aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/pkg/db
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 /syz-cluster/pkg/db
parentf68248c3be1d60bb978ff7034234d9e32597ee1b (diff)
syz-cluster: filter by series with findings
Add a checkbox to only display the series for which there are findings.
Diffstat (limited to 'syz-cluster/pkg/db')
-rw-r--r--syz-cluster/pkg/db/series_repo.go13
-rw-r--r--syz-cluster/pkg/db/series_repo_test.go7
2 files changed, 16 insertions, 4 deletions
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) {