diff --git a/frontend/src/components/BypassManagementPanel.vue b/frontend/src/components/BypassManagementPanel.vue index e8079c6..0f8323a 100644 --- a/frontend/src/components/BypassManagementPanel.vue +++ b/frontend/src/components/BypassManagementPanel.vue @@ -91,7 +91,7 @@ :label="bypassForm.type === 'cve' ? 'CVE ID' : 'Package'" :hint=" bypassForm.type === 'cve' - ? 'Enter the CVE ID, for example CVE-2021-23337.' + ? 'Enter a CVE or GHSA id, for example CVE-2021-23337. It also covers findings that carry it as an alias.' : 'Enter a package, for example npm/lodash@4.17.20, or npm/lodash for all versions. PyPI packages use the release version, for example pypi/six@1.17.0.' " required diff --git a/frontend/src/components/parts/VulnerabilityTable.spec.ts b/frontend/src/components/parts/VulnerabilityTable.spec.ts new file mode 100644 index 0000000..6668850 --- /dev/null +++ b/frontend/src/components/parts/VulnerabilityTable.spec.ts @@ -0,0 +1,50 @@ +import { afterEach, describe, expect, it } from 'vitest' +import VulnerabilityTable from './VulnerabilityTable.vue' +import { mountStrict } from '@/test/mountStrict' +import { createTestRouter } from '@/test/router' +import type { VulnerabilityEntry } from '@/lib/report' + +let restore: (() => void) | undefined +afterEach(() => { + restore?.() + restore = undefined +}) + +const entry = (over: Partial): VulnerabilityEntry => ({ + id: 'GHSA-xvch-5gv4-984h', + severity: 'critical', + title: 'Prototype pollution', + description: '', + references: [], + fixed_in: '1.2.6', + bypassed: false, + ...over, +}) + +async function open(vulnerabilities: VulnerabilityEntry[]) { + const router = await createTestRouter('/') + const mounted = await mountStrict(VulnerabilityTable, { props: { vulnerabilities }, global: { plugins: [router] } }) + restore = mounted.restore + return mounted.wrapper +} + +describe('VulnerabilityTable aliases', () => { + it('names the other ids of a finding next to its advisory id', async () => { + const w = await open([entry({ aliases: ['CVE-2021-44906'] })]) + expect(w.text()).toContain('GHSA-xvch-5gv4-984h') + expect(w.text()).toContain('Also CVE-2021-44906') + }) + + it('shows no alias line for an older finding without aliases', async () => { + const w = await open([entry({})]) + expect(w.text()).not.toContain('Also ') + }) + + it('offers a bypass link for the id and for each alias', async () => { + const w = await open([entry({ aliases: ['CVE-2021-44906'] })]) + await w.find('tbody tr').trigger('click') + const hrefs = w.findAll('a').map((a) => a.attributes('href') ?? '') + expect(hrefs).toContain('/admin/bypasses?type=cve&target=GHSA-xvch-5gv4-984h') + expect(hrefs).toContain('/admin/bypasses?type=cve&target=CVE-2021-44906') + }) +}) diff --git a/frontend/src/components/parts/VulnerabilityTable.vue b/frontend/src/components/parts/VulnerabilityTable.vue index 7469447..0d1ee22 100644 --- a/frontend/src/components/parts/VulnerabilityTable.vue +++ b/frontend/src/components/parts/VulnerabilityTable.vue @@ -19,7 +19,12 @@ - {{ vuln.id }} + + {{ vuln.id }} + + Also {{ vuln.aliases.join(', ') }} + +

{{ vuln.title || vuln.description }}

@@ -59,6 +64,16 @@ Upgrade to {{ withVersionPrefix(vuln.fixed_in) }} or later. +
+

Bypass this advisory

+

A bypass for any of these ids covers this finding.

+
    +
  • + {{ id }} +
  • +
+
+

References ({{ vuln.references.length }})

    @@ -77,6 +92,7 @@