mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-12-06 07:34:00 +00:00
The vulnerability table lists the other ids of a finding. The expanded row links to the bypass form for the id and for each alias.
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
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>): 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')
|
|
})
|
|
})
|