feat(vulnerable): filter vulnerable packages by severity

The four severity tiles on the vulnerable packages page are now toggle
buttons with aria-pressed. Each tile shows "Filter on" while active.
A tile selects packages with at least one vulnerability of that
severity. Several tiles combine with OR. A second click clears the
tile, and a Clear filters control clears all of them.

The selection lives in the URL (?severity=critical,high), so it
survives a reload and works as a link. An empty result shows the
library empty state with a clear action.

GET /api/packages accepts a severity list. The page uses it to load
only vulnerable packages instead of the whole cache. The filter is a
subquery on the latest scan result, so the statement count does not
grow with the number of rows. An unknown severity returns 400.
This commit is contained in:
2026-11-23 14:54:44 +00:00
parent 4d31e535ff
commit bd9d686383
12 changed files with 652 additions and 24 deletions
+17 -3
View File
@@ -332,11 +332,25 @@ type GroupListOptions struct {
Registry string // empty = every registry
Query string // case-insensitive substring of name, version or release version
SortBy string // one of the GroupSort* keys; empty = name
SortDesc bool
Page int // 1-based
PageSize int // 0 = every group, unpaginated
// Severities keeps rows whose latest scan holds a vulnerability of any listed
// severity (SeverityCritical and the like); empty = no severity filter.
Severities []string
Page int // 1-based
PageSize int // 0 = every group, unpaginated
SortDesc bool
}
// Severity filter values of GroupListOptions.
const (
SeverityCritical = "critical"
SeverityHigh = "high"
SeverityModerate = "moderate"
SeverityLow = "low"
)
// Severities lists the severity filter values, most severe first.
var Severities = []string{SeverityCritical, SeverityHigh, SeverityModerate, SeverityLow}
// GroupPage is one page of groups, flattened to rows.
type GroupPage struct {
// Packages holds every version row of each group on the page, in group