@@ -22,6 +22,7 @@ import (
2222 "github.com/google/syzkaller/dashboard/dashapi"
2323 "github.com/google/syzkaller/pkg/debugtracer"
2424 "github.com/google/syzkaller/pkg/email"
25+ "github.com/google/syzkaller/pkg/gcs"
2526 "github.com/google/syzkaller/pkg/hash"
2627 "github.com/google/syzkaller/pkg/html"
2728 "github.com/google/syzkaller/pkg/subsystem"
@@ -65,6 +66,7 @@ func initHTTPHandlers() {
6566 http .Handle ("/" + ns + "/graph/crashes" , handlerWrapper (handleGraphCrashes ))
6667 http .Handle ("/" + ns + "/repos" , handlerWrapper (handleRepos ))
6768 http .Handle ("/" + ns + "/bug-summaries" , handlerWrapper (handleBugSummaries ))
69+ http .Handle ("/" + ns + "/all-bugs" , handlerWrapper (handleBugsTarball ))
6870 http .Handle ("/" + ns + "/subsystems" , handlerWrapper (handleSubsystemsList ))
6971 http .Handle ("/" + ns + "/backports" , handlerWrapper (handleBackports ))
7072 http .Handle ("/" + ns + "/s/" , handlerWrapper (handleSubsystemPage ))
@@ -955,6 +957,15 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
955957 if r .FormValue ("debug_subsystems" ) != "" && accessLevel == AccessAdmin {
956958 return debugBugSubsystems (c , w , bug )
957959 }
960+ if isJSONRequested (r ) {
961+ data , err := publicBugDescriptionJSON (c , bug )
962+ if err != nil {
963+ return err
964+ }
965+ w .Header ().Set ("Content-Type" , "application/json" )
966+ _ , err = w .Write (data )
967+ return err
968+ }
958969 hdr , err := commonHeader (c , r , w , bug .Namespace )
959970 if err != nil {
960971 return err
@@ -1132,11 +1143,6 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
11321143 "Cause bisection attempts" , uiList ))
11331144 }
11341145 }
1135- if isJSONRequested (r ) {
1136- w .Header ().Set ("Content-Type" , "application/json" )
1137- return writeJSONVersionOf (w , data )
1138- }
1139-
11401146 return serveTemplate (w , "bug.html" , data )
11411147}
11421148
@@ -1328,6 +1334,38 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) {
13281334 return nil , fmt .Errorf ("mandatory parameter id/extid is missing" )
13291335}
13301336
1337+ func handleBugsTarball (c context.Context , w http.ResponseWriter , r * http.Request ) error {
1338+ hdr , err := commonHeader (c , r , w , "" )
1339+ if err != nil {
1340+ log .Infof (c , "common header failed: %v" , err )
1341+ return err
1342+ }
1343+ // TODO: add it as a config.
1344+ client , err := gcs .NewClient ()
1345+ if err != nil {
1346+ log .Errorf (c , "failed create client: %v" , err )
1347+ return err
1348+ }
1349+ wc , err := client .FileWriterExt ("syzkaller.appspot.com/" + hdr .Namespace + ".tar.gz" ,
1350+ "application/tar+gzip" , "" )
1351+ if err != nil {
1352+ log .Errorf (c , "file writer ext failed: %v" , err )
1353+ return err
1354+ }
1355+ err = createPublicBugsTarball (c , hdr .Namespace , wc )
1356+ if err != nil {
1357+ log .Errorf (c , "tarball creation failed: %v" , err )
1358+ return err
1359+ }
1360+ if err := wc .Close (); err != nil {
1361+ log .Errorf (c , "unable to close writer: %v" , err )
1362+ return err
1363+ }
1364+ log .Infof (c , "tarball saved" )
1365+
1366+ return err
1367+ }
1368+
13311369func handleSubsystemsList (c context.Context , w http.ResponseWriter , r * http.Request ) error {
13321370 hdr , err := commonHeader (c , r , w , "" )
13331371 if err != nil {
@@ -1856,17 +1894,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
18561894 }
18571895 updateBugBadness (c , uiBug )
18581896 if len (bug .Commits ) != 0 {
1859- for i , com := range bug .Commits {
1860- cfg := getNsConfig (c , bug .Namespace )
1861- info := bug .getCommitInfo (i )
1862- uiBug .Commits = append (uiBug .Commits , & uiCommit {
1863- Hash : info .Hash ,
1864- Title : com ,
1865- Link : vcs .CommitLink (cfg .Repos [0 ].URL , info .Hash ),
1866- Repo : cfg .Repos [0 ].URL ,
1867- Branch : cfg .Repos [0 ].Branch ,
1868- })
1869- }
1897+ uiBug .Commits = getBugUICommits (c , bug )
18701898 for _ , mgr := range managers {
18711899 found := false
18721900 for _ , mgr1 := range bug .PatchedOn {
@@ -1887,6 +1915,22 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
18871915 return uiBug
18881916}
18891917
1918+ func getBugUICommits (c context.Context , bug * Bug ) []* uiCommit {
1919+ var ret []* uiCommit
1920+ for i , com := range bug .Commits {
1921+ cfg := getNsConfig (c , bug .Namespace )
1922+ info := bug .getCommitInfo (i )
1923+ ret = append (ret , & uiCommit {
1924+ Hash : info .Hash ,
1925+ Title : com ,
1926+ Link : vcs .CommitLink (cfg .Repos [0 ].URL , info .Hash ),
1927+ Repo : cfg .Repos [0 ].URL ,
1928+ Branch : cfg .Repos [0 ].Branch ,
1929+ })
1930+ }
1931+ return ret
1932+ }
1933+
18901934func mergeUIBug (c context.Context , bug * uiBug , dup * Bug ) {
18911935 bug .NumCrashes += dup .NumCrashes
18921936 bug .BisectCause = mergeBisectStatus (bug .BisectCause , dup .BisectCause )
0 commit comments