mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
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:
@@ -95,11 +95,15 @@ export const usePackageStore = defineStore('packages', () => {
|
||||
}
|
||||
let pageRequest = 0
|
||||
|
||||
/** Every package, unpaginated. Only views that filter on scan results need it. */
|
||||
async function fetchPackages() {
|
||||
/**
|
||||
* Every package, unpaginated. Only views that filter on scan results need it.
|
||||
* `severity` keeps the packages whose latest scan has a vulnerability of any listed severity.
|
||||
*/
|
||||
async function fetchPackages(options: { severity?: readonly string[] } = {}) {
|
||||
begin()
|
||||
try {
|
||||
const response = await axios.get('/api/packages')
|
||||
const query = options.severity?.length ? `?severity=${options.severity.join(',')}` : ''
|
||||
const response = await axios.get(`/api/packages${query}`)
|
||||
// Only update packages if we got valid data
|
||||
if (response.data && Array.isArray(response.data.packages)) {
|
||||
packages.value = response.data.packages
|
||||
|
||||
Reference in New Issue
Block a user