aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-08-21 19:00:20 +0200
committerTaras Madan <tarasmadan@google.com>2025-08-28 11:36:44 +0000
commitd401b9d77980e7469e1c6eaa282f33df0fcfb3df (patch)
tree4a3f1285ece64120bbe75e5f336056adc77ef3dc /pkg/report
parent030f691787a240a447c5ec1491804160afa4050d (diff)
pkg/manager: add Rank column with tooltips to the main page
Diffstat (limited to 'pkg/report')
-rw-r--r--pkg/report/impact_score.go44
-rw-r--r--pkg/report/title_stat.go6
2 files changed, 47 insertions, 3 deletions
diff --git a/pkg/report/impact_score.go b/pkg/report/impact_score.go
index 63adb652a..8139644d2 100644
--- a/pkg/report/impact_score.go
+++ b/pkg/report/impact_score.go
@@ -4,6 +4,8 @@
package report
import (
+ "sort"
+
"github.com/google/syzkaller/pkg/report/crash"
)
@@ -62,3 +64,45 @@ func TitlesToImpact(title string, otherTitles ...string) int {
}
return maxImpact
}
+
+type TitleFreqRank struct {
+ Title string
+ Count int
+ Total int
+ Rank int
+}
+
+func ExplainTitleStat(ts *titleStat) []*TitleFreqRank {
+ titleCount := map[string]int{}
+ var totalCount int
+ ts.visit(func(count int, titles ...string) {
+ uniq := map[string]bool{}
+ for _, title := range titles {
+ uniq[title] = true
+ }
+ for title := range uniq {
+ titleCount[title] += count
+ }
+ totalCount += count
+ })
+ var res []*TitleFreqRank
+ for title, count := range titleCount {
+ res = append(res, &TitleFreqRank{
+ Title: title,
+ Count: count,
+ Total: totalCount,
+ Rank: TitlesToImpact(title),
+ })
+ }
+ sort.Slice(res, func(l, r int) bool {
+ if res[l].Rank != res[r].Rank {
+ return res[l].Rank > res[r].Rank
+ }
+ lTitle, rTitle := res[l].Title, res[r].Title
+ if titleCount[lTitle] != titleCount[rTitle] {
+ return titleCount[lTitle] > titleCount[rTitle]
+ }
+ return lTitle < rTitle
+ })
+ return res
+}
diff --git a/pkg/report/title_stat.go b/pkg/report/title_stat.go
index 92d8079d5..5b3cd3fb7 100644
--- a/pkg/report/title_stat.go
+++ b/pkg/report/title_stat.go
@@ -16,9 +16,9 @@ func AddTitleStat(file string, reps []*Report) error {
for _, rep := range reps {
titles = append(titles, rep.Title)
}
- stat, err := readStatFile(file)
+ stat, err := ReadStatFile(file)
if err != nil {
- return fmt.Errorf("readStatFile: %w", err)
+ return fmt.Errorf("report.ReadStatFile: %w", err)
}
stat.add(titles)
if err := writeStatFile(file, stat); err != nil {
@@ -27,7 +27,7 @@ func AddTitleStat(file string, reps []*Report) error {
return nil
}
-func readStatFile(file string) (*titleStat, error) {
+func ReadStatFile(file string) (*titleStat, error) {
stat := &titleStat{}
if _, err := os.Stat(file); errors.Is(err, os.ErrNotExist) {
return stat, nil