@slicedearth/whoisleuth-cli 1.47.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -177
- package/SECURITY.md +6 -3
- package/bin/whoisleuth.mjs +2 -1
- package/cli/archive-inspect.mjs +28 -10
- package/cli/arguments.mjs +204 -174
- package/cli/artifact-structure.mjs +837 -163
- package/cli/artifact-verify.mjs +90 -61
- package/cli/bounded-json.mjs +1 -1
- package/cli/bulk-checkpoint.mjs +33 -20
- package/cli/bulk.mjs +9 -2
- package/cli/case-pack.mjs +180 -576
- package/cli/ci-report.mjs +6 -1
- package/cli/collection-preflight.mjs +2 -2
- package/cli/command-catalogue.mjs +12 -3
- package/cli/command-reference.mjs +910 -92
- package/cli/completion.mjs +504 -226
- package/cli/config-profile.mjs +13 -3
- package/cli/discover.mjs +7 -1
- package/cli/discovery-observation-snapshot.mjs +24 -28
- package/cli/discovery-scan-command-runner.mjs +9 -9
- package/cli/discovery-scan.mjs +17 -3
- package/cli/discovery-snapshot.mjs +15 -7
- package/cli/domain-control-monitor.mjs +203 -30
- package/cli/domain-control-observations.mjs +15 -21
- package/cli/errors.mjs +8 -3
- package/cli/evidence-signing.mjs +10 -20
- package/cli/external-observation-mapping.mjs +3 -3
- package/cli/formatters/json.mjs +20 -32
- package/cli/formatters/terminal.mjs +583 -22
- package/cli/input.mjs +7 -2
- package/cli/interactive-launcher.mjs +226 -0
- package/cli/interchange-report.mjs +19 -19
- package/cli/investigation-manifest.mjs +1 -1
- package/cli/investigation-plan.mjs +167 -16
- package/cli/investigation-run.mjs +9 -1
- package/cli/lookalike-calibration.mjs +3 -1
- package/cli/lookup-brief.mjs +13 -8
- package/cli/lookup-browser.mjs +844 -0
- package/cli/lookup-command-runner.mjs +94 -31
- package/cli/lookup-diff.mjs +2 -2
- package/cli/lookup-plan.mjs +1 -0
- package/cli/mail-review.mjs +206 -94
- package/cli/manual.mjs +5 -5
- package/cli/offline-evidence-review.mjs +18 -7
- package/cli/open-asset-model-bridge.mjs +1 -1
- package/cli/output-file.mjs +70 -14
- package/cli/page-compare.mjs +11 -6
- package/cli/progress-events.mjs +2 -1
- package/cli/progress.mjs +3 -3
- package/cli/registry-cohort.mjs +9 -51
- package/cli/registry-doctor.mjs +67 -28
- package/cli/retained-artifact-diff.mjs +7 -8
- package/cli/risk-calibration.mjs +85 -38
- package/cli/runner.mjs +189 -75
- package/cli/saved-lookup.mjs +424 -57
- package/cli/sharing-review.mjs +6 -1
- package/cli/source-reliability.mjs +75 -36
- package/cli/terminal-presentation.mjs +43 -18
- package/docs/cli-reference.md +125 -1708
- package/docs/cli.md +86 -254
- package/frontend/src/lib/analysis/domain-control-manifest-core.js +3 -145
- package/frontend/src/lib/analysis/domain-control-records.js +3 -88
- package/lib/availability.mjs +58 -40
- package/lib/bounded-contract-normalizers.mjs +2 -4
- package/lib/bounded-file.mjs +78 -4
- package/lib/bounded-json.mjs +51 -13
- package/lib/browser-library-profile.mjs +1 -1
- package/lib/classify.mjs +56 -5
- package/lib/client-behavior-profile.mjs +1 -1
- package/lib/credential-surface-profile.mjs +1 -1
- package/lib/cryptographic-assurance.mjs +35 -17
- package/lib/ct-query.mjs +3 -3
- package/lib/ct-search.mjs +37 -21
- package/lib/distributed-operation-budget.mjs +4 -2
- package/lib/dns-delegation-health.mjs +9 -6
- package/lib/dns-intelligence.mjs +1 -1
- package/lib/dnssec-chain-validation.mjs +2 -3
- package/lib/dnssec-evidence-validation.mjs +13 -7
- package/lib/domain-assurance.mjs +12 -12
- package/lib/domain-change-packet.mjs +1 -1
- package/lib/domain-control-flight-recorder.mjs +442 -78
- package/lib/domain-control-manifest.mjs +314 -59
- package/lib/domain-posture-analysis.mjs +5 -2
- package/lib/encrypted-dns-contract.mjs +2 -3
- package/lib/evidence-export.mjs +518 -36
- package/lib/external-intelligence-risk.mjs +26 -10
- package/lib/feature-policy.mjs +1 -1
- package/lib/homepage-metadata-contract.mjs +290 -0
- package/lib/hostname.mjs +1 -1
- package/lib/html-signals.mjs +89 -5
- package/lib/http-intelligence.mjs +331 -2
- package/lib/interchange-fidelity-registry.mjs +28 -26
- package/lib/lookup-cache.mjs +6 -4
- package/lib/lookup.mjs +25 -2
- package/lib/observed-network-context.mjs +1 -1
- package/lib/page-fingerprints.mjs +2 -2
- package/lib/page-role-profile.mjs +1 -1
- package/lib/portable-generator.mjs +8 -0
- package/lib/provider-policy-admission.mjs +3 -1
- package/lib/rdap-bootstrap.mjs +76 -16
- package/lib/rdap-client.mjs +20 -12
- package/lib/rdap-normalization.mjs +306 -75
- package/lib/rdap-transport.mjs +2 -2
- package/lib/rdap-validation.mjs +65 -14
- package/lib/rdap.mjs +2 -2
- package/lib/registrable-domain.mjs +36 -0
- package/lib/registry-insights.mjs +7 -0
- package/lib/response-policy.mjs +27 -4
- package/lib/risk-calibration-summary.mjs +35 -33
- package/lib/risk-scoring.mjs +4 -3
- package/lib/safe-fetch.mjs +62 -40
- package/lib/security-txt.mjs +1 -1
- package/lib/smtp-transport-review.mjs +8 -5
- package/lib/sslbl-intelligence.mjs +6 -8
- package/lib/static-html-analysis.mjs +301 -4
- package/lib/structured-data-identity.mjs +51 -19
- package/lib/threat-intelligence-fixtures.mjs +2 -4
- package/lib/threat-intelligence-manifests.mjs +2 -7
- package/lib/threat-intelligence-runtime.mjs +3 -5
- package/lib/threat-intelligence-types.mjs +3 -0
- package/lib/threatfox-intelligence.mjs +7 -3
- package/lib/tls-intelligence.mjs +4 -4
- package/lib/urlhaus-intelligence.mjs +4 -2
- package/lib/urlscan-intelligence.mjs +6 -5
- package/lib/website-security-posture.mjs +1 -1
- package/lib/website-technology.mjs +1 -1
- package/lib/whois-authority.mjs +43 -8
- package/lib/whois-chain.mjs +25 -3
- package/lib/whois-normalization.mjs +3 -1
- package/lib/whois-transport.mjs +12 -3
- package/lib/zone-intent-review.mjs +1 -1
- package/package.json +12 -4
- package/{frontend/src/lib/analysis/case-brand-profile-references.js → packages/cases/case-brand-profile-references.mjs} +2 -2
- package/{frontend/src/lib/analysis/case-evidence-model.js → packages/cases/case-evidence-model.mjs} +35 -14
- package/{frontend/src/lib/analysis/case-investigation-branch-model.js → packages/cases/case-investigation-branch-model.mjs} +10 -12
- package/packages/cases/case-migration-model.mjs +476 -0
- package/{frontend/src/lib/analysis/case-model.js → packages/cases/case-model.mjs} +3 -3
- package/{frontend/src/lib/analysis/case-record-contracts.js → packages/cases/case-record-contracts.mjs} +3 -21
- package/{frontend/src/lib/analysis/case-record-core.js → packages/cases/case-record-core.mjs} +58 -31
- package/packages/cases/case-record-model.mjs +9 -0
- package/{frontend/src/lib/analysis/case-record-operations.js → packages/cases/case-record-operations.mjs} +72 -29
- package/{frontend/src/lib/analysis/case-report.js → packages/cases/case-report.mjs} +108 -14
- package/packages/cases/case-response-model.mjs +1604 -0
- package/packages/cases/case-response-packet.mjs +1312 -0
- package/{frontend/src/lib/analysis/case-storage-model.js → packages/cases/case-storage-model.mjs} +2 -2
- package/{frontend/src/lib/analysis/http-summary.js → packages/cases/http-summary.mjs} +1 -1
- package/{frontend/src/lib/analysis/comparison-ledger-bulk.js → packages/comparison/comparison-ledger-bulk.mjs} +2 -2
- package/{frontend/src/lib/analysis/comparison-ledger-contract.js → packages/comparison/comparison-ledger-contract.mjs} +4 -4
- package/{frontend/src/lib/analysis/comparison-ledger-json.js → packages/comparison/comparison-ledger-json.mjs} +1 -0
- package/{frontend/src/lib/analysis/comparison-ledger-serialization.js → packages/comparison/comparison-ledger-serialization.mjs} +1 -0
- package/packages/comparison/favicon-similarity.mjs +78 -0
- package/{frontend/src/lib/analysis/page-similarity.js → packages/comparison/page-similarity.mjs} +4 -3
- package/{frontend/src/lib/analysis/relationship-evidence.js → packages/comparison/relationship-evidence.mjs} +6 -7
- package/packages/contracts/analyst-review-state-contract.mjs +61 -0
- package/packages/contracts/analyst-review-state.mjs +50 -0
- package/packages/contracts/case-portability.mjs +1310 -0
- package/packages/contracts/cli-command-catalogue.mjs +2 -0
- package/packages/contracts/cli-lookup.mjs +394 -0
- package/packages/contracts/domain-control-flight-recorder.mjs +461 -0
- package/packages/contracts/domain-control-manifest.mjs +1027 -0
- package/packages/contracts/domain-control-monitor.mjs +310 -0
- package/packages/contracts/domain-control-review.mjs +828 -0
- package/packages/contracts/domain-name.mjs +4 -0
- package/packages/contracts/external-observation-interchange.mjs +224 -0
- package/packages/contracts/extracted-domain-lifecycle.mjs +218 -0
- package/packages/contracts/investigation-portability.mjs +331 -0
- package/packages/contracts/offline-comparison.mjs +160 -0
- package/packages/contracts/risk-calibration.mjs +1288 -0
- package/packages/contracts/schema-compatibility.mjs +71 -0
- package/packages/contracts/schema-lifecycle.mjs +1702 -0
- package/packages/contracts/sslbl-snapshot.mjs +17 -0
- package/packages/contracts/workspace-portability.mjs +1347 -0
- package/{frontend/src/lib/analysis/artifact-integrity.js → packages/evidence/artifact-integrity.mjs} +13 -11
- package/packages/evidence/decision-fact.mjs +735 -0
- package/packages/evidence/domain-control-runtime.mjs +547 -0
- package/packages/evidence/domain-name.mjs +41 -0
- package/packages/evidence/observation.mjs +384 -0
- package/{frontend/src/lib/analysis/external-findings-import.js → packages/interchange/external-findings-import.mjs} +24 -22
- package/packages/interchange/retained-text.mjs +8 -0
- package/{frontend/src/lib/analysis/acquisition-decision-packet.js → packages/investigation/acquisition-decision-packet.mjs} +9 -6
- package/{frontend/src/lib/analysis/bulk-domain-comparison.js → packages/investigation/bulk-domain-comparison.mjs} +5 -6
- package/{frontend/src/lib/analysis/bulk-mail-exposure.js → packages/investigation/bulk-mail-exposure.mjs} +4 -6
- package/{frontend/src/lib/analysis/bulk-review-export.js → packages/investigation/bulk-review-export.mjs} +5 -5
- package/packages/investigation/bulk-review-policy.mjs +1 -0
- package/{frontend/src/lib/analysis/investigation-capsule.js → packages/investigation/investigation-capsule.mjs} +30 -32
- package/packages/investigation/lookup-artefact-inputs.mjs +1 -0
- package/{frontend/src/lib/analysis/lookup-asset-graph.js → packages/investigation/lookup-asset-graph.mjs} +4 -2
- package/{frontend/src/lib/analysis/lookup-claim-passport.js → packages/investigation/lookup-claim-passport.mjs} +6 -10
- package/{frontend/src/lib/analysis/lookup-claim-readiness.js → packages/investigation/lookup-claim-readiness.mjs} +9 -2
- package/packages/investigation/lookup-investigation-brief.mjs +172 -0
- package/packages/monitoring/analyst-review-state.mjs +680 -0
- package/{frontend/src/lib/analysis/brand-profile-model.js → packages/workspace/brand-profile-model.mjs} +70 -47
- package/{frontend/src/lib/analysis/bulk-review-model.js → packages/workspace/bulk-review-model.mjs} +13 -14
- package/{frontend/src/lib/analysis/bulk-session-model.js → packages/workspace/bulk-session-model.mjs} +33 -59
- package/{frontend/src/lib/analysis/bulk-sort.js → packages/workspace/bulk-sort.mjs} +8 -5
- package/{frontend/src/lib/analysis/campaign-model.js → packages/workspace/campaign-model.mjs} +20 -22
- package/{frontend/src/lib/analysis/detection-rule-model.js → packages/workspace/detection-rule-model.mjs} +15 -17
- package/packages/workspace/hostile-input.mjs +172 -0
- package/{frontend/src/lib/analysis/investigation-guide.js → packages/workspace/investigation-guide.mjs} +8 -45
- package/{frontend/src/lib/analysis/investigation-template-model.js → packages/workspace/investigation-template-model.mjs} +18 -21
- package/{frontend/src/lib/analysis/page-baseline.js → packages/workspace/page-baseline.mjs} +6 -13
- package/{frontend/src/lib/analysis/relationship-observation-model.js → packages/workspace/relationship-observation-model.mjs} +13 -17
- package/{frontend/src/lib/analysis/shortlist-model.js → packages/workspace/shortlist-model.mjs} +20 -18
- package/{frontend/src/lib/analysis/watchlist-history.js → packages/workspace/watchlist-history.mjs} +9 -16
- package/{frontend/src/lib/analysis/watchlist-store.js → packages/workspace/watchlist-store.mjs} +24 -17
- package/{frontend/src/lib/analysis/website-snapshot-model.js → packages/workspace/website-snapshot-model.mjs} +13 -13
- package/{frontend/src/lib/analysis/workspace-archive-crypto.js → packages/workspace/workspace-archive-crypto.mjs} +49 -19
- package/{frontend/src/lib/analysis/workspace-archive.js → packages/workspace/workspace-archive.mjs} +110 -89
- package/third-party-notices.txt +14 -14
- package/frontend/src/lib/analysis/bulk-retry-plan.js +0 -79
- package/frontend/src/lib/analysis/bulk-source-coverage.js +0 -76
- package/frontend/src/lib/analysis/case-migration-model.js +0 -305
- package/frontend/src/lib/analysis/case-record-model.js +0 -9
- package/frontend/src/lib/analysis/case-response-model.js +0 -728
- package/frontend/src/lib/analysis/case-response-packet.js +0 -583
- package/frontend/src/lib/analysis/lookup-decision-support.js +0 -542
- package/frontend/src/lib/analysis/lookup-investigation-brief.js +0 -153
- package/frontend/src/lib/analysis/lookup-presentation.js +0 -120
- package/frontend/src/lib/analysis/lookup-response.js +0 -2
- package/frontend/src/lib/analysis/lookup-source-refresh.js +0 -277
- package/frontend/src/lib/analysis/lookup-summary-model.js +0 -398
- package/frontend/src/lib/analysis/scoring.js +0 -55
- package/frontend/src/lib/analysis/utils.js +0 -255
- package/frontend/src/lib/analysis/visualization-bounds.js +0 -26
- package/frontend/src/lib/analysis/visualization-force-graph.js +0 -352
- package/frontend/src/lib/analysis/visualization-matrix.js +0 -131
- package/frontend/src/lib/analysis/visualization-models.js +0 -338
- package/frontend/src/lib/analysis/visualization-time-series.js +0 -185
- package/lib/bounded-json-response.mjs +0 -170
- package/lib/lookup-response-contract.mjs +0 -1034
- package/lib/observation.mjs +0 -115
- /package/{frontend/src/lib/analysis/opaque-reference-id.js → packages/cases/opaque-reference-id.mjs} +0 -0
- /package/{frontend/src/lib/analysis/acquisition-due-diligence.js → packages/investigation/acquisition-due-diligence.mjs} +0 -0
- /package/{frontend/src/lib/analysis/evidence-coverage-ledger.js → packages/investigation/evidence-coverage-ledger.mjs} +0 -0
- /package/{frontend/src/lib/analysis/dns-record-normalization.js → packages/workspace/dns-record-normalization.mjs} +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { defineSchemaCompatibility } from "./schema-compatibility.mjs";
|
|
2
|
+
import { defineSchemaLifecycleFamily } from "./schema-lifecycle.mjs";
|
|
3
|
+
export const EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER = 'packages/contracts/external-observation-interchange.mts';
|
|
4
|
+
export const EXTERNAL_FINDINGS_SCHEMA = 'whoisleuth.external-findings';
|
|
5
|
+
export const EXTERNAL_FINDINGS_VERSION = 4;
|
|
6
|
+
export const SUPPORTED_EXTERNAL_FINDINGS_VERSIONS = Object.freeze([EXTERNAL_FINDINGS_VERSION]);
|
|
7
|
+
export const MAX_EXTERNAL_FINDINGS_IMPORT_BYTES = 384 * 1024;
|
|
8
|
+
export const MAX_EXTERNAL_FINDINGS = 100;
|
|
9
|
+
export const MAX_EXTERNAL_FINDINGS_PER_DOMAIN = 20;
|
|
10
|
+
export const MAX_EXTERNAL_FINDING_DOMAINS = 25;
|
|
11
|
+
export const EXTERNAL_FINDING_ROWS_SCHEMA = 'whoisleuth.external-finding-rows';
|
|
12
|
+
export const EXTERNAL_FINDING_ROWS_VERSION = 1;
|
|
13
|
+
export const DOMAIN_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.domain-observation-rows';
|
|
14
|
+
export const DNS_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.dns-observation-rows';
|
|
15
|
+
export const CERTIFICATE_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.certificate-observation-rows';
|
|
16
|
+
export const SUPPORTED_OBSERVATION_ROWS_VERSION = 1;
|
|
17
|
+
export const MAX_CONVERSION_INPUT_ROWS = MAX_EXTERNAL_FINDINGS * 4;
|
|
18
|
+
export const EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY_FACADES = Object.freeze([
|
|
19
|
+
['frontend/src/lib/analysis/external-findings-import.ts', 'packages/interchange/external-findings-import.mts'],
|
|
20
|
+
['frontend/src/lib/analysis/external-findings-converters.ts', 'packages/interchange/external-findings-converters.mts'],
|
|
21
|
+
]);
|
|
22
|
+
export const EXTERNAL_FINDINGS_COMPATIBILITY = defineSchemaCompatibility({
|
|
23
|
+
id: 'export.external-findings', kind: 'export', schema: EXTERNAL_FINDINGS_SCHEMA,
|
|
24
|
+
currentVersion: EXTERNAL_FINDINGS_VERSION, supportedVersions: SUPPORTED_EXTERNAL_FINDINGS_VERSIONS,
|
|
25
|
+
acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'exact_current_only', writeSemantics: 'non_destructive_merge',
|
|
26
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
27
|
+
note: 'Strict local findings import. Version 4 can retain bounded certificate event identity and name-completeness metadata while analyst assertions remain a separate case workflow.',
|
|
28
|
+
});
|
|
29
|
+
export const EXTERNAL_FINDING_ROWS_COMPATIBILITY = defineSchemaCompatibility({
|
|
30
|
+
id: 'import.external-finding-rows', kind: 'export', schema: EXTERNAL_FINDING_ROWS_SCHEMA,
|
|
31
|
+
currentVersion: EXTERNAL_FINDING_ROWS_VERSION, supportedVersions: [EXTERNAL_FINDING_ROWS_VERSION],
|
|
32
|
+
acceptsUnversionedLegacy: true, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
|
|
33
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
34
|
+
note: 'Bounded fixed-column JSON rows converted through the strict findings parser.',
|
|
35
|
+
});
|
|
36
|
+
export const DOMAIN_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
|
|
37
|
+
id: 'import.domain-observation-rows', kind: 'export', schema: DOMAIN_OBSERVATION_ROWS_SCHEMA,
|
|
38
|
+
currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
|
|
39
|
+
acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
|
|
40
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
41
|
+
note: 'Typed external domain-state observations retained with source-qualified provenance.',
|
|
42
|
+
});
|
|
43
|
+
export const DNS_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
|
|
44
|
+
id: 'import.dns-observation-rows', kind: 'export', schema: DNS_OBSERVATION_ROWS_SCHEMA,
|
|
45
|
+
currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
|
|
46
|
+
acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
|
|
47
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
48
|
+
note: 'Typed external DNS observations; only valid relational values project graph edges.',
|
|
49
|
+
});
|
|
50
|
+
export const CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
|
|
51
|
+
id: 'import.certificate-observation-rows', kind: 'export', schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA,
|
|
52
|
+
currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
|
|
53
|
+
acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
|
|
54
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
55
|
+
note: 'Typed external certificate observations requiring an exact SHA-256 fingerprint.',
|
|
56
|
+
});
|
|
57
|
+
export const EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY = Object.freeze([
|
|
58
|
+
EXTERNAL_FINDINGS_COMPATIBILITY,
|
|
59
|
+
EXTERNAL_FINDING_ROWS_COMPATIBILITY,
|
|
60
|
+
DOMAIN_OBSERVATION_ROWS_COMPATIBILITY,
|
|
61
|
+
DNS_OBSERVATION_ROWS_COMPATIBILITY,
|
|
62
|
+
CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY,
|
|
63
|
+
]);
|
|
64
|
+
const EXTERNAL_INTERCHANGE_FIXTURES = Object.freeze([
|
|
65
|
+
{ id: 'external-findings-v4', path: 'test/fixtures/external-observation-interchange/external-findings-v4.json', bytes: 634, sha256: 'ceab916e1dcf99704c94e1b0cd82f5a061f138ae6a07ce8335273080c73b7624', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
|
|
66
|
+
{ id: 'external-finding-rows-v1', path: 'test/fixtures/external-observation-interchange/external-finding-rows-v1.json', bytes: 435, sha256: '09048325d801fdc837134580fd887cacde28744c9f87a43afc388c96117a4659', schema: EXTERNAL_FINDING_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'external-finding-rows-v1-output' },
|
|
67
|
+
{ id: 'external-finding-rows-v1-output', path: 'test/fixtures/external-observation-interchange/external-finding-rows-v1-output.json', bytes: 581, sha256: '7f84a9f6177d3245acd6fc21275276694fbe9e8cd94922b1e6997a73afa3149a', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
|
|
68
|
+
{ id: 'domain-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/domain-observation-rows-v1.json', bytes: 390, sha256: '2f95ab21e57e1a6aaab03cea75a4d58fd9e1234ba87f5268a899b23103359474', schema: DOMAIN_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'domain-observation-rows-v1-output' },
|
|
69
|
+
{ id: 'domain-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/domain-observation-rows-v1-output.json', bytes: 1_027, sha256: 'bba949308e9bb5b58bf5611d6dec23f074979522627631948cffc2f0056ac817', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
|
|
70
|
+
{ id: 'dns-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/dns-observation-rows-v1.json', bytes: 369, sha256: 'afb1808a8a81339a1801d337259c19c77ed957583b4ae06579b38ea6a8f68ed1', schema: DNS_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'dns-observation-rows-v1-output' },
|
|
71
|
+
{ id: 'dns-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/dns-observation-rows-v1-output.json', bytes: 988, sha256: '4c9a49b96181d2907eb95319d15975758823994fe029c051486f1cb6869221a0', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
|
|
72
|
+
{ id: 'certificate-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/certificate-observation-rows-v1.json', bytes: 515, sha256: '68363a5fe074b08a386dbc95a0993a2933ebcf05ba2f96148df632842d1c5869', schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'certificate-observation-rows-v1-output' },
|
|
73
|
+
{ id: 'certificate-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/certificate-observation-rows-v1-output.json', bytes: 1_244, sha256: '6c484601b872f10bfdb7d9519d4b216f14ef277e7a429e4cc131154ad0e07652', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
|
|
74
|
+
].map((fixture) => Object.freeze({
|
|
75
|
+
...fixture,
|
|
76
|
+
contentDigestSha256: null,
|
|
77
|
+
scope: 'repository',
|
|
78
|
+
})));
|
|
79
|
+
function externalFixtureIds(schema, version) {
|
|
80
|
+
return Object.freeze(EXTERNAL_INTERCHANGE_FIXTURES
|
|
81
|
+
.filter((fixture) => fixture.schema === schema && fixture.version === version)
|
|
82
|
+
.map((fixture) => fixture.id));
|
|
83
|
+
}
|
|
84
|
+
const EXTERNAL_INTERCHANGE_CONTRACTS = Object.freeze([
|
|
85
|
+
...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS.map((version) => Object.freeze({
|
|
86
|
+
compatibilityId: EXTERNAL_FINDINGS_COMPATIBILITY.id,
|
|
87
|
+
schema: EXTERNAL_FINDINGS_SCHEMA,
|
|
88
|
+
version,
|
|
89
|
+
role: 'document',
|
|
90
|
+
lifecycle: version === EXTERNAL_FINDINGS_VERSION ? 'current' : 'legacy',
|
|
91
|
+
readable: true,
|
|
92
|
+
emitted: version === EXTERNAL_FINDINGS_VERSION,
|
|
93
|
+
exactKeys: true,
|
|
94
|
+
extensionPolicy: 'reject',
|
|
95
|
+
futureVersionBehaviour: 'reject',
|
|
96
|
+
migrationTarget: version === EXTERNAL_FINDINGS_VERSION ? null : { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
|
|
97
|
+
canonicalisation: null,
|
|
98
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES,
|
|
99
|
+
fixtureIds: externalFixtureIds(EXTERNAL_FINDINGS_SCHEMA, version),
|
|
100
|
+
})),
|
|
101
|
+
...[
|
|
102
|
+
[EXTERNAL_FINDING_ROWS_COMPATIBILITY.id, EXTERNAL_FINDING_ROWS_SCHEMA],
|
|
103
|
+
[DOMAIN_OBSERVATION_ROWS_COMPATIBILITY.id, DOMAIN_OBSERVATION_ROWS_SCHEMA],
|
|
104
|
+
[DNS_OBSERVATION_ROWS_COMPATIBILITY.id, DNS_OBSERVATION_ROWS_SCHEMA],
|
|
105
|
+
[CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY.id, CERTIFICATE_OBSERVATION_ROWS_SCHEMA],
|
|
106
|
+
].map(([compatibilityId, schema]) => Object.freeze({
|
|
107
|
+
compatibilityId,
|
|
108
|
+
schema,
|
|
109
|
+
version: 1,
|
|
110
|
+
role: 'input',
|
|
111
|
+
lifecycle: 'current',
|
|
112
|
+
readable: true,
|
|
113
|
+
emitted: false,
|
|
114
|
+
exactKeys: true,
|
|
115
|
+
extensionPolicy: 'reject',
|
|
116
|
+
futureVersionBehaviour: 'reject',
|
|
117
|
+
migrationTarget: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
|
|
118
|
+
canonicalisation: null,
|
|
119
|
+
byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES,
|
|
120
|
+
fixtureIds: externalFixtureIds(schema, 1),
|
|
121
|
+
})),
|
|
122
|
+
]);
|
|
123
|
+
function externalShape(id, schema, versions, requiredKeys, normalisation) {
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
id,
|
|
126
|
+
schema,
|
|
127
|
+
versions,
|
|
128
|
+
objects: [{ path: '$', requiredKeys, optionalKeys: [], unknownKeys: 'reject' }],
|
|
129
|
+
fixedArrays: [],
|
|
130
|
+
normalisation,
|
|
131
|
+
target: normalisation === 'input_to_current'
|
|
132
|
+
? { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION }
|
|
133
|
+
: null,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const externalConsumerCommon = Object.freeze({
|
|
137
|
+
expiryPolicyId: 'external-interchange.expiry.not-applicable',
|
|
138
|
+
requestMode: 'none',
|
|
139
|
+
bindingState: 'declared_unenforced',
|
|
140
|
+
policyState: 'current',
|
|
141
|
+
});
|
|
142
|
+
export const EXTERNAL_OBSERVATION_INTERCHANGE_LIFECYCLE_FAMILY = defineSchemaLifecycleFamily({
|
|
143
|
+
id: 'external-observation-interchange',
|
|
144
|
+
owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
|
|
145
|
+
privacy: 'analyst_authored_sensitive',
|
|
146
|
+
compatibility: EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY,
|
|
147
|
+
contracts: EXTERNAL_INTERCHANGE_CONTRACTS,
|
|
148
|
+
fixtures: EXTERNAL_INTERCHANGE_FIXTURES,
|
|
149
|
+
metadata: {
|
|
150
|
+
metadataVersion: 3,
|
|
151
|
+
enforcement: 'declarative_only',
|
|
152
|
+
shapes: [
|
|
153
|
+
externalShape('external-interchange.findings.v4', EXTERNAL_FINDINGS_SCHEMA, [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], ['schema', 'schemaVersion', 'source', 'findings'], 'preserve_document'),
|
|
154
|
+
externalShape('external-interchange.finding-rows.v1', EXTERNAL_FINDING_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'rows'], 'input_to_current'),
|
|
155
|
+
externalShape('external-interchange.domain-rows.v1', DOMAIN_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
|
|
156
|
+
externalShape('external-interchange.dns-rows.v1', DNS_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
|
|
157
|
+
externalShape('external-interchange.certificate-rows.v1', CERTIFICATE_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
|
|
158
|
+
],
|
|
159
|
+
boundProfiles: [{ id: 'external-interchange.document.bounds', bounds: [
|
|
160
|
+
{ id: 'raw-bytes', path: '$', phase: 'raw_intake', unit: 'bytes', minimum: 1, maximum: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, handling: 'reject' },
|
|
161
|
+
{ id: 'serialised-bytes', path: '$', phase: 'serialised', unit: 'bytes', minimum: 1, maximum: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, handling: 'reject' },
|
|
162
|
+
{ id: 'rows', path: '$', phase: 'pre_accumulation', unit: 'items', minimum: 1, maximum: MAX_CONVERSION_INPUT_ROWS, handling: 'reject' },
|
|
163
|
+
] }],
|
|
164
|
+
hooks: [
|
|
165
|
+
{ id: 'external-interchange.findings.normalise', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'parseExternalFindingsDocument' },
|
|
166
|
+
{ id: 'external-interchange.findings.serialise', role: 'serialiser', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'serializeExternalFindingsDocument' },
|
|
167
|
+
{ id: 'external-interchange.finding-rows.convert', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-converters.mts', exportName: 'convertExternalFindingRows' },
|
|
168
|
+
{ id: 'external-interchange.observation-rows.convert', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-converters.mts', exportName: 'convertSupportedExternalFindings' },
|
|
169
|
+
{ id: 'external-interchange.findings.merge', role: 'merger', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'mergeExternalFindingsIntoCases' },
|
|
170
|
+
],
|
|
171
|
+
serialisationProfiles: [{
|
|
172
|
+
id: 'external-interchange.findings.json.v4', schema: EXTERNAL_FINDINGS_SCHEMA,
|
|
173
|
+
versions: [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], mediaType: 'application/json', encoding: 'utf-8', bom: false,
|
|
174
|
+
indentSpaces: 2, terminalLf: true, propertyOrder: 'normalised_fixed', canonicalisation: null, integrity: 'none',
|
|
175
|
+
serializerHookId: 'external-interchange.findings.serialise', verifierHookIds: [],
|
|
176
|
+
}],
|
|
177
|
+
privacyProfiles: [
|
|
178
|
+
{ id: 'external-interchange.privacy.transient', classification: 'analyst_authored_sensitive', projection: 'browser_import', includedCategories: ['source-attribution', 'bounded-observations', 'completeness', 'limitations'], excludedCategories: ['raw-upstream-payloads', 'expanded-contacts', 'credentials', 'cookies', 'query-bearing-urls'], notePolicy: 'discarded', retention: 'transient_report', network: 'none', sharingReview: 'required' },
|
|
179
|
+
{ id: 'external-interchange.privacy.case-merge', classification: 'analyst_authored_sensitive', projection: 'browser_import', includedCategories: ['source-attribution', 'bounded-observations', 'completeness', 'limitations'], excludedCategories: ['raw-upstream-payloads', 'expanded-contacts', 'credentials', 'cookies', 'query-bearing-urls'], notePolicy: 'discarded', retention: 'browser_indexeddb', network: 'none', sharingReview: 'not_applicable' },
|
|
180
|
+
],
|
|
181
|
+
expiryProfiles: [{ id: 'external-interchange.expiry.not-applicable', field: null, anchor: null, handling: 'not_applicable', phase: 'not_applicable', maximumLifetimeDays: null }],
|
|
182
|
+
consumerEdges: [
|
|
183
|
+
{
|
|
184
|
+
id: 'external-interchange.consumer.findings-normalise', plane: 'shared', operation: 'normalise-strict-findings',
|
|
185
|
+
acceptedContracts: [{ schema: EXTERNAL_FINDINGS_SCHEMA, versions: [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], mode: 'direct' }],
|
|
186
|
+
emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
|
|
187
|
+
shapeIds: ['external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
|
|
188
|
+
hookIds: ['external-interchange.findings.normalise', 'external-interchange.findings.serialise'],
|
|
189
|
+
serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
|
|
190
|
+
retentionEffect: 'transient_report', ...externalConsumerCommon,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: 'external-interchange.consumer.finding-rows', plane: 'shared', operation: 'convert-finding-rows',
|
|
194
|
+
acceptedContracts: [{ schema: EXTERNAL_FINDING_ROWS_SCHEMA, versions: [1], mode: 'direct' }],
|
|
195
|
+
emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
|
|
196
|
+
shapeIds: ['external-interchange.finding-rows.v1', 'external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
|
|
197
|
+
hookIds: ['external-interchange.finding-rows.convert', 'external-interchange.findings.serialise'],
|
|
198
|
+
serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
|
|
199
|
+
retentionEffect: 'transient_report', ...externalConsumerCommon,
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'external-interchange.consumer.observation-rows', plane: 'shared', operation: 'convert-observation-rows',
|
|
203
|
+
acceptedContracts: [
|
|
204
|
+
{ schema: DOMAIN_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
|
|
205
|
+
{ schema: DNS_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
|
|
206
|
+
{ schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
|
|
207
|
+
],
|
|
208
|
+
emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
|
|
209
|
+
shapeIds: ['external-interchange.domain-rows.v1', 'external-interchange.dns-rows.v1', 'external-interchange.certificate-rows.v1', 'external-interchange.findings.v4'],
|
|
210
|
+
boundProfileIds: ['external-interchange.document.bounds'], hookIds: ['external-interchange.observation-rows.convert', 'external-interchange.findings.serialise'],
|
|
211
|
+
serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
|
|
212
|
+
retentionEffect: 'transient_report', ...externalConsumerCommon,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: 'external-interchange.consumer.case-merge', plane: 'shared', operation: 'non-destructive-case-merge',
|
|
216
|
+
acceptedContracts: [{ schema: EXTERNAL_FINDINGS_SCHEMA, versions: [EXTERNAL_FINDINGS_VERSION], mode: 'direct' }], emittedContract: null,
|
|
217
|
+
shapeIds: ['external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
|
|
218
|
+
hookIds: ['external-interchange.findings.merge'], serialisationProfileId: null,
|
|
219
|
+
privacyProfileId: 'external-interchange.privacy.case-merge', retentionEffect: 'browser_indexeddb', ...externalConsumerCommon,
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
consumerRelationships: [],
|
|
223
|
+
},
|
|
224
|
+
});
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
function formatSlug(id) {
|
|
2
|
+
return id.replaceAll('.', '-');
|
|
3
|
+
}
|
|
4
|
+
function lifecycleShapeId(format, version, v4) {
|
|
5
|
+
return v4
|
|
6
|
+
? `${formatSlug(format.descriptor.id)}.v${version}`
|
|
7
|
+
: `${formatSlug(format.descriptor.id)}.document`;
|
|
8
|
+
}
|
|
9
|
+
function contractState(format, version) {
|
|
10
|
+
const current = version === format.descriptor.currentVersion;
|
|
11
|
+
const outputOnly = format.descriptor.futureVersionBehavior === 'not_applicable';
|
|
12
|
+
return {
|
|
13
|
+
lifecycle: current ? 'current' : outputOnly ? 'retired' : 'legacy',
|
|
14
|
+
readable: !outputOnly,
|
|
15
|
+
emitted: current,
|
|
16
|
+
futureVersionBehaviour: outputOnly
|
|
17
|
+
? 'not_applicable'
|
|
18
|
+
: format.descriptor.futureVersionBehavior,
|
|
19
|
+
migrationTarget: !current && format.descriptor.migration === 'normalize_to_current'
|
|
20
|
+
? { schema: format.lifecycleSchema, version: format.descriptor.currentVersion }
|
|
21
|
+
: null,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function fixtureRecord(format, fixture, v4) {
|
|
25
|
+
const state = contractState(format, fixture.version);
|
|
26
|
+
const output = format.fixtures.find((candidate) => candidate.version === format.descriptor.currentVersion);
|
|
27
|
+
return {
|
|
28
|
+
...fixture,
|
|
29
|
+
contentDigestSha256: null,
|
|
30
|
+
schema: format.lifecycleSchema,
|
|
31
|
+
role: state.lifecycle === 'current' ? 'current' : 'historical',
|
|
32
|
+
expectation: state.lifecycle === 'retired'
|
|
33
|
+
? 'historical_output_exact'
|
|
34
|
+
: state.lifecycle === 'legacy' && format.descriptor.migration === 'normalize_to_current'
|
|
35
|
+
? 'normalises_to_current_output'
|
|
36
|
+
: 'accepted_exact',
|
|
37
|
+
expectedOutputFixtureId: state.lifecycle === 'legacy' && format.descriptor.migration === 'normalize_to_current'
|
|
38
|
+
? output?.id ?? null
|
|
39
|
+
: null,
|
|
40
|
+
scope: 'repository',
|
|
41
|
+
...(v4 ? { shapeId: lifecycleShapeId(format, fixture.version, true) } : {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function buildExtractedLifecycleFamily(options, metadataVersion) {
|
|
45
|
+
const v4 = metadataVersion === 4;
|
|
46
|
+
const fixtures = options.formats.flatMap((format) => format.fixtures.map((fixture) => (fixtureRecord(format, fixture, v4))));
|
|
47
|
+
const contracts = options.formats.flatMap((format) => format.descriptor.supportedVersions.map((version) => ({
|
|
48
|
+
compatibilityId: format.descriptor.id,
|
|
49
|
+
schema: format.lifecycleSchema,
|
|
50
|
+
version,
|
|
51
|
+
role: 'document',
|
|
52
|
+
...contractState(format, version),
|
|
53
|
+
exactKeys: true,
|
|
54
|
+
extensionPolicy: 'reject',
|
|
55
|
+
canonicalisation: null,
|
|
56
|
+
byteBudget: format.descriptor.byteBudget,
|
|
57
|
+
fixtureIds: fixtures
|
|
58
|
+
.filter((fixture) => fixture.schema === format.lifecycleSchema && fixture.version === version)
|
|
59
|
+
.map((fixture) => fixture.id),
|
|
60
|
+
})));
|
|
61
|
+
const shapes = options.formats.flatMap((format) => (v4
|
|
62
|
+
? format.descriptor.supportedVersions
|
|
63
|
+
: [format.descriptor.currentVersion]).map((version) => ({
|
|
64
|
+
id: lifecycleShapeId(format, version, v4),
|
|
65
|
+
schema: format.lifecycleSchema,
|
|
66
|
+
versions: v4 ? [version] : format.descriptor.supportedVersions,
|
|
67
|
+
objects: [{
|
|
68
|
+
path: '$',
|
|
69
|
+
requiredKeys: format.requiredKeys,
|
|
70
|
+
optionalKeys: format.optionalKeys,
|
|
71
|
+
...(v4 ? { alternativeRequiredKeys: [] } : {}),
|
|
72
|
+
unknownKeys: 'reject',
|
|
73
|
+
}],
|
|
74
|
+
fixedArrays: [],
|
|
75
|
+
normalisation: 'preserve_document',
|
|
76
|
+
target: null,
|
|
77
|
+
...(v4 ? { discriminator: null } : {}),
|
|
78
|
+
})));
|
|
79
|
+
const boundProfiles = options.formats.map((format) => ({
|
|
80
|
+
id: `${formatSlug(format.descriptor.id)}.bounds`,
|
|
81
|
+
bounds: format.descriptor.byteBudget === null
|
|
82
|
+
? [{
|
|
83
|
+
id: 'aggregate-depth', path: '$', phase: 'pre_accumulation',
|
|
84
|
+
unit: 'depth', minimum: 0, maximum: 64, handling: 'reject',
|
|
85
|
+
}]
|
|
86
|
+
: [{
|
|
87
|
+
id: 'serialised-bytes', path: '$', phase: 'serialised',
|
|
88
|
+
unit: 'bytes', minimum: 1, maximum: format.descriptor.byteBudget,
|
|
89
|
+
handling: 'reject',
|
|
90
|
+
}],
|
|
91
|
+
}));
|
|
92
|
+
const serializerHookId = `${options.id}.serialise`;
|
|
93
|
+
const implementationHooks = new Map();
|
|
94
|
+
for (const format of options.formats) {
|
|
95
|
+
const key = `${format.hook.module}\u0000${format.hook.exportName}`;
|
|
96
|
+
if (!implementationHooks.has(key)) {
|
|
97
|
+
implementationHooks.set(key, {
|
|
98
|
+
id: `${options.id}.${formatSlug(format.descriptor.id)}.implementation`,
|
|
99
|
+
...format.hook,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const hookIdFor = (format) => implementationHooks
|
|
104
|
+
.get(`${format.hook.module}\u0000${format.hook.exportName}`).id;
|
|
105
|
+
const hooks = [
|
|
106
|
+
...implementationHooks.values(),
|
|
107
|
+
{
|
|
108
|
+
id: serializerHookId,
|
|
109
|
+
role: 'serialiser',
|
|
110
|
+
runtime: 'shared',
|
|
111
|
+
module: options.serializerModule ?? options.owner,
|
|
112
|
+
exportName: options.serializerExportName,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
const serialisedFormat = options.formats[0];
|
|
116
|
+
const serialisationProfileId = `${options.id}.json`;
|
|
117
|
+
const privacyProfileId = `${options.id}.privacy`;
|
|
118
|
+
const expiryPolicyId = `${options.id}.expiry`;
|
|
119
|
+
const consumerEdges = options.formats.map((format, index) => {
|
|
120
|
+
const outputOnly = format.descriptor.futureVersionBehavior === 'not_applicable';
|
|
121
|
+
const acceptedVersions = outputOnly ? [] : format.descriptor.supportedVersions;
|
|
122
|
+
const edgeVersions = outputOnly ? [format.descriptor.currentVersion] : format.descriptor.supportedVersions;
|
|
123
|
+
const shapeIds = v4
|
|
124
|
+
? edgeVersions.map((version) => lifecycleShapeId(format, version, true))
|
|
125
|
+
: [lifecycleShapeId(format, format.descriptor.currentVersion, false)];
|
|
126
|
+
const hookId = hookIdFor(format);
|
|
127
|
+
const serialises = index === 0;
|
|
128
|
+
return {
|
|
129
|
+
id: `${options.id}.${formatSlug(format.descriptor.id)}.consumer`,
|
|
130
|
+
plane: options.plane,
|
|
131
|
+
operation: outputOnly ? 'produce-reviewed-output' : 'validate-and-produce',
|
|
132
|
+
acceptedContracts: acceptedVersions.length
|
|
133
|
+
? [{
|
|
134
|
+
schema: format.lifecycleSchema,
|
|
135
|
+
versions: acceptedVersions,
|
|
136
|
+
mode: 'direct',
|
|
137
|
+
...(metadataVersion >= 3 ? { discriminator: null } : {}),
|
|
138
|
+
}]
|
|
139
|
+
: [],
|
|
140
|
+
emittedContract: {
|
|
141
|
+
schema: format.lifecycleSchema,
|
|
142
|
+
version: format.descriptor.currentVersion,
|
|
143
|
+
...(v4 ? { discriminator: null } : {}),
|
|
144
|
+
},
|
|
145
|
+
shapeIds,
|
|
146
|
+
boundProfileIds: [`${formatSlug(format.descriptor.id)}.bounds`],
|
|
147
|
+
hookIds: serialises ? [hookId, serializerHookId] : [hookId],
|
|
148
|
+
serialisationProfileId: serialises ? serialisationProfileId : null,
|
|
149
|
+
privacyProfileId,
|
|
150
|
+
expiryPolicyId,
|
|
151
|
+
requestMode: 'none',
|
|
152
|
+
retentionEffect: options.retention,
|
|
153
|
+
bindingState: 'declared_unenforced',
|
|
154
|
+
policyState: 'current',
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
const metadata = {
|
|
158
|
+
metadataVersion,
|
|
159
|
+
enforcement: 'declarative_only',
|
|
160
|
+
shapes,
|
|
161
|
+
boundProfiles,
|
|
162
|
+
hooks,
|
|
163
|
+
serialisationProfiles: [{
|
|
164
|
+
id: serialisationProfileId,
|
|
165
|
+
schema: serialisedFormat.lifecycleSchema,
|
|
166
|
+
versions: [serialisedFormat.descriptor.currentVersion],
|
|
167
|
+
mediaType: 'application/json',
|
|
168
|
+
encoding: 'utf-8',
|
|
169
|
+
bom: false,
|
|
170
|
+
indentSpaces: 2,
|
|
171
|
+
terminalLf: true,
|
|
172
|
+
propertyOrder: 'normalised_fixed',
|
|
173
|
+
canonicalisation: null,
|
|
174
|
+
integrity: 'none',
|
|
175
|
+
serializerHookId,
|
|
176
|
+
verifierHookIds: [],
|
|
177
|
+
}],
|
|
178
|
+
privacyProfiles: [{
|
|
179
|
+
id: privacyProfileId,
|
|
180
|
+
classification: 'analyst_authored_sensitive',
|
|
181
|
+
projection: options.projection,
|
|
182
|
+
includedCategories: options.includedCategories,
|
|
183
|
+
excludedCategories: options.excludedCategories,
|
|
184
|
+
notePolicy: 'discarded',
|
|
185
|
+
retention: options.retention,
|
|
186
|
+
network: 'none',
|
|
187
|
+
sharingReview: options.retention === 'operator_controlled_output' ? 'required' : 'not_applicable',
|
|
188
|
+
}],
|
|
189
|
+
expiryProfiles: [{
|
|
190
|
+
id: expiryPolicyId,
|
|
191
|
+
field: null,
|
|
192
|
+
anchor: null,
|
|
193
|
+
handling: 'not_applicable',
|
|
194
|
+
phase: 'not_applicable',
|
|
195
|
+
maximumLifetimeDays: null,
|
|
196
|
+
}],
|
|
197
|
+
consumerEdges,
|
|
198
|
+
consumerRelationships: [],
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
id: options.id,
|
|
202
|
+
owner: options.owner,
|
|
203
|
+
privacy: 'analyst_authored_sensitive',
|
|
204
|
+
compatibility: options.formats.map((format) => format.descriptor),
|
|
205
|
+
contracts,
|
|
206
|
+
fixtures,
|
|
207
|
+
metadata,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export function buildExtractedLifecycleFamilyV2(options) {
|
|
211
|
+
return buildExtractedLifecycleFamily(options, 2);
|
|
212
|
+
}
|
|
213
|
+
export function buildExtractedLifecycleFamilyV3(options) {
|
|
214
|
+
return buildExtractedLifecycleFamily(options, 3);
|
|
215
|
+
}
|
|
216
|
+
export function buildExtractedLifecycleFamilyV4(options) {
|
|
217
|
+
return buildExtractedLifecycleFamily(options, 4);
|
|
218
|
+
}
|