Skip to content

Commit

Permalink
dashboard/app: link heatmap genetation
Browse files Browse the repository at this point in the history
  • Loading branch information
tarasmadan committed Jul 16, 2024
1 parent b66b37b commit 9201b42
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dashboard/app/graphs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
package main

import (
"bytes"
"context"
"fmt"
"html/template"
"net/http"
"net/url"
"regexp"
Expand All @@ -14,6 +16,7 @@ import (
"time"

"cloud.google.com/go/civil"
"github.com/google/syzkaller/pkg/cover"
db "google.golang.org/appengine/v2/datastore"
)

Expand Down Expand Up @@ -188,6 +191,24 @@ func handleFoundBugsGraph(c context.Context, w http.ResponseWriter, r *http.Requ
return serveTemplate(w, "graph_histogram.html", data)
}

func handleCoverageHeatmap(c context.Context, w http.ResponseWriter, r *http.Request) error {
hdr, err := commonHeader(c, r, w, "")
if err != nil {
return err
}
buf := new(bytes.Buffer)
dateFrom := civil.DateOf(time.Now())
dateTo := civil.DateOf(time.Now().Add(-14 * 24 * time.Hour))
if err = cover.DoHeatMap(buf, "syzkaller", hdr.Namespace, dateFrom, dateTo); err != nil {
return fmt.Errorf("failed to generate heatmap")
}
return serveTemplate(w, "custom_content.html", struct {
CustomContent template.HTML
}{
CustomContent: template.HTML(buf.String()),
})
}

func handleCoverageGraph(c context.Context, w http.ResponseWriter, r *http.Request) error {
hdr, err := commonHeader(c, r, w, "")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions dashboard/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func initHTTPHandlers() {
http.Handle("/"+ns+"/graph/found-bugs", handlerWrapper(handleFoundBugsGraph))
if nsConfig.Coverage != nil {
http.Handle("/"+ns+"/graph/coverage", handlerWrapper(handleCoverageGraph))
http.Handle("/"+ns+"/graph/coverage_heatmap", handlerWrapper(handleCoverageHeatmap))
}
http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos))
http.Handle("/"+ns+"/bug-summaries", handlerWrapper(handleBugSummaries))
Expand Down
18 changes: 18 additions & 0 deletions dashboard/app/templates/custom_content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{/*
Copyright 2024 syzkaller project authors. All rights reserved.
Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

Main page.
*/}}

<!doctype html>
<html>
<head>
{{template "head" .Header}}
<title>syzbot</title>
</head>
<body>
{{template "header" .Header}}
{{ .CustomContent }}
</body>
</html>

0 comments on commit 9201b42

Please sign in to comment.