aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem/linux
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-01-31 16:22:37 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-02-10 14:34:44 +0100
commitb39df73c1629cb4b2846cbb14a6a37e33d0060a1 (patch)
tree32f65a76e6ebc892b3d61f9833dc2a08f2aa4b05 /pkg/subsystem/linux
parentad871703d4fcd9ed84544dd6f5c4221aa5df5feb (diff)
pkg/subsystem: remove unneeded paths from matching rules
We don't really care about Documentation/ and similar folders. Exclude such path matching rules after parsing MAINTAINERS.
Diffstat (limited to 'pkg/subsystem/linux')
-rw-r--r--pkg/subsystem/linux/maintainers.go16
-rw-r--r--pkg/subsystem/linux/subsystems.go8
2 files changed, 24 insertions, 0 deletions
diff --git a/pkg/subsystem/linux/maintainers.go b/pkg/subsystem/linux/maintainers.go
index 6a188b261..7c60a840a 100644
--- a/pkg/subsystem/linux/maintainers.go
+++ b/pkg/subsystem/linux/maintainers.go
@@ -173,6 +173,22 @@ func (r maintainersRecord) ToPathRule() entity.PathRule {
}
}
+func removeMatchingPatterns(records []*maintainersRecord, rule *regexp.Regexp) {
+ filter := func(list []string) []string {
+ ret := []string{}
+ for _, item := range list {
+ if !rule.MatchString(item) {
+ ret = append(ret, item)
+ }
+ }
+ return ret
+ }
+ for _, record := range records {
+ record.includePatterns = filter(record.includePatterns)
+ record.excludePatterns = filter(record.excludePatterns)
+ }
+}
+
var (
escapedSeparator = regexp.QuoteMeta(fmt.Sprintf("%c", filepath.Separator))
wildcardReplace = map[byte]string{
diff --git a/pkg/subsystem/linux/subsystems.go b/pkg/subsystem/linux/subsystems.go
index abda295b4..43fea3b9e 100644
--- a/pkg/subsystem/linux/subsystems.go
+++ b/pkg/subsystem/linux/subsystems.go
@@ -7,6 +7,7 @@ import (
"fmt"
"io/fs"
"os"
+ "regexp"
"sort"
"github.com/google/syzkaller/pkg/subsystem/entity"
@@ -23,6 +24,7 @@ func listFromRepoInner(root fs.FS, rules *customRules) ([]*entity.Subsystem, err
if err != nil {
return nil, err
}
+ removeMatchingPatterns(records, dropPatterns)
ctx := &linuxCtx{
root: root,
rawRecords: records,
@@ -59,6 +61,12 @@ type subsystemCandidate struct {
commonEmail string
}
+var (
+ // Some of the patterns are not really needed for bug subsystem inteference and
+ // only complicate the manual review of the rules.
+ dropPatterns = regexp.MustCompile(`^(Documentation|scripts|samples|tools)|Makefile`)
+)
+
func (ctx *linuxCtx) groupByList() []*subsystemCandidate {
perList := make(map[string][]*maintainersRecord)
for _, record := range ctx.rawRecords {