33 lines
2.0 KiB
TypeScript
33 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { correlateReportResults } from '../../src/domain/report-correlation';
|
|
import type { UnifiedResultProjection } from '../../src/domain/unified-result';
|
|
|
|
function finding(id: string, tool: string, domain: string, refs: string[]): UnifiedResultProjection {
|
|
return {
|
|
resultProjectionId: id, sourceTool: tool, title: domain, isDeviation: true,
|
|
outcomeNormalized: 'fail', frameworkReferences: refs.map(value => ({ namespace: tool, value }))
|
|
} as unknown as UnifiedResultProjection;
|
|
}
|
|
|
|
describe('report correlation without fuzzy matching', () => {
|
|
it('distinguishes shared references from domain-only proximity and does not invent a score', () => {
|
|
const results = [finding('a', 'alpha', 'identity', ['T1110']), finding('b', 'beta', 'identity', ['T1110']),
|
|
finding('c', 'gamma', 'hardening', ['T1234'])];
|
|
const output = correlateReportResults(results, [{ id: 'identity', label: 'Identity' }, { id: 'hardening', label: 'Hardening' }],
|
|
result => result.title, [{ id: 'p1', verdict: 'Fail', conflict: false, duplicate: false,
|
|
title: 'Dummy policy', scope: 'computer', identity: 'dummy', backupInstanceIds: ['backup-1'] },
|
|
{ id: 'p2', verdict: 'Fail', conflict: true, duplicate: false,
|
|
title: 'Conflicting policy', scope: 'computer', identity: 'other', backupInstanceIds: ['backup-2'] }]);
|
|
expect(output.convergence.find(item => item.domainId === 'identity')).toMatchObject({
|
|
sourceCount: 2, evidence: 'shared-framework-reference'
|
|
});
|
|
expect(output.convergence.find(item => item.domainId === 'hardening')).toMatchObject({
|
|
sourceCount: 1, evidence: 'domain-only'
|
|
});
|
|
expect(output.bundles).toEqual([{ key: 'T1110', namespace: 'alpha, beta', members: ['a', 'b'],
|
|
toolIds: ['alpha', 'beta'], domainIds: ['identity'] }]);
|
|
expect(output.singleSourcePolicyActions).toEqual([{ policyEntryId: 'p1', backupInstanceId: 'backup-1' }]);
|
|
expect(JSON.stringify(output)).not.toMatch(/score|rank|quickwin/i);
|
|
});
|
|
});
|