OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 /* | 3 /* |
4 Runs the frontend portion of the fuzzer. This primarily is the webserver (see D
ESIGN.md) | 4 Runs the frontend portion of the fuzzer. This primarily is the webserver (see D
ESIGN.md) |
5 */ | 5 */ |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/base64" | 9 "encoding/base64" |
10 "encoding/json" | 10 "encoding/json" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 func reloadTemplates() { | 96 func reloadTemplates() { |
97 indexTemplate = template.Must(template.ParseFiles( | 97 indexTemplate = template.Must(template.ParseFiles( |
98 filepath.Join(*resourcesDir, "templates/index.html"), | 98 filepath.Join(*resourcesDir, "templates/index.html"), |
99 filepath.Join(*resourcesDir, "templates/header.html"), | 99 filepath.Join(*resourcesDir, "templates/header.html"), |
100 )) | 100 )) |
101 overviewTemplate = template.Must(template.ParseFiles( | 101 overviewTemplate = template.Must(template.ParseFiles( |
102 filepath.Join(*resourcesDir, "templates/overview.html"), | 102 filepath.Join(*resourcesDir, "templates/overview.html"), |
103 filepath.Join(*resourcesDir, "templates/header.html"), | 103 filepath.Join(*resourcesDir, "templates/header.html"), |
104 )) | 104 )) |
105 » detailsTemplate = template.Must(template.ParseFiles( | 105 » detailsTemplate = template.New("details.html") |
| 106 » // Allows this template to have Polymer binding in it and go template ma
rkup. The go templates |
| 107 » // have been changed to be {%.Thing%} instead of {{.Thing}} |
| 108 » detailsTemplate.Delims("{%", "%}") |
| 109 » detailsTemplate = template.Must(detailsTemplate.ParseFiles( |
106 filepath.Join(*resourcesDir, "templates/details.html"), | 110 filepath.Join(*resourcesDir, "templates/details.html"), |
107 filepath.Join(*resourcesDir, "templates/header.html"), | 111 filepath.Join(*resourcesDir, "templates/header.html"), |
108 )) | 112 )) |
109 } | 113 } |
110 | 114 |
111 func main() { | 115 func main() { |
112 defer common.LogPanic() | 116 defer common.LogPanic() |
113 // Calls flag.Parse() | 117 // Calls flag.Parse() |
114 common.InitWithMetrics("fuzzer", graphiteServer) | 118 common.InitWithMetrics("fuzzer", graphiteServer) |
115 | 119 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 serverURL := "https://" + *host | 207 serverURL := "https://" + *host |
204 if *local { | 208 if *local { |
205 serverURL = "http://" + *host + *port | 209 serverURL = "http://" + *host + *port |
206 } | 210 } |
207 | 211 |
208 r := mux.NewRouter() | 212 r := mux.NewRouter() |
209 r.PathPrefix("/res/").HandlerFunc(util.MakeResourceHandler(*resourcesDir
)) | 213 r.PathPrefix("/res/").HandlerFunc(util.MakeResourceHandler(*resourcesDir
)) |
210 | 214 |
211 r.HandleFunc(OAUTH2_CALLBACK_PATH, login.OAuth2CallbackHandler) | 215 r.HandleFunc(OAUTH2_CALLBACK_PATH, login.OAuth2CallbackHandler) |
212 r.HandleFunc("/", indexHandler) | 216 r.HandleFunc("/", indexHandler) |
213 » r.HandleFunc("/category/{category:[a-z_]+}", summaryPageHandler) | 217 » r.HandleFunc("/category/{category:[a-z_]+}", detailsPageHandler) |
214 r.HandleFunc("/category/{category:[a-z_]+}/name/{name}", detailsPageHand
ler) | 218 r.HandleFunc("/category/{category:[a-z_]+}/name/{name}", detailsPageHand
ler) |
215 r.HandleFunc("/category/{category:[a-z_]+}/file/{file}", detailsPageHand
ler) | 219 r.HandleFunc("/category/{category:[a-z_]+}/file/{file}", detailsPageHand
ler) |
216 r.HandleFunc("/category/{category:[a-z_]+}/file/{file}/func/{function}",
detailsPageHandler) | 220 r.HandleFunc("/category/{category:[a-z_]+}/file/{file}/func/{function}",
detailsPageHandler) |
217 r.HandleFunc(`/category/{category:[a-z_]+}/file/{file}/func/{function}/l
ine/{line}`, detailsPageHandler) | 221 r.HandleFunc(`/category/{category:[a-z_]+}/file/{file}/func/{function}/l
ine/{line}`, detailsPageHandler) |
218 r.HandleFunc("/loginstatus/", login.StatusHandler) | 222 r.HandleFunc("/loginstatus/", login.StatusHandler) |
219 r.HandleFunc("/logout/", login.LogoutHandler) | 223 r.HandleFunc("/logout/", login.LogoutHandler) |
220 r.HandleFunc("/json/version", skiaversion.JsonHandler) | 224 r.HandleFunc("/json/version", skiaversion.JsonHandler) |
221 r.HandleFunc("/json/fuzz-summary", summaryJSONHandler) | 225 r.HandleFunc("/json/fuzz-summary", summaryJSONHandler) |
222 r.HandleFunc("/json/details", detailsJSONHandler) | 226 r.HandleFunc("/json/details", detailsJSONHandler) |
223 r.HandleFunc("/json/status", statusJSONHandler) | 227 r.HandleFunc("/json/status", statusJSONHandler) |
224 r.HandleFunc(`/fuzz/{category:[a-z_]+}/{name:[0-9a-f]+}`, fuzzHandler) | 228 r.HandleFunc(`/fuzz/{category:[a-z_]+}/{name:[0-9a-f]+}`, fuzzHandler) |
225 » r.HandleFunc(`/metadata/{category:[a-z_]+}/{name:[0-9a-f]+_(debug|releas
e)\.(err|dump)}`, metadataHandler) | 229 » r.HandleFunc(`/metadata/{category:[a-z_]+}/{name:[0-9a-f]+_(debug|releas
e)\.(err|dump|asan)}`, metadataHandler) |
226 r.HandleFunc("/fuzz_count", fuzzCountHandler) | 230 r.HandleFunc("/fuzz_count", fuzzCountHandler) |
227 r.HandleFunc("/newBug", newBugHandler) | 231 r.HandleFunc("/newBug", newBugHandler) |
228 | 232 |
229 rootHandler := login.ForceAuth(util.LoggingGzipRequestResponse(r), OAUTH
2_CALLBACK_PATH) | 233 rootHandler := login.ForceAuth(util.LoggingGzipRequestResponse(r), OAUTH
2_CALLBACK_PATH) |
230 | 234 |
231 http.Handle("/", rootHandler) | 235 http.Handle("/", rootHandler) |
232 glog.Infof("Ready to serve on %s", serverURL) | 236 glog.Infof("Ready to serve on %s", serverURL) |
233 glog.Fatal(http.ListenAndServe(*port, nil)) | 237 glog.Fatal(http.ListenAndServe(*port, nil)) |
234 } | 238 } |
235 | 239 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 Category string | 275 Category string |
272 }{ | 276 }{ |
273 Category: mux.Vars(r)["category"], | 277 Category: mux.Vars(r)["category"], |
274 } | 278 } |
275 | 279 |
276 if err := overviewTemplate.Execute(w, cat); err != nil { | 280 if err := overviewTemplate.Execute(w, cat); err != nil { |
277 glog.Errorf("Failed to expand template: %v", err) | 281 glog.Errorf("Failed to expand template: %v", err) |
278 } | 282 } |
279 } | 283 } |
280 | 284 |
281 type fuzzOverview struct { | 285 type countSummary struct { |
282 Category string `json:"category"` | 286 Category string `json:"category"` |
283 CategoryDisplay string `json:"categoryDisplay"` | 287 CategoryDisplay string `json:"categoryDisplay"` |
284 TotalBad int `json:"totalBadCount"` | 288 TotalBad int `json:"totalBadCount"` |
285 TotalGrey int `json:"totalGreyCount"` | 289 TotalGrey int `json:"totalGreyCount"` |
286 // "This" means "newly introduced/fixed in this revision" | 290 // "This" means "newly introduced/fixed in this revision" |
287 ThisBad int `json:"thisBadCount"` | 291 ThisBad int `json:"thisBadCount"` |
288 ThisGrey int `json:"thisGreyCount"` | 292 ThisGrey int `json:"thisGreyCount"` |
289 } | 293 } |
290 | 294 |
291 func summaryJSONHandler(w http.ResponseWriter, r *http.Request) { | 295 func summaryJSONHandler(w http.ResponseWriter, r *http.Request) { |
292 var overview interface{} | 296 var overview interface{} |
293 if cat := r.FormValue("category"); cat != "" { | 297 if cat := r.FormValue("category"); cat != "" { |
294 overview = data.CategoryOverview(cat) | 298 overview = data.CategoryOverview(cat) |
295 } else { | 299 } else { |
296 overview = getOverview() | 300 overview = getOverview() |
297 } | 301 } |
298 | 302 |
299 if err := json.NewEncoder(w).Encode(overview); err != nil { | 303 if err := json.NewEncoder(w).Encode(overview); err != nil { |
300 glog.Errorf("Failed to write or encode output: %v", err) | 304 glog.Errorf("Failed to write or encode output: %v", err) |
301 return | 305 return |
302 } | 306 } |
303 } | 307 } |
304 | 308 |
305 func getOverview() []fuzzOverview { | 309 func getOverview() []countSummary { |
306 » overviews := make([]fuzzOverview, 0, len(fcommon.FUZZ_CATEGORIES)) | 310 » overviews := make([]countSummary, 0, len(fcommon.FUZZ_CATEGORIES)) |
307 for _, cat := range fcommon.FUZZ_CATEGORIES { | 311 for _, cat := range fcommon.FUZZ_CATEGORIES { |
308 » » o := fuzzOverview{ | 312 » » o := countSummary{ |
309 CategoryDisplay: fcommon.PrettifyCategory(cat), | 313 CategoryDisplay: fcommon.PrettifyCategory(cat), |
310 Category: cat, | 314 Category: cat, |
311 } | 315 } |
312 c := syncer.FuzzCount{ | 316 c := syncer.FuzzCount{ |
313 TotalBad: -1, | 317 TotalBad: -1, |
314 TotalGrey: -1, | 318 TotalGrey: -1, |
315 ThisBad: -1, | 319 ThisBad: -1, |
316 ThisGrey: -1, | 320 ThisGrey: -1, |
317 } | 321 } |
318 if fuzzSyncer != nil { | 322 if fuzzSyncer != nil { |
(...skipping 24 matching lines...) Expand all Loading... |
343 if err != nil { | 347 if err != nil { |
344 util.ReportError(w, r, err, "There was a problem decoding the pa
rams.") | 348 util.ReportError(w, r, err, "There was a problem decoding the pa
rams.") |
345 return | 349 return |
346 } | 350 } |
347 lineStr, err := decodeBase64(r.FormValue("line")) | 351 lineStr, err := decodeBase64(r.FormValue("line")) |
348 if err != nil { | 352 if err != nil { |
349 util.ReportError(w, r, err, "There was a problem decoding the pa
rams.") | 353 util.ReportError(w, r, err, "There was a problem decoding the pa
rams.") |
350 return | 354 return |
351 } | 355 } |
352 | 356 |
353 » var f data.FileFuzzReport | 357 » var f data.FuzzReportTree |
354 if name != "" { | 358 if name != "" { |
355 var err error | 359 var err error |
356 if f, err = data.FindFuzzDetailForFuzz(category, name); err != n
il { | 360 if f, err = data.FindFuzzDetailForFuzz(category, name); err != n
il { |
357 util.ReportError(w, r, err, "There was a problem fulfill
ing the request.") | 361 util.ReportError(w, r, err, "There was a problem fulfill
ing the request.") |
358 } | 362 } |
359 } else { | 363 } else { |
360 line, err := strconv.ParseInt(lineStr, 10, 32) | 364 line, err := strconv.ParseInt(lineStr, 10, 32) |
361 if err != nil { | 365 if err != nil { |
362 line = fcommon.UNKNOWN_LINE | 366 line = fcommon.UNKNOWN_LINE |
363 } | 367 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 w.Header().Set("Content-Type", "application/json") | 448 w.Header().Set("Content-Type", "application/json") |
445 | 449 |
446 s := status{ | 450 s := status{ |
447 Current: commit{ | 451 Current: commit{ |
448 Hash: "loading", | 452 Hash: "loading", |
449 Author: "(Loading)", | 453 Author: "(Loading)", |
450 }, | 454 }, |
451 Pending: nil, | 455 Pending: nil, |
452 } | 456 } |
453 | 457 |
454 » s.Current.Hash = config.FrontEnd.SkiaVersion.Hash | 458 » if config.FrontEnd.SkiaVersion != nil { |
455 » s.Current.Author = config.FrontEnd.SkiaVersion.Author | 459 » » s.Current.Hash = config.FrontEnd.SkiaVersion.Hash |
456 » if versionWatcher != nil { | 460 » » s.Current.Author = config.FrontEnd.SkiaVersion.Author |
457 » » if pending := versionWatcher.PendingVersion; pending != nil { | 461 » » if versionWatcher != nil { |
458 » » » s.Pending = &commit{ | 462 » » » if pending := versionWatcher.PendingVersion; pending !=
nil { |
459 » » » » Hash: pending.Hash, | 463 » » » » s.Pending = &commit{ |
460 » » » » Author: pending.Author, | 464 » » » » » Hash: pending.Hash, |
| 465 » » » » » Author: pending.Author, |
| 466 » » » » } |
461 } | 467 } |
462 } | 468 } |
463 } | 469 } |
464 | 470 |
465 if err := json.NewEncoder(w).Encode(s); err != nil { | 471 if err := json.NewEncoder(w).Encode(s); err != nil { |
466 glog.Errorf("Failed to write or encode output: %s", err) | 472 glog.Errorf("Failed to write or encode output: %s", err) |
467 return | 473 return |
468 } | 474 } |
469 } | 475 } |
470 | 476 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 522 } |
517 var t bytes.Buffer | 523 var t bytes.Buffer |
518 if err := newBugTemplate.Execute(&t, b); err != nil { | 524 if err := newBugTemplate.Execute(&t, b); err != nil { |
519 util.ReportError(w, r, err, fmt.Sprintf("Could not create templa
te with %#v", b)) | 525 util.ReportError(w, r, err, fmt.Sprintf("Could not create templa
te with %#v", b)) |
520 return | 526 return |
521 } | 527 } |
522 q.Add("comment", t.String()) | 528 q.Add("comment", t.String()) |
523 // 303 means "make a GET request to this url" | 529 // 303 means "make a GET request to this url" |
524 http.Redirect(w, r, "https://bugs.chromium.org/p/skia/issues/entry?"+q.E
ncode(), 303) | 530 http.Redirect(w, r, "https://bugs.chromium.org/p/skia/issues/entry?"+q.E
ncode(), 303) |
525 } | 531 } |
OLD | NEW |