34 lines
2.4 KiB
TypeScript
34 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { ImportedDataset } from '../../src/domain/dataset';
|
|
import type { UnifiedResultProjection } from '../../src/domain/unified-result';
|
|
import { makeSheet } from '../../src/importers/sheet-factory';
|
|
import { securityDomainCatalog, securityDomainIdForRecord } from '../../src/evaluation/security-domains';
|
|
import { clientReportInput } from '../../src/reporting/client-report-projection';
|
|
|
|
// Synthetic data only. The report must assign each check the same domain as Work (one classifier, user decision 2026-10-04).
|
|
describe('shared report security-domain assignment', () => {
|
|
it('uses the Work Raw Data record of every scanner and GPO result and lists only the six domains', () => {
|
|
const sheet = makeSheet('Synthetic · All Records', [
|
|
['Title', 'Status', 'Category', 'Source Rule ID', 'Scope', 'Technical Identity', 'Policy type', 'Policy section', 'Source: Scan'],
|
|
['Audit on DCs', 'Matched', 'Anomalies', 'A-AuditDC', '', '', '', '', 'PingCastle · synthetic'],
|
|
['Synthetic user right', 'Fail', 'GPOs', '', 'computer', 'gpo-policy-identity-synthetic', 'security-template', 'Privilege Rights', 'GPOs · synthetic']
|
|
], '', 'synthetic', { isProjectSheet: true });
|
|
const [scanner, policy] = sheet.analysis.records;
|
|
scanner.findingOccurrenceId = 'occurrence-synthetic-1';
|
|
const results = [
|
|
{ resultProjectionId: 'r1', sourceKind: 'scanner-finding', sourceResultId: 'occurrence-synthetic-1', sourceTool: 'pingcastle', categories: [] },
|
|
{ resultProjectionId: 'r2', sourceKind: 'policy-evaluation', sourceResultId: 'eval-1', sourceTool: 'GPOs', categories: [],
|
|
policyScope: 'computer', policyIdentityKey: 'gpo-policy-identity-synthetic' }
|
|
] as unknown as UnifiedResultProjection[];
|
|
const input = clientReportInput({
|
|
project: { id: 'project-synthetic', name: 'Synthetic' } as never, generatedAt: '2026-10-04T00:00:00.000Z',
|
|
results, dataset: { sheets: [sheet] } as unknown as ImportedDataset
|
|
});
|
|
expect(input.domains.map(domain => domain.id)).toEqual(securityDomainCatalog.map(domain => domain.id));
|
|
expect(input.domainOf(results[0])).toBe(securityDomainIdForRecord(scanner));
|
|
expect(input.domainOf(results[0])).toBe('recovery');
|
|
expect(input.domainOf(results[1])).toBe(securityDomainIdForRecord(policy));
|
|
expect(input.domainOf(results[1])).toBe('privilege');
|
|
});
|
|
});
|