Assessor_2.0/tests/fixtures/client-info-facts.ts

49 lines
3.1 KiB
TypeScript

import type { EnvironmentSnapshot, EnvironmentObservation, ScannerReportSection } from '../../src/domain/environment-context';
import { makeSheet } from '../../src/importers/sheet-factory';
import { genericProfile } from '../../src/profiles/generic/generic-profile';
const tool = { id: 'synthetic', name: 'Synthetic scanner' };
const observation = (property: string, value: string | number): EnvironmentObservation => ({
version: 1, id: property, scanRunId: 'synthetic-run', importFileId: 'synthetic-file', tool,
subject: { type: 'directory' }, property, label: property, originalValue: value, normalizedValue: value,
valueType: typeof value === 'number' ? 'number' : 'string', state: 'observed',
source: { rowIndex: 0 }, mappingVersion: '1', attributes: {}
});
const section = (sectionKey: string, name: string, headers: string[], rows: (string | number)[][]): ScannerReportSection => ({
version: 1, id: sectionKey, scanRunId: 'synthetic-run', importFileId: 'synthetic-file', tool,
sectionKey, label: name, ordinal: 0, state: 'observed', tables: [{ name, headers, rows }],
source: { rowIndex: 0 }, extractorVersion: '1', attributes: {}
});
export const clientFactsSnapshot: EnvironmentSnapshot = {
version: 1, projectId: 'synthetic-project', scanRunIds: ['synthetic-run'], generatedAt: '2026-01-15T00:00:00Z',
coverage: { observed: 11, explicitlyAbsent: 0, empty: 0, restricted: 0, incomplete: 0 },
observations: [
observation('domain.fqdn', 'contoso.example'), observation('forest.name', 'contoso.example'),
observation('domain.netbios_name', 'CONTOSO'), observation('domain.count', 1),
observation('domain.controller_count', 2), observation('domain.functional_level', 'Windows Server 2016'),
observation('forest.functional_level', 'Windows Server 2016'), observation('forest.schema_version', '87'),
observation('domain.created_at', '2020-01-15'), observation('entra.tenant_name', 'Synthetic tenant'),
observation('host.name', 'Synthetic host')
],
sections: [
section('sectionDomainInformation', 'Directory evidence', ['Domain', 'Forest'], [['contoso.example', 'contoso.example']]),
section('sectionUserInformation', 'Account analysis', ['Nb User Accounts', 'Nb Enabled', 'Nb Disabled', 'Nb pwd never Expire'], [[16, 15, 1, 5]]),
section('sectionComputerInformation', 'Computer analysis', ['Nb Computer Accounts'], [[24]])
]
};
export function clientFactsState() {
const sheet = makeSheet('Synthetic layout', [
['Name', 'Status', 'Severity', 'Source: Scan'], ['Synthetic finding', 'Failed', 'High', 'Scanner A']
], '', 'synthetic.csv', { isProjectSheet: true });
return {
dataset: { fileName: 'Synthetic layout', sheets: [sheet], scanTool: 'Generic' },
activeSheet: sheet, activeProfile: genericProfile, reviews: {}, facetFilters: {},
targetProjectId: 'synthetic-project', activeScanRunIds: ['synthetic-run'], activeAssessmentIds: ['synthetic-assessment'],
backendStatus: 'unavailable', projects: [], assessments: [], selectedProject: null,
setStatusFilter() {}, setFacetFilter() {}, setPathFindingIds() {}, resetFilters() {},
setView() {}, setActionOnly() {}, setActiveSheet() {}
};
}