@openai/codex-security 0.8.1 → 0.8.3
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 +45 -57
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +1 -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 +4 -4
- 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/linux-x64-musl/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/permission-profile-preflight.mjs +46 -12
- 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/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +28 -0
- package/_bundled_plugin/references/finding-detail-fields.md +1 -0
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
- package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
- package/_bundled_plugin/scripts/finding_preview.py +5 -29
- package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
- package/_bundled_plugin/scripts/report_projection.py +87 -136
- package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
- package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
- package/_bundled_plugin/scripts/workbench_cli.py +102 -13
- package/_bundled_plugin/scripts/workbench_constants.py +9 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
- package/_bundled_plugin/scripts/workbench_db.py +187 -363
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
- package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
- package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
- package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
- package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
- package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_setup.py +239 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
- package/_bundled_plugin/scripts/workbench_target.py +120 -35
- package/_bundled_plugin/scripts/workbench_validation.py +1 -9
- package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
- package/_bundled_plugin/shared/workbench-migrations.json +19 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +68 -35
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
- package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
- package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
- package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +569 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +414 -163
- package/dist/api.js.map +1 -1
- package/dist/auth.js +7 -2
- package/dist/auth.js.map +1 -1
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +305 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-severity-records.d.ts +5 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +6 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +28 -9
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +635 -266
- package/dist/cli.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +6 -5
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +162 -40
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +157 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +28 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +75 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +1 -4
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +19 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2120 -39
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +6 -2
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +12 -5
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +3 -8
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +11 -3
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +48 -16
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deep-scan.d.ts +11 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +235 -4
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +44 -89
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +11 -15
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +12 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +411 -184
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +15 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +1238 -226
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +10 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +71 -51
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +13 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +124 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +29 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +314 -44
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/finding-normalization.d.ts +1 -1
- package/dist/finding-normalization.d.ts.map +1 -1
- package/dist/finding-normalization.js +46 -11
- package/dist/finding-normalization.js.map +1 -1
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -29
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +7 -16
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +344 -56
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +7 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +27 -3
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +55 -33
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts +9 -0
- package/dist/inspector-findings.d.ts.map +1 -0
- package/dist/inspector-findings.js +512 -0
- package/dist/inspector-findings.js.map +1 -0
- package/dist/knowledge-base.js +18 -5
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +131 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +22 -12
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +34 -20
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/patch-tui.d.ts +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +94 -36
- package/dist/patch-tui.js.map +1 -1
- package/dist/private-finding-import.d.ts +246 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +387 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +10 -2
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +72 -10
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/reader-selection.d.ts +13 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +81 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +5 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +30 -0
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +2 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +5 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +110 -57
- package/dist/runtime.js.map +1 -1
- package/dist/scan-activity.js +40 -17
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +11 -13
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +37 -48
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +2 -0
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +22 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +5 -5
- package/dist/scan-logs.js.map +1 -1
- package/dist/scanner-import.d.ts +48 -3
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +214 -39
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +14 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +67 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +50 -88
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +12 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +198 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +97 -106
- package/dist/snyk-findings.js.map +1 -1
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +383 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +279 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +3 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +18 -12
- package/dist/targets.js.map +1 -1
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +0 -16
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +7 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +371 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -0
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +10 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +88 -49
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +1 -1
- package/docs/cli.md +320 -481
- package/docs/dedupe-records.md +27 -4
- package/docs/findings-service.md +21 -8
- package/docs/hosted-scans.md +16 -1
- package/package.json +9 -10
- package/schemas/external-findings.schema.json +12 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -35
- package/dist/deduplication/records-protocol.js.map +0 -1
package/dist/github-findings.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { hash } from "node:crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { isBoxedPrimitive, isDate, isProxy } from "node:util/types";
|
|
2
4
|
import { GHSA_ID, githubRepositoryParts } from "./github-identifiers.js";
|
|
3
5
|
import { CodexSecurityError, errorMessage } from "./errors.js";
|
|
4
|
-
import { validateExternalEvidence } from "./external-import-contract.js";
|
|
6
|
+
import { CloudEvidenceDepthError, exportedGitHubRecord, previousGitHubExclusion, validateExternalEvidenceFields, validateExternalEvidenceJson, validateExternalEvidence, } from "./external-import-contract.js";
|
|
5
7
|
import { isGitHubDependabotAlert, normalizeGitHubDependabotAlerts, } from "./github-dependabot-findings.js";
|
|
8
|
+
import { asRecord, canSnapshotWithoutGetters, cloneWithoutGetters, } from "./record.js";
|
|
6
9
|
import { parseJsonOrJsonl, readScannerText, text } from "./scanner-import.js";
|
|
7
|
-
|
|
8
|
-
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
9
|
-
? value
|
|
10
|
-
: undefined;
|
|
11
|
-
}
|
|
10
|
+
import { rememberPreviousSelection, } from "./reader-selection.js";
|
|
12
11
|
function repositoryName(value) {
|
|
13
12
|
const repository = text(value);
|
|
14
13
|
if (!repository || !githubRepositoryParts(repository))
|
|
@@ -38,9 +37,16 @@ function severity(value) {
|
|
|
38
37
|
? value
|
|
39
38
|
: "unknown";
|
|
40
39
|
}
|
|
41
|
-
function
|
|
40
|
+
function codeScanningPrefix({ parsed, host }, repository, number) {
|
|
41
|
+
const name = repository.toLowerCase();
|
|
42
|
+
const path = parsed.pathname.toLowerCase();
|
|
43
|
+
const alert = `code-scanning/${number}`;
|
|
44
|
+
if (path === `/${name}/${alert}` || path === `/${name}/security/${alert}`)
|
|
45
|
+
return `${host}/${name}/${alert}/`;
|
|
46
|
+
}
|
|
47
|
+
function codeScanningFinding(record) {
|
|
42
48
|
const repository = repositoryName(record["repository"]);
|
|
43
|
-
const alert =
|
|
49
|
+
const alert = asRecord(record["alert"]);
|
|
44
50
|
const number = record["number"];
|
|
45
51
|
if (!alert ||
|
|
46
52
|
typeof number !== "number" ||
|
|
@@ -51,18 +57,18 @@ function codeScanningFinding(record, target = "cloud") {
|
|
|
51
57
|
const url = text(record["url"]);
|
|
52
58
|
if (!url || url !== alert["html_url"])
|
|
53
59
|
throw new Error("GitHub alert URL must match the original alert.");
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
const link = sourceUrl(url);
|
|
61
|
+
const prefix = codeScanningPrefix(link, repository, number);
|
|
62
|
+
if (!prefix)
|
|
57
63
|
throw new Error("GitHub alert URL does not match the selected repository and alert.");
|
|
58
|
-
const rule =
|
|
59
|
-
const instance =
|
|
64
|
+
const rule = asRecord(alert["rule"]);
|
|
65
|
+
const instance = asRecord(alert["most_recent_instance"]);
|
|
60
66
|
const ref = text(instance?.["ref"]);
|
|
61
67
|
if (!ref)
|
|
62
68
|
throw new Error("GitHub code-scanning evidence requires the selected instance ref.");
|
|
63
|
-
const location =
|
|
64
|
-
const tool =
|
|
65
|
-
const message = text(
|
|
69
|
+
const location = asRecord(instance?.["location"]);
|
|
70
|
+
const tool = asRecord(alert["tool"]);
|
|
71
|
+
const message = text(asRecord(instance?.["message"])?.["text"]);
|
|
66
72
|
const description = text(rule?.["full_description"]) ?? text(rule?.["description"]);
|
|
67
73
|
const tags = Array.isArray(rule?.["tags"]) ? rule["tags"] : [];
|
|
68
74
|
const weaknessIds = [
|
|
@@ -74,10 +80,9 @@ function codeScanningFinding(record, target = "cloud") {
|
|
|
74
80
|
})),
|
|
75
81
|
];
|
|
76
82
|
const path = text(location?.["path"]);
|
|
77
|
-
const sourceId = `${host}/${repository.toLowerCase()}/code-scanning/${number}/${hash("sha256", ref)}`;
|
|
78
83
|
return {
|
|
79
|
-
source_finding_id:
|
|
80
|
-
evidence:
|
|
84
|
+
source_finding_id: prefix + hash("sha256", ref),
|
|
85
|
+
evidence: {
|
|
81
86
|
title: text(rule?.["name"]) ??
|
|
82
87
|
text(rule?.["description"]) ??
|
|
83
88
|
`GitHub code-scanning alert #${number}`,
|
|
@@ -85,9 +90,7 @@ function codeScanningFinding(record, target = "cloud") {
|
|
|
85
90
|
description: [...new Set([message, description].filter(Boolean))].join("\n\n") ||
|
|
86
91
|
null,
|
|
87
92
|
url,
|
|
88
|
-
locations: path
|
|
89
|
-
? [{ path, line: location?.["start_line"] ?? null }]
|
|
90
|
-
: [],
|
|
93
|
+
locations: path ? [{ path, line: location?.["start_line"] ?? null }] : [],
|
|
91
94
|
branch: ref,
|
|
92
95
|
code_revision: text(instance?.["commit_sha"]),
|
|
93
96
|
source_updated_at: sourceTimestamp(alert["updated_at"]),
|
|
@@ -95,7 +98,7 @@ function codeScanningFinding(record, target = "cloud") {
|
|
|
95
98
|
details: {
|
|
96
99
|
kind: "sast",
|
|
97
100
|
repository: {
|
|
98
|
-
url: `${origin}/${repository}`,
|
|
101
|
+
url: `${link.origin}/${repository}`,
|
|
99
102
|
name: repository,
|
|
100
103
|
},
|
|
101
104
|
// Dismissal covers every branch; detection state belongs to the selected ref.
|
|
@@ -108,12 +111,15 @@ function codeScanningFinding(record, target = "cloud") {
|
|
|
108
111
|
remediation_instructions: text(rule?.["help"]),
|
|
109
112
|
code: path ? { end_line: location?.["end_line"] ?? null } : null,
|
|
110
113
|
},
|
|
111
|
-
},
|
|
114
|
+
},
|
|
112
115
|
};
|
|
113
116
|
}
|
|
114
|
-
function
|
|
117
|
+
function advisorySourceId(host, selection, repository, id) {
|
|
118
|
+
return `${host}/${selection === "repository" ? repository.toLowerCase() : "global"}/security-advisory/${id.toUpperCase()}`;
|
|
119
|
+
}
|
|
120
|
+
function advisoryFinding(record) {
|
|
115
121
|
const repository = repositoryName(record["repository"]);
|
|
116
|
-
const advisory =
|
|
122
|
+
const advisory = asRecord(record["advisory"]);
|
|
117
123
|
const id = text(record["ghsaId"]);
|
|
118
124
|
const selection = record["selection"];
|
|
119
125
|
if (!advisory ||
|
|
@@ -146,11 +152,11 @@ function advisoryFinding(record, target = "cloud") {
|
|
|
146
152
|
const advisoryIds = [
|
|
147
153
|
id,
|
|
148
154
|
text(advisory["cve_id"]),
|
|
149
|
-
...identifiers.map((identifier) => text(
|
|
155
|
+
...identifiers.map((identifier) => text(asRecord(identifier)?.["value"])),
|
|
150
156
|
].filter((value) => value !== null);
|
|
151
157
|
const packages = vulnerabilities.flatMap((value) => {
|
|
152
|
-
const vulnerability =
|
|
153
|
-
const pkg =
|
|
158
|
+
const vulnerability = asRecord(value);
|
|
159
|
+
const pkg = asRecord(vulnerability?.["package"]);
|
|
154
160
|
const name = text(pkg?.["name"]);
|
|
155
161
|
// GitHub permits incomplete package metadata in advisory disclosures.
|
|
156
162
|
// Preserve it in source_data without inventing a typed package identity.
|
|
@@ -169,8 +175,8 @@ function advisoryFinding(record, target = "cloud") {
|
|
|
169
175
|
});
|
|
170
176
|
const cwes = Array.isArray(advisory["cwes"]) ? advisory["cwes"] : [];
|
|
171
177
|
return {
|
|
172
|
-
source_finding_id:
|
|
173
|
-
evidence:
|
|
178
|
+
source_finding_id: advisorySourceId(host, selection, repository, id),
|
|
179
|
+
evidence: {
|
|
174
180
|
title: text(advisory["summary"]) ?? id,
|
|
175
181
|
severity: severity(advisory["severity"]),
|
|
176
182
|
description: text(advisory["description"]),
|
|
@@ -196,55 +202,337 @@ function advisoryFinding(record, target = "cloud") {
|
|
|
196
202
|
(selection === "global" ? "published" : null)),
|
|
197
203
|
scanner_origin: "GitHub Security Advisories",
|
|
198
204
|
weakness_ids: cwes
|
|
199
|
-
.map((value) => text(
|
|
205
|
+
.map((value) => text(asRecord(value)?.["cwe_id"]))
|
|
200
206
|
.filter((value) => value !== null),
|
|
201
207
|
},
|
|
202
|
-
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function mapRecord(input) {
|
|
212
|
+
const record = asRecord(input);
|
|
213
|
+
if (!record)
|
|
214
|
+
throw new Error("GitHub finding must be an object.");
|
|
215
|
+
if (record["source"] === "github-code-scanning")
|
|
216
|
+
return codeScanningFinding(record);
|
|
217
|
+
if (record["source"] === "github-security-advisory")
|
|
218
|
+
return advisoryFinding(record);
|
|
219
|
+
throw new Error("Expected saved output from import github or import github-advisories; raw or incomplete API responses need an explicit mapping.");
|
|
220
|
+
}
|
|
221
|
+
function ownData(value, key) {
|
|
222
|
+
if (value && typeof value === "object" && !isProxy(value))
|
|
223
|
+
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
224
|
+
}
|
|
225
|
+
function priorAdvisoryId(value) {
|
|
226
|
+
if (ownData(value, "source") !== "github-security-advisory")
|
|
227
|
+
return;
|
|
228
|
+
const id = text(ownData(value, "ghsaId"));
|
|
229
|
+
const host = text(ownData(value, "githubHost"))?.toLowerCase();
|
|
230
|
+
const selection = ownData(value, "selection");
|
|
231
|
+
const repository = text(ownData(value, "repository"));
|
|
232
|
+
if (id &&
|
|
233
|
+
GHSA_ID.test(id) &&
|
|
234
|
+
host &&
|
|
235
|
+
repository &&
|
|
236
|
+
githubRepositoryParts(repository) &&
|
|
237
|
+
(selection === "repository" || selection === "global"))
|
|
238
|
+
return advisorySourceId(host, selection, repository, id);
|
|
239
|
+
}
|
|
240
|
+
// Determine whether JSON can call a serializer without evaluating a getter.
|
|
241
|
+
function maySerialize(value) {
|
|
242
|
+
while (value && typeof value === "object") {
|
|
243
|
+
if (isProxy(value))
|
|
244
|
+
return true;
|
|
245
|
+
const field = Object.getOwnPropertyDescriptor(value, "toJSON");
|
|
246
|
+
if (field)
|
|
247
|
+
return (!Object.hasOwn(field, "value") || typeof field.value === "function");
|
|
248
|
+
value = Object.getPrototypeOf(value);
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
function codeOccurrencePrefix(value) {
|
|
253
|
+
const repository = ownData(value, "repository"), number = ownData(value, "number"), url = ownData(value, "url");
|
|
254
|
+
if (ownData(value, "source") !== "github-code-scanning" ||
|
|
255
|
+
typeof repository !== "string" ||
|
|
256
|
+
!githubRepositoryParts(repository) ||
|
|
257
|
+
typeof number !== "number" ||
|
|
258
|
+
!Number.isSafeInteger(number) ||
|
|
259
|
+
number <= 0 ||
|
|
260
|
+
typeof url !== "string")
|
|
261
|
+
return;
|
|
262
|
+
try {
|
|
263
|
+
return codeScanningPrefix(sourceUrl(url), repository, number);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
/* No validated occurrence anchor. */
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// The released reader measured the caller's source_data JSON before native capture.
|
|
270
|
+
function captureGitHubRecord(input, target) {
|
|
271
|
+
// Only plain records, arrays and standard Buffers have a reconstructable wire size.
|
|
272
|
+
let plainBuffers = [];
|
|
273
|
+
let hiddenFields = false;
|
|
274
|
+
let largeLocalRow = false;
|
|
275
|
+
const record = cloneWithoutGetters(input, (value) => {
|
|
276
|
+
const prototype = Object.getPrototypeOf(value);
|
|
277
|
+
if (target === "local" &&
|
|
278
|
+
((Array.isArray(value) && value.length > 256 * 1024) ||
|
|
279
|
+
(prototype === Buffer.prototype &&
|
|
280
|
+
Buffer.isBuffer(value) &&
|
|
281
|
+
!Object.hasOwn(value, "byteLength") &&
|
|
282
|
+
value.byteLength > 256 * 1024))) {
|
|
283
|
+
largeLocalRow = true;
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
// Native capture drops non-enumerable fields the released vendor mapper could read.
|
|
287
|
+
if (!Array.isArray(value) &&
|
|
288
|
+
!ArrayBuffer.isView(value) &&
|
|
289
|
+
!isBoxedPrimitive(value) &&
|
|
290
|
+
!isDate(value) &&
|
|
291
|
+
Object.getOwnPropertyNames(value).some((key) => key !== "toJSON" &&
|
|
292
|
+
!Object.prototype.propertyIsEnumerable.call(value, key)))
|
|
293
|
+
hiddenFields = true;
|
|
294
|
+
if (!plainBuffers)
|
|
295
|
+
return;
|
|
296
|
+
if (Buffer.isBuffer(value)) {
|
|
297
|
+
if (prototype === Buffer.prototype &&
|
|
298
|
+
!Object.hasOwn(value, "toJSON") &&
|
|
299
|
+
!Object.hasOwn(value, "length") &&
|
|
300
|
+
!("_arr" in value))
|
|
301
|
+
plainBuffers.push(value);
|
|
302
|
+
else
|
|
303
|
+
plainBuffers = undefined;
|
|
304
|
+
}
|
|
305
|
+
else if ((prototype !== Object.prototype &&
|
|
306
|
+
prototype !== null &&
|
|
307
|
+
prototype !== Array.prototype) ||
|
|
308
|
+
maySerialize(value))
|
|
309
|
+
plainBuffers = undefined;
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
record: asRecord(record),
|
|
313
|
+
hiddenFields,
|
|
314
|
+
plainBuffers,
|
|
315
|
+
largeLocalRow,
|
|
203
316
|
};
|
|
204
317
|
}
|
|
205
|
-
function normalizeRecords(records, target = "cloud") {
|
|
318
|
+
function normalizeRecords(records, target = "cloud", snapshot = false) {
|
|
206
319
|
const result = {
|
|
207
320
|
read: records.length,
|
|
208
321
|
findings: [],
|
|
209
322
|
excluded: [],
|
|
210
323
|
};
|
|
324
|
+
const previous = snapshot
|
|
325
|
+
? { read: records.length, findings: [], excluded: [] }
|
|
326
|
+
: undefined;
|
|
327
|
+
const checks = [];
|
|
328
|
+
const uncertainIds = new Set();
|
|
329
|
+
const unidentifiedRows = new Set();
|
|
330
|
+
let independentlyObserved = Infinity;
|
|
331
|
+
let ranRootSerializer = false;
|
|
332
|
+
let largeLocalSelection = false;
|
|
333
|
+
const potentialIds = [];
|
|
334
|
+
const prefixes = new Set();
|
|
211
335
|
const identities = new Set();
|
|
212
|
-
for (const [index,
|
|
213
|
-
const
|
|
336
|
+
for (const [index, input] of records.entries()) {
|
|
337
|
+
const afterRootSerializer = ranRootSerializer;
|
|
338
|
+
const keySensitive = previous !== undefined && maySerialize(input);
|
|
339
|
+
ranRootSerializer ||= keySensitive;
|
|
340
|
+
let exported = input;
|
|
341
|
+
const capture = previous ? captureGitHubRecord(input, target) : undefined;
|
|
342
|
+
const before = capture?.record;
|
|
343
|
+
const priorPrefix = previous ? codeOccurrencePrefix(input) : undefined;
|
|
344
|
+
let priorId = previous ? priorAdvisoryId(input) : undefined;
|
|
345
|
+
let prefix = priorPrefix;
|
|
346
|
+
const rowIds = new Set();
|
|
347
|
+
let rowUncertain = false;
|
|
348
|
+
const priorRowCount = previous?.findings.length ?? 0;
|
|
349
|
+
function possible() {
|
|
350
|
+
rowUncertain = true;
|
|
351
|
+
// A caller getter can mutate a later row before its native evidence is seen.
|
|
352
|
+
independentlyObserved = Math.min(independentlyObserved, priorRowCount);
|
|
353
|
+
for (const id of rowIds)
|
|
354
|
+
uncertainIds.add(id);
|
|
355
|
+
if (prefix)
|
|
356
|
+
prefixes.add(prefix);
|
|
357
|
+
if (priorId)
|
|
358
|
+
uncertainIds.add(priorId);
|
|
359
|
+
else if (!priorPrefix)
|
|
360
|
+
unidentifiedRows.add(index);
|
|
361
|
+
}
|
|
362
|
+
// The old reader called a root serializer with "source_data" rather than its
|
|
363
|
+
// array index. That code could change a later occurrence before it was read.
|
|
364
|
+
if (afterRootSerializer) {
|
|
365
|
+
possible();
|
|
366
|
+
unidentifiedRows.add(index);
|
|
367
|
+
}
|
|
368
|
+
function retainPrevious(selection, id, evidence) {
|
|
369
|
+
selection.findings.push({ source_finding_id: id, evidence });
|
|
370
|
+
potentialIds.push(id);
|
|
371
|
+
checks.push(() => {
|
|
372
|
+
if (!isDeepStrictEqual(before, asRecord(cloneWithoutGetters(input))))
|
|
373
|
+
possible();
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const exclusion = (record, reason) => ({
|
|
377
|
+
position: index + 1,
|
|
378
|
+
source_finding_id: text(asRecord(record)?.["url"]),
|
|
379
|
+
reason,
|
|
380
|
+
});
|
|
381
|
+
let possibleFreshId = false;
|
|
214
382
|
try {
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
383
|
+
if (previous && capture) {
|
|
384
|
+
const source = exportedGitHubRecord(input, index, target, target === "local" && !capture.largeLocalRow);
|
|
385
|
+
exported = source.record;
|
|
386
|
+
prefix ??= codeOccurrencePrefix(exported);
|
|
387
|
+
// A serializer or Buffer can expand a native record that fit the approved request.
|
|
388
|
+
const oversizedLocalRow = target === "local" &&
|
|
389
|
+
(capture.largeLocalRow ||
|
|
390
|
+
(source.bytes > 256 * 1024 &&
|
|
391
|
+
(!before || capture.plainBuffers?.length === 0)));
|
|
392
|
+
if (oversizedLocalRow || !before) {
|
|
393
|
+
if (!oversizedLocalRow &&
|
|
394
|
+
source.previousInvalid &&
|
|
395
|
+
!source.skippedRawValue &&
|
|
396
|
+
canSnapshotWithoutGetters(input)) {
|
|
397
|
+
previous.excluded.push(exclusion(exported, errorMessage(source.previousInvalid)));
|
|
398
|
+
}
|
|
399
|
+
else if (target !== "local" &&
|
|
400
|
+
source.bytes + source.adjustment > 256 * 1024 &&
|
|
401
|
+
canSnapshotWithoutGetters(input) &&
|
|
402
|
+
!keySensitive) {
|
|
403
|
+
previous.excluded.push(exclusion(exported, "Evidence exceeds the Cloud limit of 256 KiB."));
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
largeLocalSelection ||= oversizedLocalRow;
|
|
407
|
+
// An occurrence without independent native evidence can only stop a retry.
|
|
408
|
+
possible();
|
|
409
|
+
possibleFreshId = true;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
if (capture.hiddenFields || source.skippedRawValue)
|
|
414
|
+
possible();
|
|
415
|
+
try {
|
|
416
|
+
const row = mapRecord(before);
|
|
417
|
+
const knownOldId = row.source_finding_id;
|
|
418
|
+
priorId = knownOldId;
|
|
419
|
+
if (!afterRootSerializer)
|
|
420
|
+
unidentifiedRows.delete(index);
|
|
421
|
+
rowIds.add(knownOldId);
|
|
422
|
+
if (rowUncertain)
|
|
423
|
+
uncertainIds.add(knownOldId);
|
|
424
|
+
const evidence = validateExternalEvidenceFields(row.evidence, target);
|
|
425
|
+
if (source.previousInvalid)
|
|
426
|
+
throw source.previousInvalid;
|
|
427
|
+
if (keySensitive)
|
|
428
|
+
possible();
|
|
429
|
+
const reason = keySensitive || target === "local"
|
|
430
|
+
? undefined
|
|
431
|
+
: previousGitHubExclusion(evidence, source.bytes, source.adjustment);
|
|
432
|
+
if (reason)
|
|
433
|
+
previous.excluded.push(exclusion(before, reason));
|
|
434
|
+
else
|
|
435
|
+
retainPrevious(previous, knownOldId, evidence);
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
previous.excluded.push(exclusion(before, errorMessage(error)));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (source.invalid)
|
|
442
|
+
throw source.invalid;
|
|
443
|
+
}
|
|
444
|
+
const mapped = mapRecord(exported), id = mapped.source_finding_id;
|
|
445
|
+
rowIds.add(id);
|
|
446
|
+
if (rowUncertain)
|
|
447
|
+
uncertainIds.add(id);
|
|
448
|
+
if (possibleFreshId)
|
|
449
|
+
potentialIds.push(id);
|
|
450
|
+
const evidence = validateExternalEvidence(mapped.evidence, target);
|
|
451
|
+
if (identities.has(id))
|
|
452
|
+
throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(id)}. Select each GitHub occurrence once.`);
|
|
453
|
+
identities.add(id);
|
|
454
|
+
result.findings.push({ source_finding_id: id, evidence });
|
|
228
455
|
}
|
|
229
456
|
catch (error) {
|
|
230
457
|
if (error instanceof CodexSecurityError)
|
|
231
458
|
throw error;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
459
|
+
const reason = errorMessage(error);
|
|
460
|
+
result.excluded.push(exclusion(snapshot && exported === input
|
|
461
|
+
? { url: ownData(input, "url") }
|
|
462
|
+
: exported, reason));
|
|
463
|
+
if (previous && exported === input) {
|
|
464
|
+
if (error instanceof CloudEvidenceDepthError &&
|
|
465
|
+
before &&
|
|
466
|
+
// Extra Buffer fields were inspected by the old row validator, but
|
|
467
|
+
// structuredClone does not retain them as part of the typed array.
|
|
468
|
+
capture?.plainBuffers?.every((buffer) => Object.keys(buffer).length === buffer.length)) {
|
|
469
|
+
// Exported JSON can be deeper than an approved native snapshot.
|
|
470
|
+
// Retain only the independently observed, valid prior selection.
|
|
471
|
+
try {
|
|
472
|
+
const row = mapRecord(before);
|
|
473
|
+
const evidence = validateExternalEvidence(row.evidence, target);
|
|
474
|
+
const savedSource = JSON.stringify(evidence.source_data);
|
|
475
|
+
// structuredClone turns each Buffer into a Uint8Array. Reconstruct its
|
|
476
|
+
// original serialized size on detached data without running caller hooks.
|
|
477
|
+
const oldSource = JSON.stringify(evidence.source_data, (_key, value) => value instanceof Uint8Array
|
|
478
|
+
? { type: "Buffer", data: [...value] }
|
|
479
|
+
: value);
|
|
480
|
+
validateExternalEvidenceJson(evidence, target, Buffer.byteLength(oldSource) - Buffer.byteLength(savedSource));
|
|
481
|
+
retainPrevious(previous, row.source_finding_id, evidence);
|
|
482
|
+
}
|
|
483
|
+
catch (priorError) {
|
|
484
|
+
previous.excluded.push(exclusion(before, errorMessage(priorError)));
|
|
485
|
+
}
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
// A serializer may throw at its array key while the old source_data
|
|
489
|
+
// key produced a valid record. Keep only evidence for refusing a match.
|
|
490
|
+
possible();
|
|
491
|
+
if (before)
|
|
492
|
+
try {
|
|
493
|
+
const id = mapRecord(before).source_finding_id;
|
|
494
|
+
priorId = id;
|
|
495
|
+
if (!afterRootSerializer)
|
|
496
|
+
unidentifiedRows.delete(index);
|
|
497
|
+
potentialIds.push(id);
|
|
498
|
+
uncertainIds.add(id);
|
|
499
|
+
}
|
|
500
|
+
catch {
|
|
501
|
+
/* No old identity. */
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (previous) {
|
|
507
|
+
for (const check of checks)
|
|
508
|
+
check();
|
|
509
|
+
const uncertain = independentlyObserved !== Infinity;
|
|
510
|
+
if (uncertain || !isDeepStrictEqual(previous.findings, result.findings)) {
|
|
511
|
+
const prior = { sourceFindingIds: potentialIds };
|
|
512
|
+
if (uncertain) {
|
|
513
|
+
prior.unprovenIdPrefixes = [...prefixes];
|
|
514
|
+
prior.uncertainFindingIds = [...uncertainIds];
|
|
515
|
+
if (unidentifiedRows.size)
|
|
516
|
+
prior.unprovenOccurrenceCount = unidentifiedRows.size;
|
|
517
|
+
if (!largeLocalSelection)
|
|
518
|
+
prior.knownFindings = previous.findings
|
|
519
|
+
.slice(0, independentlyObserved)
|
|
520
|
+
.filter((finding) => !uncertainIds.has(finding.source_finding_id));
|
|
521
|
+
}
|
|
522
|
+
else
|
|
523
|
+
prior.snapshot = previous;
|
|
524
|
+
rememberPreviousSelection(result, prior);
|
|
237
525
|
}
|
|
238
526
|
}
|
|
239
527
|
return result;
|
|
240
528
|
}
|
|
241
529
|
/** Map selected code-scanning instances while retaining complete upstream evidence. */
|
|
242
530
|
export function normalizeGitHubCodeScanningAlerts(alerts, target = "cloud") {
|
|
243
|
-
return normalizeRecords(alerts, target);
|
|
531
|
+
return normalizeRecords(alerts, target, true);
|
|
244
532
|
}
|
|
245
533
|
/** Map advisory disclosures without asserting an installed vulnerable dependency. */
|
|
246
534
|
export function normalizeGitHubAdvisories(advisories, target = "cloud") {
|
|
247
|
-
return normalizeRecords(advisories, target);
|
|
535
|
+
return normalizeRecords(advisories, target, true);
|
|
248
536
|
}
|
|
249
537
|
/** Read unfiltered JSON/JSONL output saved by the read-only GitHub import commands. */
|
|
250
538
|
export async function readGitHubFindings(path, target = "cloud") {
|