Skip to content

Commit 2055c0a

Browse files
committed
syz-cluster: filter by series with findings
Add a checkbox to only display the series for which there are findings.
1 parent 87b60d5 commit 2055c0a

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

syz-cluster/dashboard/handler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ func (h *dashboardHandler) seriesList(w http.ResponseWriter, r *http.Request) er
100100
baseURL := r.URL.RequestURI()
101101
data := MainPageData{
102102
Filter: db.SeriesFilter{
103-
Cc: r.FormValue("cc"),
104-
Status: db.SessionStatus(r.FormValue("status")),
105-
Limit: perPage,
106-
Offset: offset,
103+
Cc: r.FormValue("cc"),
104+
Status: db.SessionStatus(r.FormValue("status")),
105+
WithFindings: r.FormValue("with_findings") != "",
106+
Limit: perPage,
107+
Offset: offset,
107108
},
108109
// If the filters are changed, the old offset value is irrelevant.
109110
FilterFormURL: urlutil.DropParam(baseURL, "offset", ""),

syz-cluster/dashboard/templates/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
{{end}}
1616
</select>
1717
</div>
18+
<div class="form-check col-auto">
19+
<input class="form-check-input" type="checkbox" name="with_findings" value="true"
20+
id="onlyWithFindings"{{if .Filter.WithFindings}} checked=""{{end}}>
21+
<label class="form-check-label" for="onlyWithFindings">
22+
Only with findings
23+
</label>
24+
</div>
1825
<div class="col-auto">
1926
<button type="submit" class="btn btn-primary">Submit</button>
2027
</div>

syz-cluster/pkg/db/series_repo.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ type SeriesWithSession struct {
133133
}
134134

135135
type SeriesFilter struct {
136-
Cc string
137-
Status SessionStatus
138-
Limit int
139-
Offset int
136+
Cc string
137+
Status SessionStatus
138+
WithFindings bool
139+
Limit int
140+
Offset int
140141
}
141142

142143
// 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
174175
}
175176
stmt.SQL += ")"
176177
}
178+
if filter.WithFindings {
179+
stmt.SQL += " AND Series.LatestSessionID IS NOT NULL " +
180+
"AND EXISTS(SELECT 1 FROM Findings WHERE Findings.SessionID = Series.LatestSessionID)"
181+
}
177182
stmt.SQL += " ORDER BY PublishedAt DESC, ID"
178183
if filter.Limit > 0 {
179184
stmt.SQL += " LIMIT @limit"

syz-cluster/pkg/db/series_repo_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ func TestSeriesRepositoryList(t *testing.T) {
153153
assert.Len(t, list, 1)
154154
assert.Equal(t, 1, list[0].Findings, "there must be just one finding")
155155
})
156+
157+
t.Run("query_with_findings", func(t *testing.T) {
158+
list, err := repo.ListLatest(ctx, SeriesFilter{WithFindings: true}, time.Time{})
159+
assert.NoError(t, err)
160+
assert.Len(t, list, 1)
161+
assert.Equal(t, "Series 2", list[0].Series.Title)
162+
})
156163
}
157164

158165
func TestSeriesRepositoryUpdate(t *testing.T) {

0 commit comments

Comments
 (0)