Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions tools/syz-aflow/aflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@

func main() {
var (
flagFlow = flag.String("workflow", "", "workflow to execute")
flagInput = flag.String("input", "", "input json file with workflow arguments")
flagWorkdir = flag.String("workdir", "", "directory for kernel checkout, kernel builds, etc")
flagModel = flag.String("model", "", "use this LLM model, if empty use default models")
flagCacheSize = flag.String("cache-size", "10GB", "max cache size (e.g. 100MB, 5GB, 1TB)")
flagDownloadBug = flag.String("download-bug", "", "extid of a bug to download from the dashboard"+
" and save into -input file")
flagAuth = flag.Bool("auth", false, "use gcloud auth token for downloading bugs (set it up with"+
" gcloud auth application-default login)")
flagFlow = flag.String("workflow", "", "workflow to execute")
flagInput = flag.String("input", "", "input json file with workflow arguments")
flagWorkdir = flag.String("workdir", "", "directory for kernel checkout, kernel builds, etc")
flagModel = flag.String("model", "", "use this LLM model, if empty use default models")
flagCacheSize = flag.String("cache-size", "10GB", "max cache size (e.g. 100MB, 5GB, 1TB)")
flagDownloadBugByExtID = flag.String("download-bug-by-extid", "", "extid of a bug to download from the dashboard and save into -input file")

Check failure on line 38 in tools/syz-aflow/aflow.go

View workflow job for this annotation

GitHub Actions / build

The line is 142 characters long, which exceeds the maximum of 120 characters. (lll)
flagDownloadBugByID = flag.String("download-bug-by-id", "", "id of a bug to download from the dashboard and save into -input file")

Check failure on line 39 in tools/syz-aflow/aflow.go

View workflow job for this annotation

GitHub Actions / build

The line is 136 characters long, which exceeds the maximum of 120 characters. (lll)
flagAuth = flag.Bool("auth", false, "use gcloud auth token for downloading bugs (set it up with gcloud auth application-default login)")

Check failure on line 40 in tools/syz-aflow/aflow.go

View workflow job for this annotation

GitHub Actions / build

The line is 152 characters long, which exceeds the maximum of 120 characters. (lll)
)
defer tool.Init()()
if *flagDownloadBug != "" {
if *flagDownloadBugByExtID != "" || *flagDownloadBugByID != "" {
token := ""
if *flagAuth {
var err error
Expand All @@ -50,7 +49,13 @@
tool.Fail(err)
}
}
if err := downloadBug(*flagDownloadBug, *flagInput, token); err != nil {
var err error
if *flagDownloadBugByExtID != "" {
err = downloadBug(true, *flagDownloadBugByExtID, *flagInput, token)
} else {
err = downloadBug(false, *flagDownloadBugByID, *flagInput, token)
}
if err != nil {
tool.Fail(err)
}
return
Expand Down Expand Up @@ -104,11 +109,17 @@
return nil
}

func downloadBug(extID, inputFile, token string) error {
func downloadBug(useExtID bool, id, inputFile, token string) error {
if inputFile == "" {
return fmt.Errorf("-download-bug requires -input flag")
}
resp, err := get(fmt.Sprintf("/bug?extid=%v&json=1", extID), token)
var resp string
var err error
if useExtID {
resp, err = get(fmt.Sprintf("/bug?extid=%v&json=1", id), token)
} else {
resp, err = get(fmt.Sprintf("/bug?id=%v&json=1", id), token)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just try to download one link, and if it produced an error try to download the other one. It would make it simpler for users, and the code simpler too.

}
if err != nil {
return err
}
Expand Down
Loading