diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-02-23 19:30:35 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-02-24 10:29:40 +0100 |
| commit | 0e6628e0d76d6fd6ccb2f4966e144f13fdc68c5c (patch) | |
| tree | f9345f4e0dfb3a0e927f1bb456afb1feaaad25b8 /tools | |
| parent | a1ab4f01d34b4a7858d84bd662b511f55b4b65c4 (diff) | |
tools/syz-query-subsystems: add filtering functionality
Two more flags:
- filter: allows to choose only a subset of the possible subsystems.
- emails: allows to force empty Lists and Maintainers.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-query-subsystems/query_subsystems.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/syz-query-subsystems/query_subsystems.go b/tools/syz-query-subsystems/query_subsystems.go index 54ef93d35..29fa9e81a 100644 --- a/tools/syz-query-subsystems/query_subsystems.go +++ b/tools/syz-query-subsystems/query_subsystems.go @@ -15,6 +15,7 @@ import ( "strings" "github.com/google/syzkaller/pkg/osutil" + "github.com/google/syzkaller/pkg/subsystem" "github.com/google/syzkaller/pkg/subsystem/linux" "github.com/google/syzkaller/pkg/tool" "github.com/google/syzkaller/pkg/vcs" @@ -25,6 +26,8 @@ var ( flagKernelRepo = flag.String("kernel", "", "path to the OS kernel source directory") flagSyzkallerRepo = flag.String("syzkaller", "", "path to the syzkaller repo") flagName = flag.String("name", "", "the name under which the list should be saved") + flagFilter = flag.String("filter", "", "comma-separated list of subsystems to keep") + flagEmails = flag.Bool("emails", true, "save lists and maintainer fields") ) var nameRe = regexp.MustCompile(`^[a-z]\w*$`) @@ -49,6 +52,7 @@ func main() { if err != nil { tool.Failf("failed to query subsystems: %v", err) } + list = postProcessList(list) // Save the list. folder := filepath.Join(*flagSyzkallerRepo, "pkg", "subsystem", "lists") if err = osutil.MkdirAll(folder); err != nil { @@ -65,6 +69,32 @@ func main() { } } +func postProcessList(list []*subsystem.Subsystem) []*subsystem.Subsystem { + if *flagFilter != "" { + list = subsystem.FilterList(list, prepareFilter()) + } + if !*flagEmails { + for _, item := range list { + item.Lists = nil + item.Maintainers = nil + } + } + return list +} + +func prepareFilter() func(*subsystem.Subsystem) bool { + keep := map[string]bool{} + for _, name := range strings.Split(*flagFilter, ",") { + name = strings.TrimSpace(name) + if name != "" { + keep[name] = true + } + } + return func(s *subsystem.Subsystem) bool { + return keep[s.Name] + } +} + func determineCommitInfo(dir string) string { // Best effort only. repo, err := vcs.NewRepo(*flagOS, "", dir, vcs.OptPrecious, vcs.OptDontSandbox) |
