aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-04-09 13:21:52 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-04-10 10:37:46 +0000
commitd3827d51bf4ac8ac9ae98149933f1f6b34d228aa (patch)
treebcc2dd4ebaebf582b736d44030cfaef31c74c205
parentf68248c3be1d60bb978ff7034234d9e32597ee1b (diff)
syz-cluster: filter by series with findings
Add a checkbox to only display the series for which there are findings.
-rw-r--r--syz-cluster/dashboard/handler.go9
-rw-r--r--syz-cluster/dashboard/templates/index.html7
-rw-r--r--syz-cluster/pkg/db/series_repo.go13
-rw-r--r--syz-cluster/pkg/db/series_repo_test.go7
4 files changed, 28 insertions, 8 deletions
diff --git a/syz-cluster/dashboard/handler.go b/syz-cluster/dashboard/handler.go
index 318705e7f..fe9129373 100644
--- a/syz-cluster/dashboard/handler.go
+++ b/syz-cluster/dashboard/handler.go
@@ -100,10 +100,11 @@ func (h *dashboardHandler) seriesList(w http.ResponseWriter, r *http.Request) er
baseURL := r.URL.RequestURI()
data := MainPageData{
Filter: db.SeriesFilter{
- Cc: r.FormValue("cc"),
- Status: db.SessionStatus(r.FormValue("status")),
- Limit: perPage,
- Offset: offset,
+ Cc: r.FormValue("cc"),
+ Status: db.SessionStatus(r.FormValue("status")),
+ WithFindings: r.FormValue("with_findings") != "",
+ Limit: perPage,
+ Offset: offset,
},
// If the filters are changed, the old offset value is irrelevant.
FilterFormURL: urlutil.DropParam(baseURL, "offset", ""),
diff --git a/syz-cluster/dashboard/templates/index.html b/syz-cluster/dashboard/templates/index.html
index c87285b58..d5f5102b0 100644
--- a/syz-cluster/dashboard/templates/index.html
+++ b/syz-cluster/dashboard/templates/index.html
@@ -15,6 +15,13 @@
{{end}}
</select>
</div>
+ <div class="form-check col-auto">
+ <input class="form-check-input" type="checkbox" name="with_findings" value="true"
+ id="onlyWithFindings"{{if .Filter.WithFindings}} checked=""{{end}}>
+ <label class="form-check-label" for="onlyWithFindings">
+ Only with findings
+ </label>
+ </div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
diff --git a/syz-cluster/pkg/db/series_repo.go b/syz-cluster/pkg/db/series_repo.go
index 5f414b7cc..00043f1a8 100644
--- a/syz-cluster/pkg/db/series_repo.go
+++ b/syz-cluster/pkg/db/series_repo.go
@@ -133,10 +133,11 @@ type SeriesWithSession struct {
}
type SeriesFilter struct {
- Cc string
- Status SessionStatus
- Limit int
- Offset int
+ Cc string
+ Status SessionStatus
+ WithFindings bool
+ Limit int
+ Offset int
}
// ListLatest() returns the list of series ordered by the decreasing PublishedAt value.
@@ -174,6 +175,10 @@ func (repo *SeriesRepository) ListLatest(ctx context.Context, filter SeriesFilte
}
stmt.SQL += ")"
}
+ if filter.WithFindings {
+ stmt.SQL += " AND Series.LatestSessionID IS NOT NULL " +
+ "AND EXISTS(SELECT 1 FROM Findings WHERE Findings.SessionID = Series.LatestSessionID)"
+ }
stmt.SQL += " ORDER BY PublishedAt DESC, ID"
if filter.Limit > 0 {
stmt.SQL += " LIMIT @limit"
diff --git a/syz-cluster/pkg/db/series_repo_test.go b/syz-cluster/pkg/db/series_repo_test.go
index ca84b70a8..ab13b8e12 100644
--- a/syz-cluster/pkg/db/series_repo_test.go
+++ b/syz-cluster/pkg/db/series_repo_test.go
@@ -153,6 +153,13 @@ func TestSeriesRepositoryList(t *testing.T) {
assert.Len(t, list, 1)
assert.Equal(t, 1, list[0].Findings, "there must be just one finding")
})
+
+ t.Run("query_with_findings", func(t *testing.T) {
+ list, err := repo.ListLatest(ctx, SeriesFilter{WithFindings: true}, time.Time{})
+ assert.NoError(t, err)
+ assert.Len(t, list, 1)
+ assert.Equal(t, "Series 2", list[0].Series.Title)
+ })
}
func TestSeriesRepositoryUpdate(t *testing.T) {