@@ -23,6 +23,7 @@ import (
2323 "github.com/google/syzkaller/dashboard/dashapi"
2424 "github.com/google/syzkaller/pkg/debugtracer"
2525 "github.com/google/syzkaller/pkg/email"
26+ "github.com/google/syzkaller/pkg/gcs"
2627 "github.com/google/syzkaller/pkg/hash"
2728 "github.com/google/syzkaller/pkg/html"
2829 "github.com/google/syzkaller/pkg/html/urlutil"
@@ -77,6 +78,7 @@ func initHTTPHandlers() {
7778 }
7879 http .Handle ("/" + ns + "/repos" , handlerWrapper (handleRepos ))
7980 http .Handle ("/" + ns + "/bug-summaries" , handlerWrapper (handleBugSummaries ))
81+ http .Handle ("/" + ns + "/all-bugs" , handlerWrapper (handleBugsTarball ))
8082 http .Handle ("/" + ns + "/subsystems" , handlerWrapper (handleSubsystemsList ))
8183 http .Handle ("/" + ns + "/backports" , handlerWrapper (handleBackports ))
8284 http .Handle ("/" + ns + "/s/" , handlerWrapper (handleSubsystemPage ))
@@ -1062,6 +1064,15 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
10621064 if r .FormValue ("debug_subsystems" ) != "" && accessLevel == AccessAdmin {
10631065 return debugBugSubsystems (c , w , bug )
10641066 }
1067+ if r .FormValue ("json" ) == "1" {
1068+ data , err := publicBugDescriptionJSON (c , bug )
1069+ if err != nil {
1070+ return err
1071+ }
1072+ w .Header ().Set ("Content-Type" , "application/json" )
1073+ _ , err = w .Write (data )
1074+ return err
1075+ }
10651076 hdr , err := commonHeader (c , r , w , bug .Namespace )
10661077 if err != nil {
10671078 return err
@@ -1239,11 +1250,6 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
12391250 "Cause bisection attempts" , uiList ))
12401251 }
12411252 }
1242- if r .FormValue ("json" ) == "1" {
1243- w .Header ().Set ("Content-Type" , "application/json" )
1244- return writeJSONVersionOf (w , data )
1245- }
1246-
12471253 return serveTemplate (w , "bug.html" , data )
12481254}
12491255
@@ -1431,6 +1437,62 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) {
14311437 return nil , fmt .Errorf ("mandatory parameter id/extid is missing" )
14321438}
14331439
1440+ func handleBugsTarball (c context.Context , w http.ResponseWriter , r * http.Request ) error {
1441+ hdr , err := commonHeader (c , r , w , "" )
1442+ if err != nil {
1443+ log .Infof (c , "common header failed: %v" , err )
1444+ return err
1445+ }
1446+ // TODO: add it as a config.
1447+ client , err := gcs .NewClient (c )
1448+ if err != nil {
1449+ log .Errorf (c , "failed create client: %v" , err )
1450+ return err
1451+ }
1452+ wc , err := client .FileWriter ("syzkaller.appspot.com/" + hdr .Namespace + ".tar.gz" ,
1453+ "application/tar+gzip" , "" )
1454+ if err != nil {
1455+ log .Errorf (c , "file writer ext failed: %v" , err )
1456+ return err
1457+ }
1458+
1459+ var bugs []* Bug
1460+ if r .FormValue ("fixed" ) != "" {
1461+ extraBugs , err := fetchFixPendingBugs (c , hdr .Namespace , "" )
1462+ if err != nil {
1463+ return fmt .Errorf ("failed to fetch pending bugs: %w" , err )
1464+ }
1465+ fixedBugs , _ , err := loadAllBugs (c , func (query * db.Query ) * db.Query {
1466+ return applyBugFilter (
1467+ query .Filter ("Namespace=" , hdr .Namespace ).Filter ("Status=" , BugStatusFixed ),
1468+ & userBugFilter {},
1469+ )
1470+ })
1471+ if err != nil {
1472+ return fmt .Errorf ("failed to fetch fixed bugs: %w" , err )
1473+ }
1474+ bugs = append (fixedBugs , extraBugs ... )
1475+ } else {
1476+ bugs , err = loadVisibleBugs (c , hdr .Namespace , & userBugFilter {})
1477+ if err != nil {
1478+ return fmt .Errorf ("failed to fetch visible bugs: %w" , err )
1479+ }
1480+ }
1481+
1482+ err = createPublicBugsTarball (c , bugs , wc )
1483+ if err != nil {
1484+ log .Errorf (c , "tarball creation failed: %v" , err )
1485+ return err
1486+ }
1487+ if err := wc .Close (); err != nil {
1488+ log .Errorf (c , "unable to close writer: %v" , err )
1489+ return err
1490+ }
1491+ log .Infof (c , "tarball saved" )
1492+
1493+ return err
1494+ }
1495+
14341496func handleSubsystemsList (c context.Context , w http.ResponseWriter , r * http.Request ) error {
14351497 hdr , err := commonHeader (c , r , w , "" )
14361498 if err != nil {
@@ -1961,17 +2023,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
19612023 }
19622024 updateBugBadness (c , uiBug )
19632025 if len (bug .Commits ) != 0 {
1964- for i , com := range bug .Commits {
1965- mainNsRepo , mainNsBranch := getNsConfig (c , bug .Namespace ).mainRepoBranch ()
1966- info := bug .getCommitInfo (i )
1967- uiBug .Commits = append (uiBug .Commits , & uiCommit {
1968- Hash : info .Hash ,
1969- Title : com ,
1970- Link : vcs .CommitLink (mainNsRepo , info .Hash ),
1971- Repo : mainNsRepo ,
1972- Branch : mainNsBranch ,
1973- })
1974- }
2026+ uiBug .Commits = getBugUICommits (c , bug )
19752027 for _ , mgr := range managers {
19762028 found := false
19772029 for _ , mgr1 := range bug .PatchedOn {
@@ -1992,6 +2044,22 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
19922044 return uiBug
19932045}
19942046
2047+ func getBugUICommits (c context.Context , bug * Bug ) []* uiCommit {
2048+ var ret []* uiCommit
2049+ for i , com := range bug .Commits {
2050+ mainNsRepo , mainNsBranch := getNsConfig (c , bug .Namespace ).mainRepoBranch ()
2051+ info := bug .getCommitInfo (i )
2052+ ret = append (ret , & uiCommit {
2053+ Hash : info .Hash ,
2054+ Title : com ,
2055+ Link : vcs .CommitLink (mainNsRepo , info .Hash ),
2056+ Repo : mainNsRepo ,
2057+ Branch : mainNsBranch ,
2058+ })
2059+ }
2060+ return ret
2061+ }
2062+
19952063func mergeUIBug (c context.Context , bug * uiBug , dup * Bug ) {
19962064 bug .NumCrashes += dup .NumCrashes
19972065 bug .BisectCause = mergeBisectStatus (bug .BisectCause , dup .BisectCause )
0 commit comments