diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-10-11 11:38:44 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-10-15 08:34:09 +0000 |
| commit | f7ecad883569fcd9104d1296a9020cc88cbf4bc7 (patch) | |
| tree | 7902857908aa8430a5783a20d3de79075109a4a4 /tools | |
| parent | 2390a6988a188342999a14df29c36aaf9f6a6e20 (diff) | |
tools/syz-reprolist: use official API structs
Use the official API structs to avoid duplication,
prevent future bugs, and improve consistency (same field names).
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-reprolist/external_api.go | 25 | ||||
| -rw-r--r-- | tools/syz-reprolist/reprolist.go | 2 |
2 files changed, 9 insertions, 18 deletions
diff --git a/tools/syz-reprolist/external_api.go b/tools/syz-reprolist/external_api.go index 36fe4ef68..d611691cc 100644 --- a/tools/syz-reprolist/external_api.go +++ b/tools/syz-reprolist/external_api.go @@ -8,14 +8,9 @@ import ( "fmt" "log" "strings" -) -type bugList struct { - Version int - Bugs []struct { - Link string - } -} + "github.com/google/syzkaller/dashboard/api" +) func reproIDFromURL(url string) string { parts := strings.Split(url, "&") @@ -30,7 +25,7 @@ func reproIDFromURL(url string) string { } func getBugList(jsonBugs []byte) ([]string, error) { - var bl bugList + var bl api.BugGroup if err := json.Unmarshal(jsonBugs, &bl); err != nil { return nil, fmt.Errorf("json.Unmarshal: %w", err) } @@ -44,17 +39,13 @@ func getBugList(jsonBugs []byte) ([]string, error) { return res, nil } -type BugDetails struct { - ID string - Crashes []struct { - CReproURL string `json:"c-reproducer"` - } -} - -func makeBugDetails(jsonDetails []byte) (*BugDetails, error) { - var bd BugDetails +func makeBugDetails(jsonDetails []byte) (*api.Bug, error) { + var bd api.Bug if err := json.Unmarshal(jsonDetails, &bd); err != nil { return nil, fmt.Errorf("json.Unmarshal: %w", err) } + if bd.Version != 1 { + return nil, fmt.Errorf("unsupported export version %d", bd.Version) + } return &bd, nil } diff --git a/tools/syz-reprolist/reprolist.go b/tools/syz-reprolist/reprolist.go index 1881c8465..ada367baa 100644 --- a/tools/syz-reprolist/reprolist.go +++ b/tools/syz-reprolist/reprolist.go @@ -311,7 +311,7 @@ func exportNamespace() error { if err != nil { return fmt.Errorf("makeBugDetails: %w", err) } - if cReproURL := bugDetails.Crashes[0].CReproURL; cReproURL != "" { // export max 1 CRepro per bug + if cReproURL := bugDetails.Crashes[0].CReproducer; cReproURL != "" { // export max 1 CRepro per bug reproID := reproIDFromURL(cReproURL) fmt.Printf("[%d](%d/%d)saving c-repro %s for bug %s\n", i, iBug, len(bugURLs), reproID, bugDetails.ID) |
