Skip to content
Draft
Show file tree
Hide file tree
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
100 changes: 84 additions & 16 deletions dashboard/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/debugtracer"
"github.com/google/syzkaller/pkg/email"
"github.com/google/syzkaller/pkg/gcs"
"github.com/google/syzkaller/pkg/hash"
"github.com/google/syzkaller/pkg/html"
"github.com/google/syzkaller/pkg/html/urlutil"
Expand Down Expand Up @@ -78,6 +79,7 @@ func initHTTPHandlers() {
}
http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos))
http.Handle("/"+ns+"/bug-summaries", handlerWrapper(handleBugSummaries))
http.Handle("/"+ns+"/all-bugs", handlerWrapper(handleBugsTarball))
http.Handle("/"+ns+"/subsystems", handlerWrapper(handleSubsystemsList))
http.Handle("/"+ns+"/backports", handlerWrapper(handleBackports))
http.Handle("/"+ns+"/s/", handlerWrapper(handleSubsystemPage))
Expand Down Expand Up @@ -1065,6 +1067,15 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
if r.FormValue("debug_subsystems") != "" && accessLevel == AccessAdmin {
return debugBugSubsystems(c, w, bug)
}
if r.FormValue("json") == "1" {
data, err := publicBugDescriptionJSON(c, bug)
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json")
_, err = w.Write(data)
return err
}
hdr, err := commonHeader(c, r, w, bug.Namespace)
if err != nil {
return err
Expand Down Expand Up @@ -1242,11 +1253,6 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
"Cause bisection attempts", uiList))
}
}
if r.FormValue("json") == "1" {
w.Header().Set("Content-Type", "application/json")
return writeJSONVersionOf(w, data)
}

return serveTemplate(w, "bug.html", data)
}

Expand Down Expand Up @@ -1434,6 +1440,62 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) {
return nil, fmt.Errorf("mandatory parameter id/extid is missing")
}

func handleBugsTarball(c context.Context, w http.ResponseWriter, r *http.Request) error {
hdr, err := commonHeader(c, r, w, "")
if err != nil {
log.Infof(c, "common header failed: %v", err)
return err
}
// TODO: add it as a config.
client, err := gcs.NewClient(c)
if err != nil {
log.Errorf(c, "failed create client: %v", err)
return err
}
wc, err := client.FileWriter("syzkaller.appspot.com/"+hdr.Namespace+".tar.gz",
"application/tar+gzip", "")
if err != nil {
log.Errorf(c, "file writer ext failed: %v", err)
return err
}

var bugs []*Bug
if r.FormValue("fixed") != "" {
extraBugs, err := fetchFixPendingBugs(c, hdr.Namespace, "")
if err != nil {
return fmt.Errorf("failed to fetch pending bugs: %w", err)
}
fixedBugs, _, err := loadAllBugs(c, func(query *db.Query) *db.Query {
return applyBugFilter(
query.Filter("Namespace=", hdr.Namespace).Filter("Status=", BugStatusFixed),
&userBugFilter{},
)
})
if err != nil {
return fmt.Errorf("failed to fetch fixed bugs: %w", err)
}
bugs = append(fixedBugs, extraBugs...)
} else {
bugs, err = loadVisibleBugs(c, hdr.Namespace, &userBugFilter{})
if err != nil {
return fmt.Errorf("failed to fetch visible bugs: %w", err)
}
}

err = createPublicBugsTarball(c, bugs, wc)
if err != nil {
log.Errorf(c, "tarball creation failed: %v", err)
return err
}
if err := wc.Close(); err != nil {
log.Errorf(c, "unable to close writer: %v", err)
return err
}
log.Infof(c, "tarball saved")

return err
}

func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Request) error {
hdr, err := commonHeader(c, r, w, "")
if err != nil {
Expand Down Expand Up @@ -1965,17 +2027,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
}
updateBugBadness(c, uiBug)
if len(bug.Commits) != 0 {
for i, com := range bug.Commits {
mainNsRepo, mainNsBranch := getNsConfig(c, bug.Namespace).mainRepoBranch()
info := bug.getCommitInfo(i)
uiBug.Commits = append(uiBug.Commits, &uiCommit{
Hash: info.Hash,
Title: com,
Link: vcs.CommitLink(mainNsRepo, info.Hash),
Repo: mainNsRepo,
Branch: mainNsBranch,
})
}
uiBug.Commits = getBugUICommits(c, bug)
for _, mgr := range managers {
found := false
for _, mgr1 := range bug.PatchedOn {
Expand All @@ -1996,6 +2048,22 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
return uiBug
}

func getBugUICommits(c context.Context, bug *Bug) []*uiCommit {
var ret []*uiCommit
for i, com := range bug.Commits {
mainNsRepo, mainNsBranch := getNsConfig(c, bug.Namespace).mainRepoBranch()
info := bug.getCommitInfo(i)
ret = append(ret, &uiCommit{
Hash: info.Hash,
Title: com,
Link: vcs.CommitLink(mainNsRepo, info.Hash),
Repo: mainNsRepo,
Branch: mainNsBranch,
})
}
return ret
}

func mergeUIBug(c context.Context, bug *uiBug, dup *Bug) {
bug.NumCrashes += dup.NumCrashes
bug.BisectCause = mergeBisectStatus(bug.BisectCause, dup.BisectCause)
Expand Down
Loading
Loading