diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-08-11 19:39:01 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-08-12 13:50:10 +0000 |
| commit | 22ec1469fe8c0ba256de07e8f97fa7b375b522bd (patch) | |
| tree | de927aefce9e35e07b0e4995b1e9e2db9bb4bf5a /tools | |
| parent | 82ebc27e38347216ed3ea06577fa3b9627164be1 (diff) | |
tools/syz-lore: support bash wildcard results
Instead of accepting a folder name and traversing all nested folders in
it, accept the directories to process as separate arguments. This allows
for more flexibility - one can either specify just one archive to
process or one can use bash wildcards to achieve the previously default
functionality.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-lore/query_lkml.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/tools/syz-lore/query_lkml.go b/tools/syz-lore/query_lkml.go index 10a0c1ecd..4b299c3e8 100644 --- a/tools/syz-lore/query_lkml.go +++ b/tools/syz-lore/query_lkml.go @@ -8,7 +8,6 @@ import ( "encoding/json" "flag" "log" - "os" "path/filepath" "runtime" "strings" @@ -29,7 +28,6 @@ import ( // The syz-lore tool can parse Lore archives and extract syzbot-related conversations from there. var ( - flagArchives = flag.String("archives", "", "path to the folder with git archives") flagEmails = flag.String("emails", "", "comma-separated list of own emails") flagDomains = flag.String("domains", "", "comma-separated list of own domains") flagOutDir = flag.String("out_dir", "", "a directory to save discussions as JSON files") @@ -41,12 +39,12 @@ var ( func main() { defer tool.Init()() - if !osutil.IsDir(*flagArchives) { - tool.Failf("the arhives parameter must be a valid directory") + if len(flag.Args()) == 0 { + tool.Failf("format: syz-lore [flags] dir1 [dir2 ...]") } emails := strings.Split(*flagEmails, ",") domains := strings.Split(*flagDomains, ",") - threads := processArchives(*flagArchives, emails, domains) + threads := processArchives(flag.Args(), emails, domains) for i, thread := range threads { messages := []dashapi.DiscussionMessage{} for _, m := range thread.Messages { @@ -102,22 +100,14 @@ func saveDiscussion(d *dashapi.Discussion) error { return nil } -func processArchives(dir string, emails, domains []string) []*lore.Thread { - entries, err := os.ReadDir(dir) - if err != nil { - tool.Failf("failed to read directory: %v", err) - } +func processArchives(paths, emails, domains []string) []*lore.Thread { threads := runtime.NumCPU() messages := make(chan lore.EmailReader, threads*2) wg := sync.WaitGroup{} g, _ := errgroup.WithContext(context.Background()) // Generate per-email jobs. - for _, entry := range entries { - if !entry.IsDir() { - continue - } - path := filepath.Join(dir, entry.Name()) + for _, path := range paths { log.Printf("reading %s", path) wg.Add(1) g.Go(func() error { |
