From a1839e81524f4e427a4b57bca0e4633d459d3d18 Mon Sep 17 00:00:00 2001 From: Jouni Hogander Date: Fri, 23 Oct 2020 10:51:02 +0300 Subject: tools/syz-reporter: add summary and reproducer information --- dashboard/app/static/common.js | 1 + pkg/html/generated.go | 1 + tools/syz-reporter/reporter.go | 42 ++++++++++++++++++++++++++++++------------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/dashboard/app/static/common.js b/dashboard/app/static/common.js index ec5a5c767..6b15290b1 100644 --- a/dashboard/app/static/common.js +++ b/dashboard/app/static/common.js @@ -43,6 +43,7 @@ function numSort(v) { return -parseInt(v); } function floatSort(v) { return -parseFloat(v); } function reproSort(v) { return v == "C" ? 0 : v == "syz" ? 1 : 2; } function patchedSort(v) { return v == "" ? -1 : parseInt(v); } +function lineSort(v) { return -v.split(/\r\n|\r|\n/g).length } function timeSort(v) { if (v == "now") diff --git a/pkg/html/generated.go b/pkg/html/generated.go index 5db49d857..1ed211ffc 100644 --- a/pkg/html/generated.go +++ b/pkg/html/generated.go @@ -260,6 +260,7 @@ function numSort(v) { return -parseInt(v); } function floatSort(v) { return -parseFloat(v); } function reproSort(v) { return v == "C" ? 0 : v == "syz" ? 1 : 2; } function patchedSort(v) { return v == "" ? -1 : parseInt(v); } +function lineSort(v) { return -v.split(/\r\n|\r|\n/g).length } function timeSort(v) { if (v == "now") diff --git a/tools/syz-reporter/reporter.go b/tools/syz-reporter/reporter.go index 948809ea7..6173dcf36 100644 --- a/tools/syz-reporter/reporter.go +++ b/tools/syz-reporter/reporter.go @@ -34,16 +34,18 @@ var ( ) type UISummaryData struct { - Name string - Crashes []*UICrashType - Workdir string + Name string + Crashes []*UICrashType + CrashCount int + CrashCountReproducers int + Workdir string } type UICrashType struct { Description string ID string Count int - Tags map[string]string + Reproducers map[string]string Crashes []*UICrash } @@ -90,6 +92,14 @@ func httpSummary(w io.Writer, cfg *mgrconfig.Config) error { return fmt.Errorf("failed to collect crashes: %v", err) } + data.CrashCount = len(data.Crashes) + + for _, crash := range data.Crashes { + if len(crash.Reproducers) > 0 { + data.CrashCountReproducers = data.CrashCountReproducers + 1 + } + } + if err = summaryTemplate.Execute(w, data); err != nil { return fmt.Errorf("failed to execute template: %v", err) } @@ -139,7 +149,7 @@ func readCrash(workdir, dir string) *UICrashType { } var crashes []*UICrash - tags := make(map[string]string) + reproducers := make(map[string]string) for _, f := range files { if strings.HasPrefix(f, "log") { index, err := strconv.ParseUint(f[3:], 10, 64) @@ -153,16 +163,20 @@ func readCrash(workdir, dir string) *UICrashType { if strings.HasPrefix(f, "tag") { tag, err := ioutil.ReadFile(filepath.Join(crashdir, dir, f)) if err == nil { - tags[string(tag)] = string(tag) + reproducers[string(tag)] = string(tag) } } + + if strings.HasSuffix(f, "prog") { + reproducers[f] = f + } } return &UICrashType{ Description: desc, ID: dir, Count: len(crashes), - Tags: tags, + Reproducers: reproducers, Crashes: crashes, } } @@ -186,22 +200,26 @@ var summaryTemplate = html.CreatePage(`
Workdir: {{.Workdir }}
+Crash Count: {{ .CrashCount }} +
+Crash With Reproducers Count: {{ .CrashCountReproducers }} +
- + {{range $c := $.Crashes}} - {{end}} -- cgit mrf-deployment
Crashes:
Description CountTagsReproducers
{{$c.Description}} {{$c.Count}} - {{range $tag := $c.Tags}} - {{$tag}}
- {{end}} +
+ {{range $reproducer := $c.Reproducers}} + {{$reproducer}}
+ {{end}}