diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-11-28 18:08:15 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-12-29 10:47:28 +0000 |
| commit | 4086874033ecb76c219de0caf61b4c285c6d0e95 (patch) | |
| tree | 5e31e73c15a0e390aaf7dc51e865bc7071457c2e /dashboard | |
| parent | ba994aabc89d9006610a4c6e1752eeb0b639242c (diff) | |
dashboard: extend bug's JSON representation
Add status, crash, fix, close and commit dates.
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/api/api.go | 28 | ||||
| -rw-r--r-- | dashboard/app/main.go | 2 | ||||
| -rw-r--r-- | dashboard/app/public_json_api.go | 42 | ||||
| -rw-r--r-- | dashboard/app/public_json_api_test.go | 21 |
4 files changed, 73 insertions, 20 deletions
diff --git a/dashboard/api/api.go b/dashboard/api/api.go index 09dcf7690..cafdd170e 100644 --- a/dashboard/api/api.go +++ b/dashboard/api/api.go @@ -5,6 +5,8 @@ // All structures in this package are backwards compatible. package api +import "time" + const Version = 1 type BugGroup struct { @@ -20,11 +22,16 @@ type BugSummary struct { } type Bug struct { - Version int `json:"version"` - Title string `json:"title,omitempty"` - ID string `json:"id"` - FixCommits []Commit `json:"fix-commits,omitempty"` - CauseCommit *Commit `json:"cause-commit,omitempty"` + Version int `json:"version"` + Title string `json:"title,omitempty"` + ID string `json:"id"` + Status string `json:"status"` + FirstCrash time.Time `json:"first-crash"` + LastCrash time.Time `json:"last-crash"` + FixTime *time.Time `json:"fix-time,omitempty"` + CloseTime *time.Time `json:"close-time,omitempty"` + FixCommits []Commit `json:"fix-commits,omitempty"` + CauseCommit *Commit `json:"cause-commit,omitempty"` // Links to the discussions. Discussions []string `json:"discussions,omitempty"` Crashes []Crash `json:"crashes,omitempty"` @@ -45,9 +52,10 @@ type Crash struct { } type Commit struct { - Title string `json:"title"` - Link string `json:"link,omitempty"` - Hash string `json:"hash,omitempty"` - Repo string `json:"repo,omitempty"` - Branch string `json:"branch,omitempty"` + Title string `json:"title"` + Link string `json:"link,omitempty"` + Hash string `json:"hash,omitempty"` + Repo string `json:"repo,omitempty"` + Branch string `json:"branch,omitempty"` + Date *time.Time `json:"date,omitempty"` } diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 2fb4a14fb..95bd08919 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -389,6 +389,7 @@ type uiBug struct { FirstTime time.Time LastTime time.Time ReportedTime time.Time + FixTime time.Time ClosedTime time.Time ReproLevel dashapi.ReproLevel ReportingIndex int @@ -1967,6 +1968,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers [] LastTime: bug.LastTime, ReportedTime: reported, ClosedTime: bug.Closed, + FixTime: bug.FixTime, ReproLevel: bug.ReproLevel, ReportingIndex: reportingIdx, Status: status, diff --git a/dashboard/app/public_json_api.go b/dashboard/app/public_json_api.go index 104ee42a1..89adfd29e 100644 --- a/dashboard/app/public_json_api.go +++ b/dashboard/app/public_json_api.go @@ -18,9 +18,24 @@ import ( func getExtAPIDescrForBug(bug *uiBugDetails) *api.Bug { return &api.Bug{ - Version: api.Version, - Title: bug.Title, - ID: bug.ID, + Version: api.Version, + Title: bug.Title, + ID: bug.ID, + Status: bug.Status, + FirstCrash: bug.FirstTime, + LastCrash: bug.LastTime, + FixTime: func() *time.Time { + if bug.FixTime.IsZero() { + return nil + } + return &bug.FixTime + }(), + CloseTime: func() *time.Time { + if bug.ClosedTime.IsZero() { + return nil + } + return &bug.ClosedTime + }(), Discussions: func() []string { if bug.ExternalLink == "" { return nil @@ -29,16 +44,21 @@ func getExtAPIDescrForBug(bug *uiBugDetails) *api.Bug { }(), FixCommits: getBugFixCommits(bug.uiBug), CauseCommit: func() *api.Commit { - if bug.BisectCause == nil || bug.BisectCause.Commit == nil { + bisectCause := bug.BisectCauseJob + if bisectCause == nil || bisectCause.Commit == nil { return nil } - bisectCause := bug.BisectCause - return &api.Commit{ + commit := &api.Commit{ Title: bisectCause.Commit.Title, Link: bisectCause.Commit.Link, Hash: bisectCause.Commit.Hash, Repo: bisectCause.KernelRepo, - Branch: bisectCause.KernelBranch} + Branch: bisectCause.KernelBranch, + } + if !bisectCause.Commit.Date.IsZero() { + commit.Date = &bisectCause.Commit.Date + } + return commit }(), Crashes: func() []api.Crash { var res []api.Crash @@ -65,13 +85,17 @@ func getExtAPIDescrForBug(bug *uiBugDetails) *api.Bug { func getBugFixCommits(bug *uiBug) []api.Commit { var res []api.Commit for _, commit := range bug.Commits { - res = append(res, api.Commit{ + apiCommit := api.Commit{ Title: commit.Title, Link: commit.Link, Hash: commit.Hash, Repo: commit.Repo, Branch: commit.Branch, - }) + } + if !commit.Date.IsZero() { + apiCommit.Date = &commit.Date + } + res = append(res, apiCommit) } return res } diff --git a/dashboard/app/public_json_api_test.go b/dashboard/app/public_json_api_test.go index 081bcee23..f98c0d3f8 100644 --- a/dashboard/app/public_json_api_test.go +++ b/dashboard/app/public_json_api_test.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "testing" + "time" "github.com/google/syzkaller/dashboard/api" "github.com/google/syzkaller/dashboard/dashapi" @@ -23,6 +24,9 @@ func TestJSONAPIIntegration(t *testing.T) { "version": 1, "title": "title1", "id": "cb1dbe55dc6daa7e739a0d09a0ae4d5e3e5a10c8", + "status": "reporting1: reported on 2000/01/01 00:01", + "first-crash": "2000-01-01T00:01:00Z", + "last-crash": "2000-01-01T00:01:00Z", "crashes": [ { "title": "title1", @@ -40,6 +44,9 @@ func TestJSONAPIIntegration(t *testing.T) { "version": 1, "title": "title2", "id": "fc00fbc0cddd9a4ef2ae33e40cd21636081466ce", + "status": "reporting1: reported C repro on 2000/01/01 00:01", + "first-crash": "2000-01-01T00:01:00Z", + "last-crash": "2000-01-01T00:01:00Z", "crashes": [ { "title": "title2", @@ -100,6 +107,7 @@ func TestJSONAPIIntegration(t *testing.T) { c.client.UploadBuild(build) crash1 := testCrash(build, 1) + c.advanceTime(time.Minute) c.client.ReportCrash(crash1) bugReport1 := c.client.pollBug() checkBugPageJSONIs(c, bugReport1.ID, sampleCrashDescr) @@ -121,6 +129,7 @@ func TestJSONAPIIntegration(t *testing.T) { } func checkBugPageJSONIs(c *Ctx, ID string, expectedContent []byte) { + c.t.Helper() url := fmt.Sprintf("/bug?extid=%v&json=1", ID) contentType, _ := c.client.ContentType(url) @@ -131,6 +140,7 @@ func checkBugPageJSONIs(c *Ctx, ID string, expectedContent []byte) { } func checkBugGroupPageJSONIs(c *Ctx, url string, expectedContent []byte) { + c.t.Helper() contentType, _ := c.client.ContentType(url) c.expectEQ(contentType, "application/json") @@ -150,6 +160,7 @@ func TestJSONAPIFixCommits(t *testing.T) { rep1 := c.client.pollBug() // Specify fixing commit for the bug. + c.advanceTime(time.Hour) c.client.ReportingUpdate(&dashapi.BugUpdate{ ID: rep1.ID, Status: dashapi.BugStatusOpen, @@ -166,6 +177,10 @@ func TestJSONAPIFixCommits(t *testing.T) { "version": 1, "title": "title1", "id": "cb1dbe55dc6daa7e739a0d09a0ae4d5e3e5a10c8", + "status": "reporting1: reported on 2000/01/01 00:00", + "first-crash": "2000-01-01T00:00:00Z", + "last-crash": "2000-01-01T00:00:00Z", + "fix-time": "2000-01-01T01:00:00Z", "fix-commits": [ { "title": "foo: fix1", @@ -210,11 +225,15 @@ func TestJSONAPICauseBisection(t *testing.T) { "version": 1, "title": "title1", "id": "70ce63ecb151d563976728208edccc6879191f9f", + "status": "reporting2: reported C repro on 2000/01/31 00:00", + "first-crash": "2000-01-01T00:00:00Z", + "last-crash": "2000-01-01T00:00:00Z", "cause-commit": { "title": "kernel: add a bug", "hash": "36e65cb4a0448942ec316b24d60446bbd5cc7827", "repo": "repo1", - "branch": "branch1" + "branch": "branch1", + "date": "2000-02-09T04:05:06Z" }, "crashes": [ { |
