Skip to content

Commit 22ec146

Browse files
committed
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.
1 parent 82ebc27 commit 22ec146

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

tools/syz-lore/query_lkml.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"flag"
1010
"log"
11-
"os"
1211
"path/filepath"
1312
"runtime"
1413
"strings"
@@ -29,7 +28,6 @@ import (
2928
// The syz-lore tool can parse Lore archives and extract syzbot-related conversations from there.
3029

3130
var (
32-
flagArchives = flag.String("archives", "", "path to the folder with git archives")
3331
flagEmails = flag.String("emails", "", "comma-separated list of own emails")
3432
flagDomains = flag.String("domains", "", "comma-separated list of own domains")
3533
flagOutDir = flag.String("out_dir", "", "a directory to save discussions as JSON files")
@@ -41,12 +39,12 @@ var (
4139

4240
func main() {
4341
defer tool.Init()()
44-
if !osutil.IsDir(*flagArchives) {
45-
tool.Failf("the arhives parameter must be a valid directory")
42+
if len(flag.Args()) == 0 {
43+
tool.Failf("format: syz-lore [flags] dir1 [dir2 ...]")
4644
}
4745
emails := strings.Split(*flagEmails, ",")
4846
domains := strings.Split(*flagDomains, ",")
49-
threads := processArchives(*flagArchives, emails, domains)
47+
threads := processArchives(flag.Args(), emails, domains)
5048
for i, thread := range threads {
5149
messages := []dashapi.DiscussionMessage{}
5250
for _, m := range thread.Messages {
@@ -102,22 +100,14 @@ func saveDiscussion(d *dashapi.Discussion) error {
102100
return nil
103101
}
104102

105-
func processArchives(dir string, emails, domains []string) []*lore.Thread {
106-
entries, err := os.ReadDir(dir)
107-
if err != nil {
108-
tool.Failf("failed to read directory: %v", err)
109-
}
103+
func processArchives(paths, emails, domains []string) []*lore.Thread {
110104
threads := runtime.NumCPU()
111105
messages := make(chan lore.EmailReader, threads*2)
112106
wg := sync.WaitGroup{}
113107
g, _ := errgroup.WithContext(context.Background())
114108

115109
// Generate per-email jobs.
116-
for _, entry := range entries {
117-
if !entry.IsDir() {
118-
continue
119-
}
120-
path := filepath.Join(dir, entry.Name())
110+
for _, path := range paths {
121111
log.Printf("reading %s", path)
122112
wg.Add(1)
123113
g.Go(func() error {

0 commit comments

Comments
 (0)