@openai/codex-security 0.6.0 → 0.8.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 +76 -39
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/examples/completed-scan/findings.json +34 -34
- package/_bundled_plugin/examples/completed-scan/report.md +22 -31
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +27 -29
- package/_bundled_plugin/examples/{completed-scan → legacy-completed-scan}/coverage.json +1 -0
- package/_bundled_plugin/examples/legacy-completed-scan/findings.json +57 -0
- package/_bundled_plugin/examples/legacy-completed-scan/report.md +98 -0
- package/_bundled_plugin/examples/legacy-completed-scan/scan-manifest.json +43 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +1 -1
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/access-advisory.md +11 -0
- package/_bundled_plugin/references/core-scan.md +30 -77
- package/_bundled_plugin/references/final-report.md +50 -184
- package/_bundled_plugin/references/scan-artifacts.md +5 -5
- package/_bundled_plugin/references/scan-contract.md +12 -12
- package/_bundled_plugin/references/scan-prologue.md +1 -1
- package/_bundled_plugin/references/scan-runtime.md +1 -5
- package/_bundled_plugin/references/threat-model.md +33 -41
- package/_bundled_plugin/schemas/coverage.schema.json +12 -1
- package/_bundled_plugin/schemas/scan-manifest.schema.json +37 -11
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +38 -1
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +5 -5
- package/_bundled_plugin/scripts/deep_scan_config.py +39 -39
- package/_bundled_plugin/scripts/deep_scan_workbench.py +146 -86
- package/_bundled_plugin/scripts/finalize_scan_contract.py +249 -76
- package/_bundled_plugin/scripts/report_projection.py +49 -17
- package/_bundled_plugin/scripts/review_state.py +68 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +4 -2
- package/_bundled_plugin/scripts/validate_scan_contract.py +1 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -14
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +3230 -0
- package/_bundled_plugin/scripts/workbench/retained_records.py +627 -0
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +651 -8
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +72 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +730 -0
- package/_bundled_plugin/scripts/workbench_cli.py +3 -0
- package/_bundled_plugin/scripts/workbench_constants.py +0 -1
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +479 -0
- package/_bundled_plugin/scripts/workbench_db.py +55 -171
- package/_bundled_plugin/scripts/workbench_feedback.py +0 -1
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +51 -9
- package/_bundled_plugin/scripts/workbench_native_indexes.py +56 -44
- package/_bundled_plugin/scripts/workbench_saved_results.py +808 -2389
- package/_bundled_plugin/scripts/workbench_scan_history.py +77 -7
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +4 -1
- package/_bundled_plugin/scripts/workbench_target.py +142 -17
- package/_bundled_plugin/scripts/workbench_validation.py +9 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +21 -0
- package/_bundled_plugin/shared/workbench-migrations.json +28 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +3 -14
- package/_bundled_plugin/skills/assess-patch-risk/references/windows-validation.md +14 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +38 -103
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +11 -73
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +57 -116
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +28 -51
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +9 -9
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +26 -140
- package/_bundled_plugin/skills/fix-finding/SKILL.md +9 -28
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +28 -218
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +29 -424
- package/_bundled_plugin/skills/publish-findings/SKILL.md +32 -24
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +64 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +12 -12
- package/_bundled_plugin/skills/security-scan/SKILL.md +29 -17
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +11 -17
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +52 -69
- package/_bundled_plugin/skills/threat-model/SKILL.md +16 -9
- package/_bundled_plugin/skills/track-findings/SKILL.md +1 -1
- package/_bundled_plugin/skills/triage-finding/SKILL.md +5 -15
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -6
- package/_bundled_plugin/skills/validation/SKILL.md +42 -104
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +21 -106
- package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +21 -159
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +18 -60
- package/dist/api.d.ts +5 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +359 -53
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -1
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +696 -430
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +2 -23
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-scan.d.ts +8 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +2 -0
- package/dist/component-scan.js.map +1 -1
- package/dist/contract.d.ts +5 -2
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +93 -45
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts +18 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +107 -12
- package/dist/cost.js.map +1 -1
- package/dist/coverage-presentation.d.ts +6 -0
- package/dist/coverage-presentation.d.ts.map +1 -0
- package/dist/coverage-presentation.js +34 -0
- package/dist/coverage-presentation.js.map +1 -0
- package/dist/custom-publish.js +2 -2
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.js +5 -5
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +47 -19
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +3 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +2 -2
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +1 -0
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +3 -0
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +21 -1
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +9 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/endor-findings.d.ts +4 -3
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +16 -11
- package/dist/endor-findings.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +13 -5
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +1 -0
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +14 -3
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +2 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +64 -28
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +12 -1
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +25 -6
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +2 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +7 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +63 -31
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-imports-feature.d.ts +6 -0
- package/dist/external-imports-feature.d.ts.map +1 -0
- package/dist/external-imports-feature.js +51 -0
- package/dist/external-imports-feature.js.map +1 -0
- package/dist/finding-workflow.d.ts +24 -5
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +24 -9
- package/dist/finding-workflow.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +3 -1
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-findings.d.ts +4 -3
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +16 -14
- package/dist/github-findings.js.map +1 -1
- package/dist/host-protocol.d.ts +1 -1
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +2 -2
- package/dist/host-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +19 -2
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan.d.ts +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +0 -6
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.js +17 -17
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -0
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +20 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/mock-scan.d.ts +1 -2
- package/dist/mock-scan.d.ts.map +1 -1
- package/dist/mock-scan.js +12 -17
- package/dist/mock-scan.js.map +1 -1
- package/dist/models.d.ts +10 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +1 -6
- package/dist/multiscan.js.map +1 -1
- package/dist/native-json-findings.d.ts +30 -0
- package/dist/native-json-findings.d.ts.map +1 -0
- package/dist/native-json-findings.js +114 -0
- package/dist/native-json-findings.js.map +1 -0
- package/dist/opengrep-findings.d.ts +10 -0
- package/dist/opengrep-findings.d.ts.map +1 -0
- package/dist/opengrep-findings.js +198 -0
- package/dist/opengrep-findings.js.map +1 -0
- package/dist/owner-evidence.d.ts +2 -0
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -1
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +2 -0
- package/dist/patch-tui.js.map +1 -1
- package/dist/publication.js +1 -2
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +1 -0
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +10 -0
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +1 -25
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -24
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +5 -3
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +9 -6
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +7 -7
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts +5 -3
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +79 -26
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +9 -3
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-owner-suggestions.d.ts +1 -1
- package/dist/scan-owner-suggestions.d.ts.map +1 -1
- package/dist/scan-owner-suggestions.js +4 -4
- package/dist/scan-owner-suggestions.js.map +1 -1
- package/dist/scan-usage-display.d.ts +8 -0
- package/dist/scan-usage-display.d.ts.map +1 -0
- package/dist/scan-usage-display.js +46 -0
- package/dist/scan-usage-display.js.map +1 -0
- package/dist/scanner-import.d.ts +1 -1
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +7 -3
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +17 -22
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +4 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +22 -89
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/skill-authentication.d.ts +18 -0
- package/dist/skill-authentication.d.ts.map +1 -0
- package/dist/skill-authentication.js +82 -0
- package/dist/skill-authentication.js.map +1 -0
- package/dist/snyk-findings.d.ts +5 -4
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +18 -17
- package/dist/snyk-findings.js.map +1 -1
- package/dist/suggest-owners.d.ts +4 -1
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +53 -21
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +4 -1
- package/dist/targets.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -1
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +3 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -1
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +27 -23
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +3 -4
- package/docs/cli.md +171 -41
- package/docs/dedupe-records.md +15 -1
- package/docs/findings-service.md +119 -118
- package/docs/hosted-remediation.md +19 -17
- package/docs/hosted-scans.md +37 -11
- package/package.json +9 -9
- package/_bundled_plugin/scripts/generate_in_scope_files.py +0 -277
- package/_bundled_plugin/scripts/generate_rank_input.py +0 -350
- package/_bundled_plugin/scripts/rank_preview.py +0 -129
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,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KAAK,mBAAmB;gBACpC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM;YACT,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,mBAAmB;gBAC1C,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACtC,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,OAAO,KAAK,IAAI,UAAU;YACxB,CAAC,CAAC;gBACE;oBACE,GAAG,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,KAAK,IAAI,UAAU,EAAE;oBAC3C,QAAQ,EAAE,QAAiB;iBAC5B;aACF;YACH,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CACF,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,WAAW,CAAC,OAAO;QAC7B,WAAW;QACX,kBAAkB,EAAE;YAClB,GAAG,WAAW,CAAC,kBAAkB;YACjC,GAAG,kBAAkB;SACtB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport { readSnykFindings, snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { readSemgrepFindings } from \"./semgrep-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport { readEndorFindings, endorRepositoryUrls } from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport { readVendorFindingsForPublication } from \"./wiz-findings.js\";\n\n/** File reader names mapped to their stored and Cloud source provider. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n} as const satisfies Record<string, Provider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK, shared by local and Cloud imports. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n /** Preserve previous Wiz projections when resuming immutable Cloud requests. */\n publication?: ExternalPublicationInput;\n sourceRepositories?: ExternalSourceRepository[];\n}\n\n/** @internal Read vendor evidence for the local and Cloud import entrypoints. */\nexport async function readExternalFindings(\n path: string,\n options: ExternalFindingsReaderOptions,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ReadExternalFindings> {\n if (options.provider === \"opengrep\") {\n const sourceRepositoryUrl = options.sourceRepositoryUrl ?? \"\";\n return {\n findings: await readOpenGrepFindings(\n path,\n { sourceRepositoryUrl },\n target,\n ),\n sourceRepositories: [{ url: sourceRepositoryUrl }],\n };\n }\n if (options.provider === \"snyk\") {\n const findings = await readSnykFindings(path, target);\n return {\n findings,\n sourceRepositories: findings.findings.flatMap(({ evidence }) =>\n snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url })),\n ),\n };\n }\n if (options.provider === \"semgrep\") {\n const findings = await readSemgrepFindings(\n path,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl ?? \"\",\n },\n target,\n );\n const sourceRepositories = findings.findings.flatMap(({ evidence }) => {\n const context = evidence.source_data?.[\"runContext\"];\n const references = isRecord(context)\n ? context[\"versionControlProvenance\"]\n : undefined;\n return Array.isArray(references)\n ? references.flatMap((reference) =>\n isRecord(reference) &&\n typeof reference[\"repositoryUri\"] === \"string\" &&\n reference[\"repositoryUri\"].trim()\n ? [{ url: reference[\"repositoryUri\"] }]\n : [],\n )\n : [];\n });\n return { findings, sourceRepositories };\n }\n if (options.provider === \"endor\") {\n const parsed = await readEndorFindings(path, target);\n return {\n findings: parsed,\n sourceRepositories: parsed.findings.flatMap((finding) =>\n endorRepositoryUrls(finding.evidence.source_data).map((url) => ({\n url,\n })),\n ),\n };\n }\n if (options.provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n const publication = await readVendorFindingsForPublication(path, target);\n // Raw package exports keep repository-branch URLs in retained source data.\n const sourceRepositories = publication.current.findings.flatMap(\n ({ evidence }) => {\n const csvUrl = wizCsvRepositoryUrl(evidence);\n if (csvUrl) return [{ url: csvUrl, platform: \"github\" as const }];\n const asset = evidence.source_data?.[\"vulnerableAsset\"];\n if (!isRecord(asset) || typeof asset[\"cloudProviderURL\"] !== \"string\")\n return [];\n const url = URL.parse(asset[\"cloudProviderURL\"]);\n if (!url) return [];\n const github =\n asset[\"nativeType\"] === \"github#repositoryBranch\" ||\n (asset[\"type\"] === \"REPOSITORY_BRANCH\" &&\n isGitHubCloudHost(url.hostname));\n if (!github)\n return asset[\"type\"] === \"REPOSITORY_BRANCH\"\n ? [{ url: asset[\"cloudProviderURL\"] }]\n : [];\n const [, owner, repository] = url.pathname.split(\"/\");\n return owner && repository\n ? [\n {\n url: `${url.origin}/${owner}/${repository}`,\n platform: \"github\" as const,\n },\n ]\n : [];\n },\n );\n return {\n findings: publication.current,\n publication,\n sourceRepositories: [\n ...publication.sourceRepositories,\n ...sourceRepositories,\n ],\n };\n}\n"]}
|
|
@@ -11,6 +11,8 @@ export interface ExternalSourceRepository {
|
|
|
11
11
|
}
|
|
12
12
|
export interface ExternalFindings {
|
|
13
13
|
read: number;
|
|
14
|
+
/** Reader-retained run metadata, including diagnostics for empty reports. */
|
|
15
|
+
report?: Record<string, unknown>;
|
|
14
16
|
findings: ExternalFinding[];
|
|
15
17
|
excluded: {
|
|
16
18
|
position: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACL"}
|
|
1
|
+
{"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings.js","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExternalFindingEvidence } from \"./external-import-models.js\";\n\n/** A provider occurrence and its evidence, independent of a Codex assessment. */\nexport interface ExternalFinding {\n source_finding_id: string;\n evidence: ExternalFindingEvidence;\n}\n\n/** Repository provenance retained by a reader outside the published evidence. */\nexport interface ExternalSourceRepository {\n url: string;\n platform?: \"github\";\n}\n\nexport interface ExternalFindings {\n read: number;\n findings: ExternalFinding[];\n excluded: {\n position: number;\n source_finding_id: string | null;\n reason: string;\n }[];\n}\n\n/** @internal Keep earlier provider projections only for immutable request replay. */\nexport interface ExternalPublicationInput {\n current: ExternalFindings;\n legacy: ExternalFindings;\n currentIdentity: unknown;\n legacyIdentity: unknown;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-findings.js","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExternalFindingEvidence } from \"./external-import-models.js\";\n\n/** A provider occurrence and its evidence, independent of a Codex assessment. */\nexport interface ExternalFinding {\n source_finding_id: string;\n evidence: ExternalFindingEvidence;\n}\n\n/** Repository provenance retained by a reader outside the published evidence. */\nexport interface ExternalSourceRepository {\n url: string;\n platform?: \"github\";\n}\n\nexport interface ExternalFindings {\n read: number;\n /** Reader-retained run metadata, including diagnostics for empty reports. */\n report?: Record<string, unknown>;\n findings: ExternalFinding[];\n excluded: {\n position: number;\n source_finding_id: string | null;\n reason: string;\n }[];\n}\n\n/** @internal Keep earlier provider projections only for immutable request replay. */\nexport interface ExternalPublicationInput {\n current: ExternalFindings;\n legacy: ExternalFindings;\n currentIdentity: unknown;\n legacyIdentity: unknown;\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ExternalFindingEvidence, FindingImportRequest, FindingImportReceipt, ImportRepositoryPage, SourceReportPage, SourceReport } from "./external-import-models.js";
|
|
2
|
+
/** Local storage accepts complete evidence; Cloud publication has payload limits. */
|
|
3
|
+
export type ExternalImportTarget = "local" | "cloud";
|
|
2
4
|
/** Compare repository URLs without changing the retained vendor evidence.
|
|
3
5
|
* GitHub repository paths are case-insensitive; unknown VCS hosts stay strict.
|
|
4
6
|
* Keep protocols and explicit ports distinct, matching the Cloud URL contract. */
|
|
@@ -8,6 +10,10 @@ export declare const validateImportReceipt: (input: unknown) => FindingImportRec
|
|
|
8
10
|
export declare const validateRepositories: (input: unknown) => ImportRepositoryPage;
|
|
9
11
|
export declare const validateSourceReports: (input: unknown) => SourceReportPage;
|
|
10
12
|
export declare const validateSourceReport: (input: unknown) => SourceReport;
|
|
11
|
-
|
|
13
|
+
/** Report metadata is retained in previews and receipts without Cloud evidence size limits. */
|
|
14
|
+
export declare function validateExternalReport(report: Record<string, unknown> | undefined): void;
|
|
15
|
+
export declare function validateExternalEvidence(input: unknown, target?: ExternalImportTarget): ExternalFindingEvidence;
|
|
16
|
+
/** Return the validated Cloud wire size, or zero for local evidence. */
|
|
17
|
+
export declare function validateExternalEvidenceJson(input: unknown, target: ExternalImportTarget, additionalCloudBytes?: number): number;
|
|
12
18
|
export declare function validateImportRequest(input: unknown): FindingImportRequest;
|
|
13
19
|
//# sourceMappingURL=external-import-contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-import-contract.d.ts","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external-import-contract.d.ts","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACb,MAAM,6BAA6B,CAAC;AAQrC,qFAAqF;AACrF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC;AAqBrD;;kFAEkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAatD;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AA2JD,eAAO,MAAM,qBAAqB,UA3BjB,OAAO,yBA6BvB,CAAC;AACF,eAAO,MAAM,oBAAoB,UA9BhB,OAAO,yBAgCvB,CAAC;AACF,eAAO,MAAM,qBAAqB,UAjCjB,OAAO,qBAkCyB,CAAC;AAClD,eAAO,MAAM,oBAAoB,UAnChB,OAAO,iBAmCmD,CAAC;AAW5E,+FAA+F;AAC/F,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC1C,IAAI,CAON;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,uBAAuB,CA6EzB;AAED,wEAAwE;AACxE,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,oBAAoB,EAC5B,oBAAoB,SAAI,GACvB,MAAM,CAiCR;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAgB1E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isIP } from "node:net";
|
|
2
|
+
import { isNumberObject } from "node:util/types";
|
|
2
3
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
3
4
|
import schema from "../schemas/external-findings.schema.json" with { type: "json" };
|
|
4
5
|
const ajv = new Ajv2020({
|
|
@@ -6,6 +7,7 @@ const ajv = new Ajv2020({
|
|
|
6
7
|
validateFormats: false,
|
|
7
8
|
useDefaults: true,
|
|
8
9
|
});
|
|
10
|
+
const localSchema = JSON.parse(JSON.stringify(schema, (key, value) => key === "maxLength" || key === "maxItems" ? undefined : value));
|
|
9
11
|
const STRING_BYTE_LIMITS = {
|
|
10
12
|
description: 65536,
|
|
11
13
|
snippet: 65536,
|
|
@@ -42,12 +44,12 @@ export function cloudRepositoryUrlKey(value) {
|
|
|
42
44
|
// Cloud ImportModel applies these constraints to both requests and responses.
|
|
43
45
|
// Its UTF-8 limits are not exported as JSON Schema character limits: even a
|
|
44
46
|
// plain string field such as a receipt error message inherits the 512-byte bound.
|
|
45
|
-
function validateModelStrings(input) {
|
|
47
|
+
function validateModelStrings(input, target) {
|
|
46
48
|
if (input === null || typeof input !== "object")
|
|
47
49
|
return;
|
|
48
50
|
if (Array.isArray(input)) {
|
|
49
51
|
for (const item of input)
|
|
50
|
-
validateModelStrings(item);
|
|
52
|
+
validateModelStrings(item, target);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
for (const [field, value] of Object.entries(input)) {
|
|
@@ -58,42 +60,44 @@ function validateModelStrings(input) {
|
|
|
58
60
|
value.includes("\0"))
|
|
59
61
|
throw new Error(`${field} must be nonempty and contain no NUL characters.`);
|
|
60
62
|
const limit = STRING_BYTE_LIMITS[field] ?? 512;
|
|
61
|
-
if (Buffer.byteLength(value) > limit)
|
|
63
|
+
if (target === "cloud" && Buffer.byteLength(value) > limit)
|
|
62
64
|
throw new Error(`${field} exceeds its Cloud limit of ${limit} UTF-8 bytes.`);
|
|
63
65
|
}
|
|
64
66
|
else if (Array.isArray(value) &&
|
|
65
67
|
value.every((item) => typeof item === "string")) {
|
|
66
|
-
if (
|
|
68
|
+
if (target === "cloud" &&
|
|
69
|
+
value.some((item) => Buffer.byteLength(item) > 512))
|
|
67
70
|
throw new Error(`${field} entries exceed the Cloud limit of 512 UTF-8 bytes.`);
|
|
68
71
|
}
|
|
69
72
|
else
|
|
70
|
-
validateModelStrings(value);
|
|
73
|
+
validateModelStrings(value, target);
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
const modelSchemas = schema.$defs;
|
|
74
76
|
const detailValidators = new Map();
|
|
75
77
|
/** AJV does not apply defaults through nullable anyOf references. Validate the
|
|
76
78
|
* present detail objects directly against their generated model definitions so
|
|
77
79
|
* sparse normalized inputs match the backend's serialized evidence. */
|
|
78
|
-
function materializeDetailDefaults(value, fieldSchema) {
|
|
80
|
+
function materializeDetailDefaults(value, fieldSchema, target) {
|
|
79
81
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
80
82
|
return;
|
|
81
83
|
const reference = fieldSchema.$ref ?? fieldSchema.anyOf?.find((branch) => branch.$ref)?.$ref;
|
|
82
84
|
if (!reference)
|
|
83
85
|
return;
|
|
84
86
|
const name = reference.split("/").at(-1);
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
+
const modelSchema = target === "local" ? localSchema : schema;
|
|
88
|
+
const definition = modelSchema.$defs[name];
|
|
89
|
+
const key = `${target}:${reference}`;
|
|
90
|
+
let check = detailValidators.get(key);
|
|
87
91
|
if (!check) {
|
|
88
|
-
check = ajv.compile({ $defs:
|
|
89
|
-
detailValidators.set(
|
|
92
|
+
check = ajv.compile({ $defs: modelSchema.$defs, $ref: reference });
|
|
93
|
+
detailValidators.set(key, check);
|
|
90
94
|
}
|
|
91
95
|
if (!check(value))
|
|
92
96
|
throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);
|
|
93
97
|
for (const [field, childSchema] of Object.entries(definition.properties ?? {}))
|
|
94
|
-
materializeDetailDefaults(value[field], childSchema);
|
|
98
|
+
materializeDetailDefaults(value[field], childSchema, target);
|
|
95
99
|
}
|
|
96
|
-
function normalizeEvidenceDetails(value) {
|
|
100
|
+
function normalizeEvidenceDetails(value, target) {
|
|
97
101
|
if (value !== null && typeof value === "object") {
|
|
98
102
|
const fields = value;
|
|
99
103
|
// Cloud omits these new optional fields when null. Preserve every legacy
|
|
@@ -113,41 +117,60 @@ function normalizeEvidenceDetails(value) {
|
|
|
113
117
|
for (const field of ["repository", "advisory"])
|
|
114
118
|
if (details[field] === null)
|
|
115
119
|
delete details[field];
|
|
116
|
-
materializeDetailDefaults(fields["details"],
|
|
120
|
+
materializeDetailDefaults(fields["details"], schema.$defs.ImportedFindingEvidence.properties.details, target);
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
|
-
function validator(name) {
|
|
124
|
+
function validator(name, target = "cloud") {
|
|
121
125
|
const check = ajv.compile({
|
|
122
|
-
$defs: schema.$defs,
|
|
126
|
+
$defs: (target === "local" ? localSchema : schema).$defs,
|
|
123
127
|
$ref: `#/$defs/${name}`,
|
|
124
128
|
});
|
|
125
129
|
return (input) => {
|
|
126
130
|
if (name === "ImportedFindingEvidence")
|
|
127
|
-
normalizeEvidenceDetails(input);
|
|
131
|
+
normalizeEvidenceDetails(input, target);
|
|
128
132
|
else if (input && typeof input === "object") {
|
|
129
133
|
if (name === "SourceReport" && "evidence" in input)
|
|
130
|
-
normalizeEvidenceDetails(input.evidence);
|
|
134
|
+
normalizeEvidenceDetails(input.evidence, target);
|
|
131
135
|
if (name === "FindingImportRequest" &&
|
|
132
136
|
"items" in input &&
|
|
133
137
|
Array.isArray(input.items))
|
|
134
138
|
for (const item of input.items)
|
|
135
|
-
normalizeEvidenceDetails(item?.evidence);
|
|
139
|
+
normalizeEvidenceDetails(item?.evidence, target);
|
|
136
140
|
}
|
|
137
141
|
if (!check(input))
|
|
138
142
|
throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);
|
|
139
|
-
validateModelStrings(input);
|
|
143
|
+
validateModelStrings(input, target);
|
|
140
144
|
return input;
|
|
141
145
|
};
|
|
142
146
|
}
|
|
143
147
|
const evidence = validator("ImportedFindingEvidence");
|
|
148
|
+
const localEvidence = validator("ImportedFindingEvidence", "local");
|
|
144
149
|
const request = validator("FindingImportRequest");
|
|
145
150
|
export const validateImportReceipt = validator("FindingImportReceipt");
|
|
146
151
|
export const validateRepositories = validator("ImportRepositoryPage");
|
|
147
152
|
export const validateSourceReports = validator("SourceReportPage");
|
|
148
153
|
export const validateSourceReport = validator("SourceReport");
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
function requireJsonNumber(value, label) {
|
|
155
|
+
if (!Number.isFinite(value))
|
|
156
|
+
throw new Error(`${label} must contain finite JSON numbers.`);
|
|
157
|
+
if (Number.isInteger(value) && !Number.isSafeInteger(value))
|
|
158
|
+
throw new Error(`${label} integers must be within JavaScript's safe integer range; export larger values as strings to preserve them exactly.`);
|
|
159
|
+
}
|
|
160
|
+
/** Report metadata is retained in previews and receipts without Cloud evidence size limits. */
|
|
161
|
+
export function validateExternalReport(report) {
|
|
162
|
+
if (report === undefined)
|
|
163
|
+
return;
|
|
164
|
+
JSON.stringify(report, (_key, value) => {
|
|
165
|
+
if (isNumberObject(value))
|
|
166
|
+
value = +value;
|
|
167
|
+
if (typeof value === "number")
|
|
168
|
+
requireJsonNumber(value, "Scanner report");
|
|
169
|
+
return value;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
export function validateExternalEvidence(input, target = "cloud") {
|
|
173
|
+
const result = (target === "local" ? localEvidence : evidence)(input);
|
|
151
174
|
for (const location of result.locations ?? []) {
|
|
152
175
|
const path = location.path.replaceAll("\\", "/");
|
|
153
176
|
if (path.startsWith("/") ||
|
|
@@ -209,21 +232,26 @@ export function validateExternalEvidence(input) {
|
|
|
209
232
|
!validHost)
|
|
210
233
|
throw new Error("Evidence URLs must be HTTP(S) links without credentials.");
|
|
211
234
|
}
|
|
235
|
+
validateExternalEvidenceJson(result, target);
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
/** Return the validated Cloud wire size, or zero for local evidence. */
|
|
239
|
+
export function validateExternalEvidenceJson(input, target, additionalCloudBytes = 0) {
|
|
240
|
+
// Local evidence still has to be serializable JSON, including acyclic source data.
|
|
241
|
+
if (target === "local")
|
|
242
|
+
JSON.stringify(input);
|
|
212
243
|
let numericByteAdjustment = 0;
|
|
213
|
-
const pending = [[
|
|
244
|
+
const pending = [[input, 0]];
|
|
214
245
|
while (pending.length > 0) {
|
|
215
246
|
const [value, depth] = pending.pop();
|
|
216
|
-
if (depth > 20)
|
|
247
|
+
if (target === "cloud" && depth > 20)
|
|
217
248
|
throw new Error("Evidence exceeds the Cloud JSON depth limit of 20.");
|
|
218
249
|
if (value !== null && typeof value === "object") {
|
|
219
250
|
for (const child of Object.values(value))
|
|
220
251
|
pending.push([child, depth + 1]);
|
|
221
252
|
}
|
|
222
253
|
else if (typeof value === "number") {
|
|
223
|
-
|
|
224
|
-
throw new Error("Evidence must contain finite JSON numbers.");
|
|
225
|
-
if (Number.isInteger(value) && !Number.isSafeInteger(value))
|
|
226
|
-
throw new Error("Evidence integers must be within JavaScript's safe integer range; export larger values as strings to preserve them exactly.");
|
|
254
|
+
requireJsonNumber(value, "Evidence");
|
|
227
255
|
const wire = JSON.stringify(value);
|
|
228
256
|
// Cloud pads short exponents and formats small fractions scientifically.
|
|
229
257
|
const cloud = (wire.includes(".") && Math.abs(value) < 1e-4
|
|
@@ -232,10 +260,14 @@ export function validateExternalEvidence(input) {
|
|
|
232
260
|
numericByteAdjustment += cloud.length - wire.length;
|
|
233
261
|
}
|
|
234
262
|
}
|
|
235
|
-
|
|
236
|
-
|
|
263
|
+
const bytes = target === "cloud"
|
|
264
|
+
? Buffer.byteLength(JSON.stringify(input)) +
|
|
265
|
+
numericByteAdjustment +
|
|
266
|
+
additionalCloudBytes
|
|
267
|
+
: 0;
|
|
268
|
+
if (bytes > 256 * 1024)
|
|
237
269
|
throw new Error("Evidence exceeds the Cloud limit of 256 KiB.");
|
|
238
|
-
return
|
|
270
|
+
return bytes;
|
|
239
271
|
}
|
|
240
272
|
export function validateImportRequest(input) {
|
|
241
273
|
const result = request(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-import-contract.js","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"A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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QACxD,MAAM,CAAC,KAAK,CAAC,MAAM;QAEnB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,IACE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;QAChE,MAAM,CAAC,KAAK,CAAC,MAAM;QAEnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;QAAE,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI;QAC7D,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { isIP } from \"node:net\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport schema from \"../schemas/external-findings.schema.json\" with { type: \"json\" };\nimport type {\n ExternalFindingEvidence,\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepositoryPage,\n SourceReportPage,\n SourceReport,\n} from \"./external-import-models.js\";\n\nconst ajv = new Ajv2020({\n strict: false,\n validateFormats: false,\n useDefaults: true,\n});\nconst STRING_BYTE_LIMITS: Readonly<Record<string, number>> = {\n description: 65536,\n snippet: 65536,\n remediation_instructions: 65536,\n expected: 65536,\n actual: 65536,\n file_url: 2048,\n path: 2048,\n url: 2048,\n manifest_path: 2048,\n client_id: 128,\n next: 4096,\n};\n\n/** Compare repository URLs without changing the retained vendor evidence.\n * GitHub repository paths are case-insensitive; unknown VCS hosts stay strict.\n * Keep protocols and explicit ports distinct, matching the Cloud URL contract. */\nexport function repositoryUrlKey(value: string): string {\n const normalized = value.replace(/\\/$/u, \"\").replace(/\\.git$/u, \"\");\n const parts = /^(https?):\\/\\/([^/?#]+)((?:\\/[^?#]*)?)((?:[?#].*)?)$/iu.exec(\n normalized,\n );\n if (!parts) return normalized;\n const authority = parts[2]!.toLowerCase();\n const hostname = authority.replace(/:\\d+$/u, \"\");\n const path =\n hostname === \"github.com\" || hostname.endsWith(\".ghe.com\")\n ? parts[3]!.toLowerCase()\n : parts[3]!;\n return `${parts[1]!.toLowerCase()}://${authority}${path}${parts[4]!}`;\n}\n\n// Cloud's import catalog contains GitHub repositories, including custom Enterprise\n// hosts. Match its case-insensitive URL identity without merging schemes or ports.\nexport function cloudRepositoryUrlKey(value: string): string {\n return repositoryUrlKey(value).toLowerCase();\n}\n\n// Cloud ImportModel applies these constraints to both requests and responses.\n// Its UTF-8 limits are not exported as JSON Schema character limits: even a\n// plain string field such as a receipt error message inherits the 512-byte bound.\nfunction validateModelStrings(input: unknown): void {\n if (input === null || typeof input !== \"object\") return;\n if (Array.isArray(input)) {\n for (const item of input) validateModelStrings(item);\n return;\n }\n for (const [field, value] of Object.entries(input)) {\n if (field === \"source_data\") continue;\n if (typeof value === \"string\") {\n if (\n (!value.trim() && ![\"snippet\", \"expected\", \"actual\"].includes(field)) ||\n value.includes(\"\\0\")\n )\n throw new Error(\n `${field} must be nonempty and contain no NUL characters.`,\n );\n const limit = STRING_BYTE_LIMITS[field] ?? 512;\n if (Buffer.byteLength(value) > limit)\n throw new Error(\n `${field} exceeds its Cloud limit of ${limit} UTF-8 bytes.`,\n );\n } else if (\n Array.isArray(value) &&\n value.every((item) => typeof item === \"string\")\n ) {\n if (value.some((item) => Buffer.byteLength(item) > 512))\n throw new Error(\n `${field} entries exceed the Cloud limit of 512 UTF-8 bytes.`,\n );\n } else validateModelStrings(value);\n }\n}\n\ntype ModelSchema = {\n $ref?: string;\n anyOf?: ModelSchema[];\n properties?: Record<string, ModelSchema>;\n [key: string]: unknown;\n};\nconst modelSchemas: Record<string, ModelSchema> = schema.$defs;\nconst detailValidators = new Map<string, ReturnType<typeof ajv.compile>>();\n\n/** AJV does not apply defaults through nullable anyOf references. Validate the\n * present detail objects directly against their generated model definitions so\n * sparse normalized inputs match the backend's serialized evidence. */\nfunction materializeDetailDefaults(\n value: unknown,\n fieldSchema: ModelSchema,\n): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value))\n return;\n const reference =\n fieldSchema.$ref ?? fieldSchema.anyOf?.find((branch) => branch.$ref)?.$ref;\n if (!reference) return;\n const name = reference.split(\"/\").at(-1)!;\n const definition = modelSchemas[name]!;\n let check = detailValidators.get(reference);\n if (!check) {\n check = ajv.compile({ $defs: schema.$defs, $ref: reference });\n detailValidators.set(reference, check);\n }\n if (!check(value))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n for (const [field, childSchema] of Object.entries(\n definition.properties ?? {},\n ))\n materializeDetailDefaults(\n (value as Record<string, unknown>)[field],\n childSchema,\n );\n}\n\nfunction normalizeEvidenceDetails(value: unknown): void {\n if (value !== null && typeof value === \"object\") {\n const fields = value as Record<string, unknown>;\n // Cloud omits these new optional fields when null. Preserve every legacy\n // default so saved Wiz requests still replay the same evidence bytes.\n if (Array.isArray(fields[\"packages\"]))\n for (const value of fields[\"packages\"]) {\n if (\n value &&\n typeof value === \"object\" &&\n value[\"vulnerable_version_range\"] === null\n )\n delete value[\"vulnerable_version_range\"];\n }\n if (fields[\"details\"] === null) delete fields[\"details\"];\n else {\n const details = fields[\"details\"];\n if (details && typeof details === \"object\" && !Array.isArray(details))\n for (const field of [\"repository\", \"advisory\"])\n if ((details as Record<string, unknown>)[field] === null)\n delete (details as Record<string, unknown>)[field];\n materializeDetailDefaults(\n fields[\"details\"],\n modelSchemas[\"ImportedFindingEvidence\"]!.properties![\"details\"]!,\n );\n }\n }\n}\n\nfunction validator<T>(name: keyof typeof schema.$defs) {\n const check = ajv.compile<T>({\n $defs: schema.$defs,\n $ref: `#/$defs/${name}`,\n });\n return (input: unknown): T => {\n if (name === \"ImportedFindingEvidence\") normalizeEvidenceDetails(input);\n else if (input && typeof input === \"object\") {\n if (name === \"SourceReport\" && \"evidence\" in input)\n normalizeEvidenceDetails(input.evidence);\n if (\n name === \"FindingImportRequest\" &&\n \"items\" in input &&\n Array.isArray(input.items)\n )\n for (const item of input.items)\n normalizeEvidenceDetails(item?.evidence);\n }\n if (!check(input))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n validateModelStrings(input);\n return input;\n };\n}\n\nconst evidence = validator<ExternalFindingEvidence>(\"ImportedFindingEvidence\");\nconst request = validator<FindingImportRequest>(\"FindingImportRequest\");\nexport const validateImportReceipt = validator<FindingImportReceipt>(\n \"FindingImportReceipt\",\n);\nexport const validateRepositories = validator<ImportRepositoryPage>(\n \"ImportRepositoryPage\",\n);\nexport const validateSourceReports =\n validator<SourceReportPage>(\"SourceReportPage\");\nexport const validateSourceReport = validator<SourceReport>(\"SourceReport\");\n\nexport function validateExternalEvidence(\n input: unknown,\n): ExternalFindingEvidence {\n const result = evidence(input);\n for (const location of result.locations ?? []) {\n const path = location.path.replaceAll(\"\\\\\", \"/\");\n if (\n path.startsWith(\"/\") ||\n /^[A-Za-z]:/.test(path) ||\n path.split(\"/\").includes(\"..\")\n )\n throw new Error(\"Locations must use repository-relative paths.\");\n }\n const details = result.details;\n if (details) {\n if (details.kind === \"advisory\") {\n if (!details.advisory)\n throw new Error(\"Advisory evidence requires its source context.\");\n if (details.advisory.source === \"global\" && details.repository)\n throw new Error(\n \"Global advisory evidence cannot claim a source repository.\",\n );\n if (details.advisory.source === \"repository\" && !details.repository)\n throw new Error(\n \"Repository advisory evidence requires its source repository.\",\n );\n } else {\n if (!details.repository)\n throw new Error(\n \"Repository finding evidence requires its source repository.\",\n );\n if (details.advisory)\n throw new Error(\"Advisory source context requires advisory evidence.\");\n }\n }\n const endLine = result.details?.code?.end_line;\n if (endLine !== null && endLine !== undefined) {\n const firstLine = result.locations?.[0]?.line;\n if (firstLine === null || firstLine === undefined || endLine < firstLine)\n throw new Error(\n \"The code end line requires a first source location line and cannot precede it.\",\n );\n }\n const urls = [\n result.url,\n result.details?.repository?.url,\n result.details?.file_url,\n ];\n for (const value of urls) {\n if (value === null || value === undefined) continue;\n const url = value\n .replace(/[\\t\\r\\n]/gu, \"\")\n .replace(/^[\\u0000-\\u0020]+/u, \"\");\n const authority = /^https?:\\/\\/([^/?#]+)/iu.exec(url)?.[1];\n const normalizedAuthority = (authority ?? \"\")\n .replace(/[@:#?]/gu, \"\")\n .normalize(\"NFKC\");\n let validHost = true;\n if (authority?.includes(\"[\") || authority?.includes(\"]\")) {\n const hostname = /^\\[([^\\]]+)\\](?::[\\s\\S]*)?$/u.exec(authority)?.[1];\n const [address, scope, extraScope] = (hostname ?? \"\").split(\"%\");\n // Cloud accepts scoped IPv6 and IPvFuture hosts in brackets.\n validHost =\n hostname !== undefined &&\n (/^v[a-fA-F0-9]+\\.[\\s\\S]+$/u.test(hostname) ||\n (isIP(address!) === 6 && scope !== \"\" && extraScope === undefined));\n }\n if (\n !authority ||\n authority.includes(\"@\") ||\n /[/?#@:]/u.test(normalizedAuthority) ||\n !validHost\n )\n throw new Error(\n \"Evidence URLs must be HTTP(S) links without credentials.\",\n );\n }\n let numericByteAdjustment = 0;\n const pending: [unknown, number][] = [[result, 0]];\n while (pending.length > 0) {\n const [value, depth] = pending.pop()!;\n if (depth > 20)\n throw new Error(\"Evidence exceeds the Cloud JSON depth limit of 20.\");\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value))\n pending.push([child, depth + 1]);\n } else if (typeof value === \"number\") {\n if (!Number.isFinite(value))\n throw new Error(\"Evidence must contain finite JSON numbers.\");\n if (Number.isInteger(value) && !Number.isSafeInteger(value))\n throw new Error(\n \"Evidence integers must be within JavaScript's safe integer range; export larger values as strings to preserve them exactly.\",\n );\n const wire = JSON.stringify(value);\n // Cloud pads short exponents and formats small fractions scientifically.\n const cloud = (\n wire.includes(\".\") && Math.abs(value) < 1e-4\n ? value.toExponential()\n : wire\n ).replace(/e-(\\d)$/u, \"e-0$1\");\n numericByteAdjustment += cloud.length - wire.length;\n }\n }\n if (\n Buffer.byteLength(JSON.stringify(result)) + numericByteAdjustment >\n 256 * 1024\n )\n throw new Error(\"Evidence exceeds the Cloud limit of 256 KiB.\");\n return result;\n}\n\nexport function validateImportRequest(input: unknown): FindingImportRequest {\n const result = request(input);\n if (\n new Set(result.items.map((item) => item.client_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate client IDs.\");\n if (\n new Set(result.items.map((item) => item.source_finding_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate source finding identities.\");\n for (const item of result.items) validateExternalEvidence(item.evidence);\n if (Buffer.byteLength(JSON.stringify(result)) > 5 * 1024 * 1024)\n throw new Error(\"Import exceeds the Cloud limit of 5 MiB.\");\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-import-contract.js","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,MAAM,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAUpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC;IACtB,MAAM,EAAE,KAAK;IACb,eAAe,EAAE,KAAK;IACtB,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAKH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAc,EAAE,EAAE,CAC7C,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,C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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QACxD,MAAM,CAAC,KAAK,CAAC,MAAM;QAEnB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,IACE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;QAChE,MAAM,CAAC,KAAK,CAAC,MAAM;QAEnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;QAAE,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI;QAC7D,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { isIP } from \"node:net\";\nimport { isNumberObject } from \"node:util/types\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport schema from \"../schemas/external-findings.schema.json\" with { type: \"json\" };\nimport type {\n ExternalFindingEvidence,\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepositoryPage,\n SourceReportPage,\n SourceReport,\n} from \"./external-import-models.js\";\n\nconst ajv = new Ajv2020({\n strict: false,\n validateFormats: false,\n useDefaults: true,\n});\n\n/** Local storage accepts complete evidence; Cloud publication has payload limits. */\nexport type ExternalImportTarget = \"local\" | \"cloud\";\n\nconst localSchema = JSON.parse(\n JSON.stringify(schema, (key, value: unknown) =>\n key === \"maxLength\" || key === \"maxItems\" ? undefined : value,\n ),\n) as typeof schema;\nconst STRING_BYTE_LIMITS: Readonly<Record<string, number>> = {\n description: 65536,\n snippet: 65536,\n remediation_instructions: 65536,\n expected: 65536,\n actual: 65536,\n file_url: 2048,\n path: 2048,\n url: 2048,\n manifest_path: 2048,\n client_id: 128,\n next: 4096,\n};\n\n/** Compare repository URLs without changing the retained vendor evidence.\n * GitHub repository paths are case-insensitive; unknown VCS hosts stay strict.\n * Keep protocols and explicit ports distinct, matching the Cloud URL contract. */\nexport function repositoryUrlKey(value: string): string {\n const normalized = value.replace(/\\/$/u, \"\").replace(/\\.git$/u, \"\");\n const parts = /^(https?):\\/\\/([^/?#]+)((?:\\/[^?#]*)?)((?:[?#].*)?)$/iu.exec(\n normalized,\n );\n if (!parts) return normalized;\n const authority = parts[2]!.toLowerCase();\n const hostname = authority.replace(/:\\d+$/u, \"\");\n const path =\n hostname === \"github.com\" || hostname.endsWith(\".ghe.com\")\n ? parts[3]!.toLowerCase()\n : parts[3]!;\n return `${parts[1]!.toLowerCase()}://${authority}${path}${parts[4]!}`;\n}\n\n// Cloud's import catalog contains GitHub repositories, including custom Enterprise\n// hosts. Match its case-insensitive URL identity without merging schemes or ports.\nexport function cloudRepositoryUrlKey(value: string): string {\n return repositoryUrlKey(value).toLowerCase();\n}\n\n// Cloud ImportModel applies these constraints to both requests and responses.\n// Its UTF-8 limits are not exported as JSON Schema character limits: even a\n// plain string field such as a receipt error message inherits the 512-byte bound.\nfunction validateModelStrings(\n input: unknown,\n target: ExternalImportTarget,\n): void {\n if (input === null || typeof input !== \"object\") return;\n if (Array.isArray(input)) {\n for (const item of input) validateModelStrings(item, target);\n return;\n }\n for (const [field, value] of Object.entries(input)) {\n if (field === \"source_data\") continue;\n if (typeof value === \"string\") {\n if (\n (!value.trim() && ![\"snippet\", \"expected\", \"actual\"].includes(field)) ||\n value.includes(\"\\0\")\n )\n throw new Error(\n `${field} must be nonempty and contain no NUL characters.`,\n );\n const limit = STRING_BYTE_LIMITS[field] ?? 512;\n if (target === \"cloud\" && Buffer.byteLength(value) > limit)\n throw new Error(\n `${field} exceeds its Cloud limit of ${limit} UTF-8 bytes.`,\n );\n } else if (\n Array.isArray(value) &&\n value.every((item) => typeof item === \"string\")\n ) {\n if (\n target === \"cloud\" &&\n value.some((item) => Buffer.byteLength(item) > 512)\n )\n throw new Error(\n `${field} entries exceed the Cloud limit of 512 UTF-8 bytes.`,\n );\n } else validateModelStrings(value, target);\n }\n}\n\ntype ModelSchema = {\n $ref?: string;\n anyOf?: ModelSchema[];\n properties?: Record<string, ModelSchema>;\n [key: string]: unknown;\n};\nconst detailValidators = new Map<string, ReturnType<typeof ajv.compile>>();\n\n/** AJV does not apply defaults through nullable anyOf references. Validate the\n * present detail objects directly against their generated model definitions so\n * sparse normalized inputs match the backend's serialized evidence. */\nfunction materializeDetailDefaults(\n value: unknown,\n fieldSchema: ModelSchema,\n target: ExternalImportTarget,\n): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value))\n return;\n const reference =\n fieldSchema.$ref ?? fieldSchema.anyOf?.find((branch) => branch.$ref)?.$ref;\n if (!reference) return;\n const name = reference.split(\"/\").at(-1)!;\n const modelSchema = target === \"local\" ? localSchema : schema;\n const definition: ModelSchema =\n modelSchema.$defs[name as keyof typeof schema.$defs]!;\n const key = `${target}:${reference}`;\n let check = detailValidators.get(key);\n if (!check) {\n check = ajv.compile({ $defs: modelSchema.$defs, $ref: reference });\n detailValidators.set(key, check);\n }\n if (!check(value))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n for (const [field, childSchema] of Object.entries(\n definition.properties ?? {},\n ))\n materializeDetailDefaults(\n (value as Record<string, unknown>)[field],\n childSchema,\n target,\n );\n}\n\nfunction normalizeEvidenceDetails(\n value: unknown,\n target: ExternalImportTarget,\n): void {\n if (value !== null && typeof value === \"object\") {\n const fields = value as Record<string, unknown>;\n // Cloud omits these new optional fields when null. Preserve every legacy\n // default so saved Wiz requests still replay the same evidence bytes.\n if (Array.isArray(fields[\"packages\"]))\n for (const value of fields[\"packages\"]) {\n if (\n value &&\n typeof value === \"object\" &&\n value[\"vulnerable_version_range\"] === null\n )\n delete value[\"vulnerable_version_range\"];\n }\n if (fields[\"details\"] === null) delete fields[\"details\"];\n else {\n const details = fields[\"details\"];\n if (details && typeof details === \"object\" && !Array.isArray(details))\n for (const field of [\"repository\", \"advisory\"])\n if ((details as Record<string, unknown>)[field] === null)\n delete (details as Record<string, unknown>)[field];\n materializeDetailDefaults(\n fields[\"details\"],\n schema.$defs.ImportedFindingEvidence.properties.details,\n target,\n );\n }\n }\n}\n\nfunction validator<T>(\n name: keyof typeof schema.$defs,\n target: ExternalImportTarget = \"cloud\",\n) {\n const check = ajv.compile<T>({\n $defs: (target === \"local\" ? localSchema : schema).$defs,\n $ref: `#/$defs/${name}`,\n });\n return (input: unknown): T => {\n if (name === \"ImportedFindingEvidence\")\n normalizeEvidenceDetails(input, target);\n else if (input && typeof input === \"object\") {\n if (name === \"SourceReport\" && \"evidence\" in input)\n normalizeEvidenceDetails(input.evidence, target);\n if (\n name === \"FindingImportRequest\" &&\n \"items\" in input &&\n Array.isArray(input.items)\n )\n for (const item of input.items)\n normalizeEvidenceDetails(item?.evidence, target);\n }\n if (!check(input))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n validateModelStrings(input, target);\n return input;\n };\n}\n\nconst evidence = validator<ExternalFindingEvidence>(\"ImportedFindingEvidence\");\nconst localEvidence = validator<ExternalFindingEvidence>(\n \"ImportedFindingEvidence\",\n \"local\",\n);\nconst request = validator<FindingImportRequest>(\"FindingImportRequest\");\nexport const validateImportReceipt = validator<FindingImportReceipt>(\n \"FindingImportReceipt\",\n);\nexport const validateRepositories = validator<ImportRepositoryPage>(\n \"ImportRepositoryPage\",\n);\nexport const validateSourceReports =\n validator<SourceReportPage>(\"SourceReportPage\");\nexport const validateSourceReport = validator<SourceReport>(\"SourceReport\");\n\nfunction requireJsonNumber(value: number, label: string): void {\n if (!Number.isFinite(value))\n throw new Error(`${label} must contain finite JSON numbers.`);\n if (Number.isInteger(value) && !Number.isSafeInteger(value))\n throw new Error(\n `${label} integers must be within JavaScript's safe integer range; export larger values as strings to preserve them exactly.`,\n );\n}\n\n/** Report metadata is retained in previews and receipts without Cloud evidence size limits. */\nexport function validateExternalReport(\n report: Record<string, unknown> | undefined,\n): void {\n if (report === undefined) return;\n JSON.stringify(report, (_key, value: unknown) => {\n if (isNumberObject(value)) value = +value;\n if (typeof value === \"number\") requireJsonNumber(value, \"Scanner report\");\n return value;\n });\n}\n\nexport function validateExternalEvidence(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindingEvidence {\n const result = (target === \"local\" ? localEvidence : evidence)(input);\n for (const location of result.locations ?? []) {\n const path = location.path.replaceAll(\"\\\\\", \"/\");\n if (\n path.startsWith(\"/\") ||\n /^[A-Za-z]:/.test(path) ||\n path.split(\"/\").includes(\"..\")\n )\n throw new Error(\"Locations must use repository-relative paths.\");\n }\n const details = result.details;\n if (details) {\n if (details.kind === \"advisory\") {\n if (!details.advisory)\n throw new Error(\"Advisory evidence requires its source context.\");\n if (details.advisory.source === \"global\" && details.repository)\n throw new Error(\n \"Global advisory evidence cannot claim a source repository.\",\n );\n if (details.advisory.source === \"repository\" && !details.repository)\n throw new Error(\n \"Repository advisory evidence requires its source repository.\",\n );\n } else {\n if (!details.repository)\n throw new Error(\n \"Repository finding evidence requires its source repository.\",\n );\n if (details.advisory)\n throw new Error(\"Advisory source context requires advisory evidence.\");\n }\n }\n const endLine = result.details?.code?.end_line;\n if (endLine !== null && endLine !== undefined) {\n const firstLine = result.locations?.[0]?.line;\n if (firstLine === null || firstLine === undefined || endLine < firstLine)\n throw new Error(\n \"The code end line requires a first source location line and cannot precede it.\",\n );\n }\n const urls = [\n result.url,\n result.details?.repository?.url,\n result.details?.file_url,\n ];\n for (const value of urls) {\n if (value === null || value === undefined) continue;\n const url = value\n .replace(/[\\t\\r\\n]/gu, \"\")\n .replace(/^[\\u0000-\\u0020]+/u, \"\");\n const authority = /^https?:\\/\\/([^/?#]+)/iu.exec(url)?.[1];\n const normalizedAuthority = (authority ?? \"\")\n .replace(/[@:#?]/gu, \"\")\n .normalize(\"NFKC\");\n let validHost = true;\n if (authority?.includes(\"[\") || authority?.includes(\"]\")) {\n const hostname = /^\\[([^\\]]+)\\](?::[\\s\\S]*)?$/u.exec(authority)?.[1];\n const [address, scope, extraScope] = (hostname ?? \"\").split(\"%\");\n // Cloud accepts scoped IPv6 and IPvFuture hosts in brackets.\n validHost =\n hostname !== undefined &&\n (/^v[a-fA-F0-9]+\\.[\\s\\S]+$/u.test(hostname) ||\n (isIP(address!) === 6 && scope !== \"\" && extraScope === undefined));\n }\n if (\n !authority ||\n authority.includes(\"@\") ||\n /[/?#@:]/u.test(normalizedAuthority) ||\n !validHost\n )\n throw new Error(\n \"Evidence URLs must be HTTP(S) links without credentials.\",\n );\n }\n validateExternalEvidenceJson(result, target);\n return result;\n}\n\n/** Return the validated Cloud wire size, or zero for local evidence. */\nexport function validateExternalEvidenceJson(\n input: unknown,\n target: ExternalImportTarget,\n additionalCloudBytes = 0,\n): number {\n // Local evidence still has to be serializable JSON, including acyclic source data.\n if (target === \"local\") JSON.stringify(input);\n let numericByteAdjustment = 0;\n const pending: [unknown, number][] = [[input, 0]];\n while (pending.length > 0) {\n const [value, depth] = pending.pop()!;\n if (target === \"cloud\" && depth > 20)\n throw new Error(\"Evidence exceeds the Cloud JSON depth limit of 20.\");\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value))\n pending.push([child, depth + 1]);\n } else if (typeof value === \"number\") {\n requireJsonNumber(value, \"Evidence\");\n const wire = JSON.stringify(value);\n // Cloud pads short exponents and formats small fractions scientifically.\n const cloud = (\n wire.includes(\".\") && Math.abs(value) < 1e-4\n ? value.toExponential()\n : wire\n ).replace(/e-(\\d)$/u, \"e-0$1\");\n numericByteAdjustment += cloud.length - wire.length;\n }\n }\n const bytes =\n target === \"cloud\"\n ? Buffer.byteLength(JSON.stringify(input)) +\n numericByteAdjustment +\n additionalCloudBytes\n : 0;\n if (bytes > 256 * 1024)\n throw new Error(\"Evidence exceeds the Cloud limit of 256 KiB.\");\n return bytes;\n}\n\nexport function validateImportRequest(input: unknown): FindingImportRequest {\n const result = request(input);\n if (\n new Set(result.items.map((item) => item.client_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate client IDs.\");\n if (\n new Set(result.items.map((item) => item.source_finding_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate source finding identities.\");\n for (const item of result.items) validateExternalEvidence(item.evidence);\n if (Buffer.byteLength(JSON.stringify(result)) > 5 * 1024 * 1024)\n throw new Error(\"Import exceeds the Cloud limit of 5 MiB.\");\n return result;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const externalImportsDisabledMessage = "External findings imports are disabled. Set CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 to enable them.";
|
|
2
|
+
export declare function externalImportsEnabled(environment?: NodeJS.ProcessEnv): boolean;
|
|
3
|
+
/** Preserve the selected flag while copying a caller's environment for a child. */
|
|
4
|
+
export declare function forwardExternalImportSetting<Value>(source: Record<string, Value | undefined>, child: Record<string, Value>): void;
|
|
5
|
+
export declare function requireExternalImports(environment?: NodeJS.ProcessEnv): void;
|
|
6
|
+
//# sourceMappingURL=external-imports-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-imports-feature.d.ts","sourceRoot":"","sources":["../src/external-imports-feature.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,8BAA8B,yGAA0E,CAAC;AA6BtH,wBAAgB,sBAAsB,CACpC,WAAW,GAAE,MAAM,CAAC,UAAwB,GAC3C,OAAO,CAET;AAED,mFAAmF;AACnF,wBAAgB,4BAA4B,CAAC,KAAK,EAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,SAAS,CAAC,EACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC3B,IAAI,CAUN;AAED,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,IAAI,CAI5E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CodexSecurityError } from "./errors.js";
|
|
2
|
+
const flag = "CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS";
|
|
3
|
+
export const externalImportsDisabledMessage = `External findings imports are disabled. Set ${flag}=1 to enable them.`;
|
|
4
|
+
function externalImportSetting(environment) {
|
|
5
|
+
const exact = environment[flag];
|
|
6
|
+
if (process.platform !== "win32")
|
|
7
|
+
return { key: flag, value: exact };
|
|
8
|
+
// A scan can override a case-insensitive process.env with its own spelling.
|
|
9
|
+
function callerDeclares(key) {
|
|
10
|
+
for (let owner = environment; owner && owner !== process.env; owner = Object.getPrototypeOf(owner)) {
|
|
11
|
+
if (Object.hasOwn(owner, key))
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (exact !== undefined && callerDeclares(flag))
|
|
17
|
+
return { key: flag, value: exact };
|
|
18
|
+
// Node includes enumerable prototype keys and sorts competing spellings.
|
|
19
|
+
const keys = [];
|
|
20
|
+
for (const name in environment) {
|
|
21
|
+
if (name.toUpperCase() === flag)
|
|
22
|
+
keys.push(name);
|
|
23
|
+
}
|
|
24
|
+
keys.sort();
|
|
25
|
+
const key = keys.find(callerDeclares) ?? keys[0];
|
|
26
|
+
if (key !== undefined)
|
|
27
|
+
return { key, value: key === flag ? exact : environment[key] };
|
|
28
|
+
}
|
|
29
|
+
export function externalImportsEnabled(environment = process.env) {
|
|
30
|
+
return externalImportSetting(environment)?.value === "1";
|
|
31
|
+
}
|
|
32
|
+
/** Preserve the selected flag while copying a caller's environment for a child. */
|
|
33
|
+
export function forwardExternalImportSetting(source, child) {
|
|
34
|
+
const selected = externalImportSetting(source);
|
|
35
|
+
if (selected === undefined)
|
|
36
|
+
return;
|
|
37
|
+
if (process.platform === "win32") {
|
|
38
|
+
for (const name of Object.keys(child)) {
|
|
39
|
+
if (name !== selected.key && name.toUpperCase() === flag)
|
|
40
|
+
delete child[name];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (selected.value !== undefined)
|
|
44
|
+
child[selected.key] = selected.value;
|
|
45
|
+
}
|
|
46
|
+
export function requireExternalImports(environment) {
|
|
47
|
+
if (!externalImportsEnabled(environment)) {
|
|
48
|
+
throw new CodexSecurityError(externalImportsDisabledMessage);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=external-imports-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-imports-feature.js","sourceRoot":"","sources":["../src/external-imports-feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,IAAI,GAAG,wCAAwC,CAAC;AACtD,MAAM,CAAC,MAAM,8BAA8B,GAAG,+CAA+C,IAAI,oBAAoB,CAAC;AAEtH,SAAS,qBAAqB,CAAQ,WAAkC;IACtE,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACrE,4EAA4E;IAC5E,SAAS,cAAc,CAAC,GAAW;QACjC,KACE,IAAI,KAAK,GAAkB,WAAW,EACtC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,GAAG,EAC9B,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EACpC,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,cAAc,CAAC,IAAI,CAAC;QAC7C,OAAO,EAAE,GAAG,EAAE,I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AAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,WAA+B;IACpE,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAAC,8BAA8B,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import { CodexSecurityError } from \"./errors.js\";\n\nconst flag = \"CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS\";\nexport const externalImportsDisabledMessage = `External findings imports are disabled. Set ${flag}=1 to enable them.`;\n\nfunction externalImportSetting<Value>(environment: Record<string, Value>) {\n const exact = environment[flag];\n if (process.platform !== \"win32\") return { key: flag, value: exact };\n // A scan can override a case-insensitive process.env with its own spelling.\n function callerDeclares(key: string): boolean {\n for (\n let owner: object | null = environment;\n owner && owner !== process.env;\n owner = Object.getPrototypeOf(owner)\n ) {\n if (Object.hasOwn(owner, key)) return true;\n }\n return false;\n }\n if (exact !== undefined && callerDeclares(flag))\n return { key: flag, value: exact };\n // Node includes enumerable prototype keys and sorts competing spellings.\n const keys: string[] = [];\n for (const name in environment) {\n if (name.toUpperCase() === flag) keys.push(name);\n }\n keys.sort();\n const key = keys.find(callerDeclares) ?? keys[0];\n if (key !== undefined)\n return { key, value: key === flag ? exact : environment[key] };\n}\n\nexport function externalImportsEnabled(\n environment: NodeJS.ProcessEnv = process.env,\n): boolean {\n return externalImportSetting(environment)?.value === \"1\";\n}\n\n/** Preserve the selected flag while copying a caller's environment for a child. */\nexport function forwardExternalImportSetting<Value>(\n source: Record<string, Value | undefined>,\n child: Record<string, Value>,\n): void {\n const selected = externalImportSetting(source);\n if (selected === undefined) return;\n if (process.platform === \"win32\") {\n for (const name of Object.keys(child)) {\n if (name !== selected.key && name.toUpperCase() === flag)\n delete child[name];\n }\n }\n if (selected.value !== undefined) child[selected.key] = selected.value;\n}\n\nexport function requireExternalImports(environment?: NodeJS.ProcessEnv): void {\n if (!externalImportsEnabled(environment)) {\n throw new CodexSecurityError(externalImportsDisabledMessage);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JsonObject } from "./config.js";
|
|
2
|
+
import type { LoadedContract } from "./contract.js";
|
|
2
3
|
import type { FindingSearchScope } from "./finding-retrieval.js";
|
|
3
|
-
import { runWorkbench } from "./runtime.js";
|
|
4
|
+
import { runWorkbench, type WorkbenchCommandOptions } from "./runtime.js";
|
|
4
5
|
export type WorkflowStage = "scan" | "publish" | "dedupe";
|
|
5
6
|
export interface WorkflowBinding {
|
|
6
7
|
repositoryPath?: string;
|
|
@@ -28,7 +29,14 @@ export interface DedupePendingWrite {
|
|
|
28
29
|
gitDisabled?: boolean;
|
|
29
30
|
};
|
|
30
31
|
}
|
|
32
|
+
interface SourceSnapshotOptions {
|
|
33
|
+
optional?: boolean;
|
|
34
|
+
gitDisabled?: boolean;
|
|
35
|
+
privateStatePaths?: readonly string[];
|
|
36
|
+
evidence?: boolean;
|
|
37
|
+
}
|
|
31
38
|
export declare function workflowDigest(value: unknown): string;
|
|
39
|
+
export declare function scanArtifactDigest({ manifest, findings, review, }: Pick<LoadedContract, "manifest" | "findings" | "review">): string;
|
|
32
40
|
export declare function workflowDestination(url: string): string;
|
|
33
41
|
/** State lives in the workbench database, never in sealed scan artifacts. */
|
|
34
42
|
export declare class FindingWorkflow {
|
|
@@ -36,9 +44,12 @@ export declare class FindingWorkflow {
|
|
|
36
44
|
private readonly environment;
|
|
37
45
|
private readonly workbench;
|
|
38
46
|
private readonly pythonPath?;
|
|
39
|
-
private readonly
|
|
47
|
+
private readonly selection;
|
|
40
48
|
private options?;
|
|
41
|
-
constructor(id: string, environment?: NodeJS.ProcessEnv, workbench?: typeof runWorkbench, pythonPath?: string | undefined,
|
|
49
|
+
constructor(id: string, environment?: NodeJS.ProcessEnv, workbench?: typeof runWorkbench, pythonPath?: string | undefined, selection?: {
|
|
50
|
+
protectedRoot?: string;
|
|
51
|
+
workbenchOptions?: WorkbenchCommandOptions;
|
|
52
|
+
});
|
|
42
53
|
protectArtifacts(scanDir: string): Promise<void>;
|
|
43
54
|
get(): Promise<WorkflowState | null>;
|
|
44
55
|
bind(binding: WorkflowBinding): Promise<WorkflowState>;
|
|
@@ -47,12 +58,20 @@ export declare class FindingWorkflow {
|
|
|
47
58
|
fail(stage: WorkflowStage, error: unknown, result?: unknown): Promise<void>;
|
|
48
59
|
run<T>(stage: WorkflowStage, operation: () => Promise<T>): Promise<T>;
|
|
49
60
|
registeredScan(scanId: string): Promise<JsonObject>;
|
|
50
|
-
sourceSnapshot(repository: string,
|
|
61
|
+
sourceSnapshot(repository: string, options?: SourceSnapshotOptions & {
|
|
62
|
+
optional?: false;
|
|
63
|
+
}): Promise<JsonObject>;
|
|
64
|
+
sourceSnapshot(repository: string, options: SourceSnapshotOptions & {
|
|
65
|
+
optional: true;
|
|
66
|
+
}): Promise<JsonObject | null>;
|
|
51
67
|
getReview(key: string): Promise<unknown>;
|
|
52
|
-
saveReview(key: string, binding: object, result: unknown
|
|
68
|
+
saveReview(key: string, binding: object, result: unknown, options?: {
|
|
69
|
+
replace?: boolean;
|
|
70
|
+
}): Promise<void>;
|
|
53
71
|
prepareDedupe(result: unknown, pendingWrite: DedupePendingWrite): Promise<void>;
|
|
54
72
|
private command;
|
|
55
73
|
private request;
|
|
56
74
|
private call;
|
|
57
75
|
}
|
|
76
|
+
export {};
|
|
58
77
|
//# sourceMappingURL=finding-workflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finding-workflow.d.ts","sourceRoot":"","sources":["../src/finding-workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"finding-workflow.d.ts","sourceRoot":"","sources":["../src/finding-workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OA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