From 573dd3df4750cfd2b79826f6cbbeade35625417e Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Wed, 28 Jun 2023 08:35:41 +0200 Subject: dashboard: export causeBug repo + branch --- dashboard/app/getjson_test.go | 4 +++- dashboard/app/jobs.go | 2 ++ dashboard/app/main.go | 4 ++++ dashboard/app/public_json_api.go | 41 +++++++++++++++++++++++++--------------- dashboard/dashapi/dashapi.go | 2 ++ 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/dashboard/app/getjson_test.go b/dashboard/app/getjson_test.go index 64097c0eb..6a524a20d 100644 --- a/dashboard/app/getjson_test.go +++ b/dashboard/app/getjson_test.go @@ -166,7 +166,9 @@ func TestJSONAPICauseBisection(t *testing.T) { "title": "title1", "cause-commit": { "title": "kernel: add a bug", - "hash": "36e65cb4a0448942ec316b24d60446bbd5cc7827" + "hash": "36e65cb4a0448942ec316b24d60446bbd5cc7827", + "repo": "repo1", + "branch": "branch1" }, "crashes": [ { diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go index b7e8a8b0d..bb9e98b88 100644 --- a/dashboard/app/jobs.go +++ b/dashboard/app/jobs.go @@ -1488,6 +1488,8 @@ func makeJobInfo(c context.Context, job *Job, jobKey *db.Key, bug *Bug, build *B Namespace: job.Namespace, Manager: job.Manager, BugTitle: job.BugTitle, + KernelRepo: job.KernelRepo, + KernelBranch: job.KernelBranch, KernelAlias: kernelRepoInfoRaw(c, job.Namespace, job.KernelRepo, job.KernelBranch).Alias, KernelCommit: kernelCommit, KernelCommitLink: vcs.CommitLink(kernelRepo, kernelCommit), diff --git a/dashboard/app/main.go b/dashboard/app/main.go index e971dfa3a..f680563bb 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -212,6 +212,8 @@ type uiBuild struct { SyzkallerCommit string SyzkallerCommitLink string SyzkallerCommitDate time.Time + KernelRepo string + KernelBranch string KernelAlias string KernelCommit string KernelCommitLink string @@ -1725,6 +1727,8 @@ func makeUIBuild(c context.Context, build *Build) *uiBuild { SyzkallerCommit: build.SyzkallerCommit, SyzkallerCommitLink: vcs.LogLink(vcs.SyzkallerRepo, build.SyzkallerCommit), SyzkallerCommitDate: build.SyzkallerCommitDate, + KernelRepo: build.KernelRepo, + KernelBranch: build.KernelBranch, KernelAlias: kernelRepoInfo(c, build).Alias, KernelCommit: build.KernelCommit, KernelCommitLink: vcs.LogLink(build.KernelRepo, build.KernelCommit), diff --git a/dashboard/app/public_json_api.go b/dashboard/app/public_json_api.go index 466135710..04499d8f8 100644 --- a/dashboard/app/public_json_api.go +++ b/dashboard/app/public_json_api.go @@ -3,7 +3,11 @@ package main -import "encoding/json" +import ( + "encoding/json" + + "github.com/google/syzkaller/dashboard/dashapi" +) // publicApiBugDescription is used to serve the /bug HTTP requests // and provide JSON description of the BUG. Backward compatible. @@ -18,9 +22,21 @@ type publicAPIBugDescription struct { } type vcsCommit struct { - Title string `json:"title"` - Link string `json:"link,omitempty"` - Hash string `json:"hash,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"` +} + +func makeVCSCommit(commit *dashapi.Commit, repo, branch string) *vcsCommit { + return &vcsCommit{ + Title: commit.Title, + Link: commit.Link, + Hash: commit.Hash, + Repo: repo, + Branch: branch, + } } type publicAPICrashDescription struct { @@ -52,11 +68,9 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription { } var res []vcsCommit for _, commit := range bugPage.Bug.Commits { - res = append(res, vcsCommit{ - Title: commit.Title, - Hash: commit.Hash, - Link: commit.Link, - }) + // TODO: add repoName and branchName to CommitInfo and + // forward it here as commit.Repo + commit.Branch. + res = append(res, *makeVCSCommit(commit, "", "")) } return res }(), @@ -64,12 +78,9 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription { if bugPage.BisectCause == nil || bugPage.BisectCause.Commit == nil { return nil } - commit := bugPage.BisectCause.Commit - return &vcsCommit{ - Title: commit.Title, - Hash: commit.Hash, - Link: commit.Link, - } + return makeVCSCommit(bugPage.BisectCause.Commit, + bugPage.BisectCause.KernelRepo, + bugPage.BisectCause.KernelBranch) }(), Crashes: []publicAPICrashDescription{{ SyzReproducer: crash.ReproSyzLink, diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go index d151b1618..96e8dff0e 100644 --- a/dashboard/dashapi/dashapi.go +++ b/dashboard/dashapi/dashapi.go @@ -878,6 +878,8 @@ type JobInfo struct { Manager string BugTitle string BugID string + KernelRepo string + KernelBranch string KernelAlias string KernelCommit string KernelCommitLink string -- cgit mrf-deployment