@openai/codex-security 0.9.1 → 0.10.1
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 +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +3 -0
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- 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/server.mjs.br +0 -0
- package/_bundled_plugin/references/access-advisory.md +1 -1
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/final-report.md +1 -1
- package/_bundled_plugin/references/focused-investigator.md +13 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +30 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +47 -9
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +26 -1
- package/_bundled_plugin/scripts/snapshot_sqlite.py +8 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +216 -25
- package/_bundled_plugin/scripts/workbench/handoff.py +55 -25
- package/_bundled_plugin/scripts/workbench/storage.py +25 -5
- package/_bundled_plugin/scripts/workbench_cli.py +24 -2
- package/_bundled_plugin/scripts/workbench_constants.py +2 -0
- package/_bundled_plugin/scripts/workbench_db.py +257 -268
- package/_bundled_plugin/scripts/workbench_feedback.py +49 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +226 -29
- package/_bundled_plugin/scripts/workbench_progress.py +159 -3
- package/_bundled_plugin/scripts/workbench_publication.py +2 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +142 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +48 -8
- package/_bundled_plugin/scripts/workbench_scan_history.py +291 -134
- package/_bundled_plugin/scripts/workbench_scan_start.py +208 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +36 -10
- package/_bundled_plugin/scripts/workbench_schema.py +220 -14
- package/_bundled_plugin/scripts/workbench_setup.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +8 -0
- package/_bundled_plugin/scripts/workbench_target.py +486 -85
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +64 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +26 -160
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +2 -2
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +3 -58
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +459 -157
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +33 -12
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/blackduck-findings.d.ts +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +5 -18
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/classify-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-diagnostics.d.ts +10 -0
- package/dist/classify-severity-diagnostics.d.ts.map +1 -0
- package/dist/classify-severity-diagnostics.js +57 -0
- package/dist/classify-severity-diagnostics.js.map +1 -0
- package/dist/classify-severity-records.d.ts +4 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +35 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +9 -6
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +8 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1860 -903
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +33 -31
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -3
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +3 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +40 -7
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -1
- package/dist/config.js.map +1 -1
- package/dist/continuum-aws.d.ts +6 -0
- package/dist/continuum-aws.d.ts.map +1 -0
- package/dist/continuum-aws.js +202 -0
- package/dist/continuum-aws.js.map +1 -0
- package/dist/continuum-collector.d.ts +44 -0
- package/dist/continuum-collector.d.ts.map +1 -0
- package/dist/continuum-collector.js +266 -0
- package/dist/continuum-collector.js.map +1 -0
- package/dist/continuum-findings.d.ts +31 -2
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +497 -59
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -0
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -45
- package/dist/cost.js.map +1 -1
- package/dist/crowdstrike-findings.d.ts +7 -0
- package/dist/crowdstrike-findings.d.ts.map +1 -0
- package/dist/crowdstrike-findings.js +210 -0
- package/dist/crowdstrike-findings.js.map +1 -0
- 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 +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +3 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +8 -1
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +2 -1
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +16 -15
- package/dist/deep-scan.js.map +1 -1
- package/dist/endor-findings.d.ts +2 -2
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +6 -23
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +12 -1
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +66 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +258 -59
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +6 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +330 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +56 -53
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +1 -1
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +12 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +6 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +35 -177
- 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-prompt.d.ts.map +1 -1
- package/dist/finding-prompt.js +2 -2
- package/dist/finding-prompt.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +3 -4
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +19 -287
- package/dist/github-findings.js.map +1 -1
- package/dist/host-protocol.d.ts +6 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +11 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +2 -0
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +4 -0
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +19 -35
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +34 -27
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -4
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +4 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +83 -39
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts +4 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +39 -22
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/private-finding-import.d.ts +8 -13
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +69 -129
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +56 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +4 -9
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -1
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts +35 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +782 -153
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +6 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +267 -115
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts +20 -2
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +26 -5
- 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 +18 -2
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +4 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +25 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +28 -4
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +5 -11
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +16 -89
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +26 -6
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +14 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +20 -70
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +116 -333
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +1 -0
- package/dist/severity-review.js.map +1 -1
- package/dist/snyk-findings.d.ts +2 -0
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +5 -8
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +3 -20
- package/dist/snyk-rest-findings.d.ts.map +1 -1
- package/dist/snyk-rest-findings.js +45 -217
- package/dist/snyk-rest-findings.js.map +1 -1
- package/dist/sonar-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +28 -30
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +129 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/targets.d.ts +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +103 -23
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +1 -4
- package/dist/tenable-findings.d.ts.map +1 -1
- package/dist/tenable-findings.js.map +1 -1
- package/dist/trivy-findings.d.ts.map +1 -1
- package/dist/trivy-findings.js +0 -11
- package/dist/trivy-findings.js.map +1 -1
- package/dist/trusted-executable.d.ts +7 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +148 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.js +3 -1
- package/dist/value.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -3
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +13 -38
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +14 -92
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +30 -0
- package/docs/cli.md +537 -124
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +918 -0
- package/package.json +15 -6
- package/schemas/external-findings.schema.json +2 -1
- package/schemas/project-config.schema.json +5 -0
- package/dist/hosted-scanner-v1.d.ts +0 -6
- package/dist/hosted-scanner-v1.d.ts.map +0 -1
- package/dist/hosted-scanner-v1.js +0 -60
- package/dist/hosted-scanner-v1.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -15
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -89
- package/dist/reader-selection.js.map +0 -1
- package/dist/semgrep-platform-v1.d.ts +0 -6
- package/dist/semgrep-platform-v1.d.ts.map +0 -1
- package/dist/semgrep-platform-v1.js +0 -83
- package/dist/semgrep-platform-v1.js.map +0 -1
- package/dist/snyk-rest-v1.d.ts +0 -28
- package/dist/snyk-rest-v1.d.ts.map +0 -1
- package/dist/snyk-rest-v1.js +0 -132
- package/dist/snyk-rest-v1.js.map +0 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { hash } from "node:crypto";
|
|
1
2
|
import { CodexSecurityError } from "./errors.js";
|
|
2
|
-
import { DEFAULT_CLOUD_STRING_BYTES, validateEnrichedExternalEvidence, } from "./external-import-contract.js";
|
|
3
|
+
import { CLOUD_EVIDENCE_BYTES, CloudEvidenceSizeError, DEFAULT_CLOUD_STRING_BYTES, repositoryUrlKey, validateEnrichedExternalEvidence, validateExternalEvidence, validateExternalEvidenceJson, } from "./external-import-contract.js";
|
|
3
4
|
import { isRecord } from "./record.js";
|
|
4
|
-
import { array, awsTimestampSeconds, concreteVersion, normalizeRecords,
|
|
5
|
+
import { array, awsTimestampSeconds, concreteVersion, normalizeRecords, optionalArray, scannerJsonReader, record, repositoryFilePath, requiredText, strings, text, } from "./scanner-import.js";
|
|
5
6
|
import { declaredScannerRepositoryUrl, repositoryScopeValidator, } from "./scanner-repository-url.js";
|
|
6
7
|
const format = "aws-continuum-code-findings/v1";
|
|
8
|
+
export const continuumIssueFormat = "aws-continuum-code-issues/v1";
|
|
7
9
|
const findingArn = /^(arn:[a-z0-9-]+:continuum:[a-z0-9-]+:\d{12}:environments\/([a-z0-9]+))\/code-findings\/([a-z0-9]+)$/u;
|
|
8
|
-
|
|
10
|
+
const issueArn = /^(arn:[a-z0-9-]+:continuum:[a-z0-9-]+:\d{12}:environments\/([a-z0-9]+))\/code-issues\/([a-z0-9]+)$/u;
|
|
11
|
+
export function findingIdentity(value) {
|
|
9
12
|
const row = record(value, "Continuum finding");
|
|
10
13
|
const arn = requiredText(row["findingArn"], "Continuum finding ARN");
|
|
11
14
|
const match = findingArn.exec(arn);
|
|
@@ -13,12 +16,21 @@ function identity(value) {
|
|
|
13
16
|
row["environmentId"] !== match[2] ||
|
|
14
17
|
row["findingId"] !== match[3])
|
|
15
18
|
throw new Error("Expected a Continuum finding ARN matching its environmentId and findingId.");
|
|
16
|
-
return { arn, scope: match[1] };
|
|
19
|
+
return { arn, scope: match[1], id: match[3] };
|
|
20
|
+
}
|
|
21
|
+
export function issueIdentity(value) {
|
|
22
|
+
const issue = record(value, "Continuum issue");
|
|
23
|
+
const arn = requiredText(issue["issueArn"], "Continuum issue ARN");
|
|
24
|
+
const match = issueArn.exec(arn);
|
|
25
|
+
if (!match || issue["issueId"] !== match[3])
|
|
26
|
+
throw new Error("Expected a Continuum issue ARN matching its issueId.");
|
|
27
|
+
return { arn, scope: match[1], environmentId: match[2], id: match[3] };
|
|
17
28
|
}
|
|
18
29
|
function retainedRepository(provider, finding, target) {
|
|
19
30
|
const { source_finding_id: id, evidence: { source_data: data }, } = finding;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
31
|
+
const isIssue = data?.["format"] === continuumIssueFormat || issueArn.test(id);
|
|
32
|
+
const native = data?.[isIssue ? "issue" : "finding"];
|
|
33
|
+
const marked = isIssue || data?.["format"] === format;
|
|
22
34
|
const nativeArn = isRecord(native) && findingArn.test(text(native["findingArn"]) ?? "");
|
|
23
35
|
if (provider !== "continuum") {
|
|
24
36
|
if (marked ||
|
|
@@ -30,27 +42,55 @@ function retainedRepository(provider, finding, target) {
|
|
|
30
42
|
}
|
|
31
43
|
if (!marked && !nativeArn && !findingArn.test(id))
|
|
32
44
|
return;
|
|
33
|
-
const { arn, scope } =
|
|
45
|
+
const { arn, scope } = isIssue
|
|
46
|
+
? issueIdentity(native)
|
|
47
|
+
: findingIdentity(native);
|
|
34
48
|
if (arn !== id)
|
|
35
|
-
throw new Error(
|
|
49
|
+
throw new Error(`Continuum source finding ID does not match the retained ${isIssue ? "issue" : "finding"} ARN.`);
|
|
36
50
|
return {
|
|
37
51
|
url: declaredScannerRepositoryUrl(data?.["sourceRepositoryUrl"], "Continuum", target),
|
|
38
52
|
scope,
|
|
39
53
|
};
|
|
40
54
|
}
|
|
41
55
|
export const continuumReportRepositories = repositoryScopeValidator({ provider: "continuum", label: "AWS Continuum", scope: "environment" }, retainedRepository);
|
|
42
|
-
function
|
|
56
|
+
function findingVulnerabilities(row) {
|
|
57
|
+
return array(row["vulnerabilities"] ?? [], "Continuum vulnerabilities").map((item) => record(item, "Continuum vulnerability"));
|
|
58
|
+
}
|
|
59
|
+
function* findingCodeLocations(row, vulnerabilities) {
|
|
60
|
+
yield {
|
|
61
|
+
filePath: row["filePath"],
|
|
62
|
+
startLine: row["lineNumber"],
|
|
63
|
+
endLine: row["endLine"],
|
|
64
|
+
code: row["vulnerableCode"],
|
|
65
|
+
};
|
|
66
|
+
for (const vulnerability of vulnerabilities) {
|
|
67
|
+
for (const value of array(vulnerability["locations"] ?? [], "Continuum vulnerability locations")) {
|
|
68
|
+
const location = record(value, "Continuum vulnerability location");
|
|
69
|
+
yield {
|
|
70
|
+
filePath: location["filePath"],
|
|
71
|
+
startLine: location["startLine"],
|
|
72
|
+
endLine: location["endLine"],
|
|
73
|
+
code: vulnerability["code"],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function locationLine(value) {
|
|
79
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0
|
|
80
|
+
? value
|
|
81
|
+
: null;
|
|
82
|
+
}
|
|
83
|
+
function codeLocations(ranges) {
|
|
43
84
|
const locations = [];
|
|
44
85
|
const seen = new Set();
|
|
45
86
|
let endLine = null;
|
|
46
87
|
let snippet = null;
|
|
47
|
-
|
|
48
|
-
const path = repositoryFilePath(
|
|
88
|
+
for (const range of ranges) {
|
|
89
|
+
const path = repositoryFilePath(range.filePath);
|
|
49
90
|
if (!path)
|
|
50
|
-
|
|
51
|
-
const line =
|
|
52
|
-
|
|
53
|
-
: null;
|
|
91
|
+
continue;
|
|
92
|
+
const line = locationLine(range.startLine);
|
|
93
|
+
const end = locationLine(range.endLine);
|
|
54
94
|
const key = JSON.stringify([path, line]);
|
|
55
95
|
if (!seen.has(key)) {
|
|
56
96
|
seen.add(key);
|
|
@@ -58,38 +98,117 @@ function codeLocations(row, vulnerabilities) {
|
|
|
58
98
|
}
|
|
59
99
|
// The flat location and first nested location can describe the same range.
|
|
60
100
|
if (locations[0].path === path && locations[0].line === line) {
|
|
61
|
-
if (line !== null &&
|
|
62
|
-
typeof end === "number" &&
|
|
63
|
-
Number.isSafeInteger(end) &&
|
|
64
|
-
end >= line)
|
|
101
|
+
if (line !== null && end !== null && end >= line)
|
|
65
102
|
endLine ??= end;
|
|
66
|
-
snippet ??= text(
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
add(row["filePath"], row["lineNumber"], row["endLine"], row["vulnerableCode"]);
|
|
70
|
-
for (const vulnerability of vulnerabilities) {
|
|
71
|
-
for (const value of array(vulnerability["locations"] ?? [], "Continuum vulnerability locations")) {
|
|
72
|
-
const location = record(value, "Continuum vulnerability location");
|
|
73
|
-
add(location["filePath"], location["startLine"], location["endLine"], vulnerability["code"]);
|
|
103
|
+
snippet ??= text(range.code);
|
|
74
104
|
}
|
|
75
105
|
}
|
|
76
106
|
return { locations, code: { end_line: endLine, snippet } };
|
|
77
107
|
}
|
|
78
|
-
function reportRows(input
|
|
79
|
-
if (Array.isArray(input)
|
|
108
|
+
function reportRows(input) {
|
|
109
|
+
if (Array.isArray(input))
|
|
80
110
|
return { rows: input, summary: false };
|
|
81
111
|
const document = record(input, "Continuum report");
|
|
82
112
|
if (Object.hasOwn(document, "nextToken") ||
|
|
83
113
|
Object.hasOwn(document, "NextToken"))
|
|
84
114
|
throw new Error("Continuum export has a continuation token; supply the complete paginated CLI output.");
|
|
85
|
-
if (!("items" in document ||
|
|
86
|
-
|
|
115
|
+
if (!("items" in document ||
|
|
116
|
+
"findingArn" in document ||
|
|
117
|
+
"finding" in document))
|
|
118
|
+
throw new Error("Expected a Continuum ListCodeFindings, GetCodeFinding, or finding with artifacts.");
|
|
87
119
|
const summary = "items" in document;
|
|
88
120
|
return {
|
|
89
121
|
rows: summary ? array(document["items"], "Continuum items") : [document],
|
|
90
122
|
summary,
|
|
91
123
|
};
|
|
92
124
|
}
|
|
125
|
+
function isFindingCapture(value) {
|
|
126
|
+
return isRecord(value) && !("findingArn" in value) && "finding" in value;
|
|
127
|
+
}
|
|
128
|
+
export function readPatch(value) {
|
|
129
|
+
const artifact = record(value, "Continuum patch artifact");
|
|
130
|
+
const patch = requiredText(artifact["patch"], "Continuum patch content");
|
|
131
|
+
const sizeBytes = Buffer.byteLength(patch);
|
|
132
|
+
const patchSha256 = hash("sha256", patch);
|
|
133
|
+
if (artifact["sizeBytes"] !== sizeBytes ||
|
|
134
|
+
artifact["patchSha256"] !== patchSha256)
|
|
135
|
+
throw new Error("Continuum patch content does not match its sizeBytes or patchSha256.");
|
|
136
|
+
return {
|
|
137
|
+
artifactId: requiredText(artifact["artifactId"], "Continuum patch artifact ID"),
|
|
138
|
+
patch,
|
|
139
|
+
patchSha256,
|
|
140
|
+
sizeBytes,
|
|
141
|
+
...(artifact["format"] !== undefined && {
|
|
142
|
+
format: requiredText(artifact["format"], "Continuum patch format"),
|
|
143
|
+
}),
|
|
144
|
+
...(artifact["repositoryName"] !== undefined && {
|
|
145
|
+
repositoryName: requiredText(artifact["repositoryName"], "Continuum patch repository"),
|
|
146
|
+
}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function projectArtifactBodies(artifacts, target, project) {
|
|
150
|
+
if (!Object.keys(artifacts).length || target === "local")
|
|
151
|
+
return project(artifacts);
|
|
152
|
+
try {
|
|
153
|
+
return project(artifacts);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (!(error instanceof CloudEvidenceSizeError))
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
// Reserve all descriptors. Fit whole validation bodies before optional patches.
|
|
160
|
+
const marker = { contentOmitted: "cloud_evidence_limit" };
|
|
161
|
+
const projected = {};
|
|
162
|
+
const omitted = [];
|
|
163
|
+
for (const key of ["evidence_artifacts", "patches"]) {
|
|
164
|
+
const group = artifacts[key];
|
|
165
|
+
if (!group)
|
|
166
|
+
continue;
|
|
167
|
+
const bodyKey = key === "patches" ? "patch" : "body";
|
|
168
|
+
const wireBytes = (entry) => validateExternalEvidenceJson({ source_data: { [key]: [entry] } }, target);
|
|
169
|
+
const markerBytes = wireBytes(marker);
|
|
170
|
+
const compact = [];
|
|
171
|
+
projected[key] = compact;
|
|
172
|
+
for (const [index, artifact] of group.entries()) {
|
|
173
|
+
const { [bodyKey]: body, ...descriptor } = artifact;
|
|
174
|
+
try {
|
|
175
|
+
const bytes = wireBytes({ [bodyKey]: body }) - markerBytes;
|
|
176
|
+
if (bytes <= 0) {
|
|
177
|
+
compact.push(artifact);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
omitted.push({ compact, index, bytes, artifact });
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (!(error instanceof CloudEvidenceSizeError))
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
compact.push({ ...descriptor, ...marker });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
let result;
|
|
190
|
+
try {
|
|
191
|
+
result = project(projected);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
if (!(error instanceof CloudEvidenceSizeError) ||
|
|
195
|
+
!artifacts.evidence_artifacts?.length)
|
|
196
|
+
throw error;
|
|
197
|
+
// Even the validation descriptors exceed the budget. Retry the original finding and patches.
|
|
198
|
+
return projectArtifactBodies(artifacts.patches ? { patches: artifacts.patches } : {}, target, project);
|
|
199
|
+
}
|
|
200
|
+
let remaining = CLOUD_EVIDENCE_BYTES - validateExternalEvidenceJson(result, target);
|
|
201
|
+
for (const { compact, index, bytes, artifact } of omitted) {
|
|
202
|
+
if (bytes > remaining)
|
|
203
|
+
continue;
|
|
204
|
+
compact[index] = artifact;
|
|
205
|
+
remaining -= bytes;
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
function subcategoryCwe(row) {
|
|
210
|
+
return /^(CWE-[1-9]\d*):/u.exec(text(row["subCategory"]) ?? "")?.[1];
|
|
211
|
+
}
|
|
93
212
|
function statusUpdatedAt(value) {
|
|
94
213
|
const seconds = Math.floor(awsTimestampSeconds(value));
|
|
95
214
|
return Number.isSafeInteger(seconds) && seconds >= 0 ? seconds : null;
|
|
@@ -134,18 +253,327 @@ function affectedPackages(items, target) {
|
|
|
134
253
|
}
|
|
135
254
|
return [...unique.values()];
|
|
136
255
|
}
|
|
137
|
-
function
|
|
138
|
-
const
|
|
139
|
-
const
|
|
256
|
+
function linkedIssueFindings(value, issue, scope) {
|
|
257
|
+
const ids = array(issue["findingIds"], "Continuum issue findingIds").map((id) => requiredText(id, "Continuum issue finding ID"));
|
|
258
|
+
const missing = new Set(ids);
|
|
259
|
+
const findings = new Map();
|
|
260
|
+
const invalidLinks = "Supply exactly one detail response per Continuum issue finding ID.";
|
|
261
|
+
if (ids.length === 0 || missing.size !== ids.length)
|
|
262
|
+
throw new Error(invalidLinks);
|
|
263
|
+
for (const item of array(value, "Continuum issue findings")) {
|
|
264
|
+
const { id, scope: findingScope } = findingIdentity(item);
|
|
265
|
+
if (findingScope !== scope)
|
|
266
|
+
throw new Error("Continuum issue and linked finding must share an environment.");
|
|
267
|
+
if (!missing.delete(id))
|
|
268
|
+
throw new Error(invalidLinks);
|
|
269
|
+
findings.set(id, record(item, "Continuum finding"));
|
|
270
|
+
}
|
|
271
|
+
if (missing.size)
|
|
272
|
+
throw new Error(invalidLinks);
|
|
273
|
+
return ids.map((id) => findings.get(id));
|
|
274
|
+
}
|
|
275
|
+
function issueFindingEvidence(finding, includeReviewEvidence) {
|
|
276
|
+
const dependencyFields = (row) => ({
|
|
277
|
+
cveId: text(row["cveId"]),
|
|
278
|
+
affectedPackages: Array.isArray(row["affectedPackages"])
|
|
279
|
+
? row["affectedPackages"]
|
|
280
|
+
: [],
|
|
281
|
+
});
|
|
282
|
+
const vulnerableCode = includeReviewEvidence && text(finding["vulnerableCode"]);
|
|
283
|
+
const mitigation = includeReviewEvidence && text(finding["mitigation"]);
|
|
284
|
+
const validation = finding["validation"];
|
|
285
|
+
// Retain the inputs needed to replay the stored issue. The export on disk
|
|
286
|
+
// retains the full finding details.
|
|
287
|
+
return {
|
|
288
|
+
findingArn: finding["findingArn"],
|
|
289
|
+
findingId: finding["findingId"],
|
|
290
|
+
environmentId: finding["environmentId"],
|
|
291
|
+
ocsfClass: finding["posture"] != null
|
|
292
|
+
? "APPLICATION_SECURITY_POSTURE_FINDING"
|
|
293
|
+
: text(finding["ocsfClass"]),
|
|
294
|
+
...dependencyFields(finding),
|
|
295
|
+
filePath: text(finding["filePath"]),
|
|
296
|
+
lineNumber: locationLine(finding["lineNumber"]),
|
|
297
|
+
endLine: locationLine(finding["endLine"]),
|
|
298
|
+
...(vulnerableCode && { vulnerableCode }),
|
|
299
|
+
...(mitigation && { mitigation }),
|
|
300
|
+
...(includeReviewEvidence && isRecord(validation) && { validation }),
|
|
301
|
+
vulnerabilities: findingVulnerabilities(finding).map((vulnerability) => {
|
|
302
|
+
const code = includeReviewEvidence && text(vulnerability["code"]);
|
|
303
|
+
return {
|
|
304
|
+
...dependencyFields(vulnerability),
|
|
305
|
+
locations: vulnerability["locations"] ?? [],
|
|
306
|
+
...(code && { code }),
|
|
307
|
+
};
|
|
308
|
+
}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function issueEvidenceBody(artifact) {
|
|
312
|
+
const body = artifact["body"];
|
|
313
|
+
if (!isRecord(body))
|
|
314
|
+
return;
|
|
315
|
+
if (artifact["artifactType"] === "VALIDATION_EVIDENCE") {
|
|
316
|
+
if (isRecord(body["validationEvidence"]))
|
|
317
|
+
return { validationEvidence: body["validationEvidence"] };
|
|
318
|
+
if (typeof body["raw"] === "string")
|
|
319
|
+
return { raw: body["raw"] };
|
|
320
|
+
}
|
|
321
|
+
const projection = body["prevalidationSignals"];
|
|
322
|
+
if (artifact["artifactType"] !== "EVIDENCE" || !isRecord(projection))
|
|
323
|
+
return;
|
|
324
|
+
const signals = array(projection["signals"] ?? [], "Continuum evidence signals").map((signal) => record(signal, "Continuum evidence signal"));
|
|
325
|
+
return { prevalidationSignals: { ...projection, signals } };
|
|
326
|
+
}
|
|
327
|
+
function issueEvidenceDescriptor(artifact) {
|
|
328
|
+
return {
|
|
329
|
+
artifactId: requiredText(artifact["artifactId"], "Continuum evidence artifact ID"),
|
|
330
|
+
artifactType: artifact["artifactType"],
|
|
331
|
+
...(artifact["createdAt"] != null && { createdAt: artifact["createdAt"] }),
|
|
332
|
+
...(artifact["mediaType"] != null && { mediaType: artifact["mediaType"] }),
|
|
333
|
+
...(artifact["producer"] != null && { producer: artifact["producer"] }),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
export function singleFindingValidationIssue(issue, issueId, finding) {
|
|
337
|
+
if (!isRecord(issue) || typeof issueId !== "string")
|
|
338
|
+
return null;
|
|
339
|
+
const arn = `${finding.scope}/code-issues/${issueId}`;
|
|
340
|
+
const ids = issue["findingIds"];
|
|
341
|
+
if (issue["issueArn"] !== arn ||
|
|
342
|
+
issue["issueId"] !== issueId ||
|
|
343
|
+
!Array.isArray(ids) ||
|
|
344
|
+
ids.length !== 1 ||
|
|
345
|
+
ids[0] !== finding.id)
|
|
346
|
+
return null;
|
|
347
|
+
return { issueArn: arn, issueId, findingIds: [finding.id] };
|
|
348
|
+
}
|
|
349
|
+
export function selectFindingValidationArtifact(artifact, findingId) {
|
|
350
|
+
if (artifact["artifactType"] !== "VALIDATION_EVIDENCE")
|
|
351
|
+
return;
|
|
352
|
+
const body = issueEvidenceBody(artifact);
|
|
353
|
+
if (!body)
|
|
354
|
+
return;
|
|
355
|
+
const results = body.validationEvidence?.["perFindingResults"];
|
|
356
|
+
if (results === undefined)
|
|
357
|
+
return { scope: "issue", artifact };
|
|
358
|
+
// A bundle's top-level proof can belong to a different finding.
|
|
359
|
+
const matches = array(results, "Continuum per-finding results")
|
|
360
|
+
.map((value) => record(value, "Continuum per-finding result"))
|
|
361
|
+
.filter((result) => result["findingId"] === findingId);
|
|
362
|
+
if (matches.length === 0)
|
|
363
|
+
return;
|
|
364
|
+
return {
|
|
365
|
+
scope: "finding",
|
|
366
|
+
artifact: {
|
|
367
|
+
...issueEvidenceDescriptor(artifact),
|
|
368
|
+
body: {
|
|
369
|
+
validationEvidence: {
|
|
370
|
+
...(matches.length === 1 &&
|
|
371
|
+
"exploitable" in matches[0] && {
|
|
372
|
+
exploitable: matches[0]["exploitable"],
|
|
373
|
+
}),
|
|
374
|
+
perFindingResults: matches,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function issueEvidenceArtifacts(artifacts) {
|
|
381
|
+
return artifacts.flatMap((artifact) => {
|
|
382
|
+
const body = issueEvidenceBody(artifact);
|
|
383
|
+
return body ? [{ ...issueEvidenceDescriptor(artifact), body }] : [];
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function normalizeContinuumIssues(document, repository, target) {
|
|
387
|
+
const environmentId = requiredText(document["environmentId"], "Continuum environment ID");
|
|
388
|
+
const rows = array(document["issues"], "Continuum issues");
|
|
389
|
+
const scopes = new Set();
|
|
390
|
+
const result = normalizeRecords(rows, (value) => {
|
|
391
|
+
const row = record(value, "Continuum issue record");
|
|
392
|
+
const { artifacts, ...issue } = record(row["issue"], "Continuum issue");
|
|
393
|
+
const { arn, id, scope } = issueIdentity(issue);
|
|
394
|
+
const issueArtifacts = array(artifacts ?? row["evidenceArtifacts"] ?? [], "Continuum issue artifacts").map((artifact) => record(artifact, "Continuum issue artifact"));
|
|
395
|
+
const evidenceArtifacts = issueEvidenceArtifacts(issueArtifacts);
|
|
396
|
+
const patches = issueArtifacts
|
|
397
|
+
.filter((artifact) => artifact["artifactType"] === "PATCH")
|
|
398
|
+
.map((artifact) => {
|
|
399
|
+
const body = record(artifact["body"], "Continuum patch body");
|
|
400
|
+
return readPatch({
|
|
401
|
+
...record(body["patch"], "Continuum patch"),
|
|
402
|
+
artifactId: artifact["artifactId"],
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
const verdicts = new Set();
|
|
406
|
+
for (const artifact of evidenceArtifacts) {
|
|
407
|
+
for (const signal of artifact.body.prevalidationSignals?.signals ??
|
|
408
|
+
[]) {
|
|
409
|
+
const subject = signal["subjectRef"];
|
|
410
|
+
const exploitability = signal["exploitability"];
|
|
411
|
+
if (signal["dimension"] !== "EXPLOITABILITY" ||
|
|
412
|
+
(subject !== id && subject !== arn) ||
|
|
413
|
+
!isRecord(exploitability))
|
|
414
|
+
continue;
|
|
415
|
+
const verdict = text(exploitability["verdict"]);
|
|
416
|
+
if (verdict)
|
|
417
|
+
verdicts.add(verdict);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const scannerVerdict = verdicts.size > 1 ? "MIXED" : [...verdicts][0];
|
|
421
|
+
const linked = linkedIssueFindings(row["findings"], issue, scope);
|
|
422
|
+
const findings = linked.map((finding) => issueFindingEvidence(finding, true));
|
|
423
|
+
const ranges = findings.flatMap((finding) => Array.from(findingCodeLocations(finding, finding.vulnerabilities)));
|
|
424
|
+
const { locations, code } = codeLocations([
|
|
425
|
+
...ranges.filter(({ startLine }) => locationLine(startLine) !== null),
|
|
426
|
+
...ranges.filter(({ startLine }) => locationLine(startLine) === null),
|
|
427
|
+
]);
|
|
428
|
+
const all = findings.flatMap((finding) => [
|
|
429
|
+
finding,
|
|
430
|
+
...finding.vulnerabilities,
|
|
431
|
+
]);
|
|
432
|
+
const advisories = [...new Set(strings(all.map((row) => row.cveId)))];
|
|
433
|
+
const packages = all.flatMap((row) => row.affectedPackages);
|
|
434
|
+
const dependency = advisories.length > 0 || packages.length > 0;
|
|
435
|
+
const posture = findings.some((finding) => finding.ocsfClass === "APPLICATION_SECURITY_POSTURE_FINDING");
|
|
436
|
+
const status = requiredText(issue["status"], "Continuum issue status");
|
|
437
|
+
const synopsis = requiredText(issue["synopsis"], "Continuum issue synopsis");
|
|
438
|
+
const details = posture || (!scannerVerdict && locations[0]?.line == null)
|
|
439
|
+
? undefined
|
|
440
|
+
: {
|
|
441
|
+
details: {
|
|
442
|
+
kind: dependency ? "advisory" : "sast",
|
|
443
|
+
...(dependency && { advisory: { source: "repository" } }),
|
|
444
|
+
repository: { url: repository },
|
|
445
|
+
source_status: status,
|
|
446
|
+
...(scannerVerdict && { scanner_verdict: scannerVerdict }),
|
|
447
|
+
remediation_instructions: text(issue["summary"]),
|
|
448
|
+
code: { ...code, snippet: null },
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
const reviewDetails = details && {
|
|
452
|
+
details: {
|
|
453
|
+
...details.details,
|
|
454
|
+
remediation_instructions: details.details.remediation_instructions ??
|
|
455
|
+
findings.find(({ mitigation }) => mitigation)?.mitigation ??
|
|
456
|
+
null,
|
|
457
|
+
code,
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
const dependencyEvidence = dependency
|
|
461
|
+
? {
|
|
462
|
+
advisory_ids: target === "cloud" ? advisories.slice(0, 100) : advisories,
|
|
463
|
+
packages: affectedPackages(packages, target),
|
|
464
|
+
}
|
|
465
|
+
: undefined;
|
|
466
|
+
const source = {
|
|
467
|
+
format: continuumIssueFormat,
|
|
468
|
+
sourceRepositoryUrl: repository,
|
|
469
|
+
environmentId,
|
|
470
|
+
issue,
|
|
471
|
+
...(evidenceArtifacts.length && {
|
|
472
|
+
evidence_artifacts: evidenceArtifacts,
|
|
473
|
+
}),
|
|
474
|
+
};
|
|
475
|
+
const compactSource = structuredClone({
|
|
476
|
+
...source,
|
|
477
|
+
findings: linked.map((finding) => issueFindingEvidence(finding, false)),
|
|
478
|
+
});
|
|
479
|
+
const findingsWithVerdicts = compactSource.findings.map((finding, index) => {
|
|
480
|
+
const verdict = text(findings[index]?.validation?.["verdict"]);
|
|
481
|
+
return verdict ? { ...finding, validation: { verdict } } : finding;
|
|
482
|
+
});
|
|
483
|
+
const evidence = validateEnrichedExternalEvidence({
|
|
484
|
+
title: requiredText(issue["name"], "Continuum issue name"),
|
|
485
|
+
severity: text(issue["severity"])?.toLowerCase() ?? "unknown",
|
|
486
|
+
description: [synopsis, text(issue["severityReasoning"])]
|
|
487
|
+
.filter(Boolean)
|
|
488
|
+
.join("\n\n"),
|
|
489
|
+
// Keep every reported range in source_data, including ranges beyond
|
|
490
|
+
// the Cloud limit for navigable locations.
|
|
491
|
+
locations: target === "cloud" ? locations.slice(0, 100) : locations,
|
|
492
|
+
source_updated_at: statusUpdatedAt(issue["updatedAt"]) ??
|
|
493
|
+
statusUpdatedAt(issue["statusUpdatedAt"]),
|
|
494
|
+
source_data: compactSource,
|
|
495
|
+
...(scannerVerdict &&
|
|
496
|
+
details && {
|
|
497
|
+
details: {
|
|
498
|
+
...details.details,
|
|
499
|
+
remediation_instructions: null,
|
|
500
|
+
code: null,
|
|
501
|
+
},
|
|
502
|
+
}),
|
|
503
|
+
}, target, {
|
|
504
|
+
...reviewDetails,
|
|
505
|
+
...dependencyEvidence,
|
|
506
|
+
source_data: structuredClone({ ...source, findings }),
|
|
507
|
+
},
|
|
508
|
+
// Bulky linked validation evidence can exceed the Cloud record limit.
|
|
509
|
+
// Keep the per-finding verdicts with the structured review fields if they fit.
|
|
510
|
+
{
|
|
511
|
+
...reviewDetails,
|
|
512
|
+
...dependencyEvidence,
|
|
513
|
+
source_data: { ...compactSource, findings: findingsWithVerdicts },
|
|
514
|
+
}, dependencyEvidence
|
|
515
|
+
? { ...reviewDetails, ...dependencyEvidence }
|
|
516
|
+
: undefined, reviewDetails, dependencyEvidence ? { ...details, ...dependencyEvidence } : undefined, details, dependencyEvidence);
|
|
517
|
+
if (!patches.length)
|
|
518
|
+
return evidence;
|
|
519
|
+
// Fit optional patch bodies after selecting the scanner evidence to retain.
|
|
520
|
+
return projectArtifactBodies({ patches }, target, (artifacts) => validateExternalEvidence({
|
|
521
|
+
...evidence,
|
|
522
|
+
source_data: { ...evidence.source_data, ...artifacts },
|
|
523
|
+
}, target));
|
|
524
|
+
}, (value) => {
|
|
525
|
+
const issue = issueIdentity(record(value, "Continuum issue record")["issue"]);
|
|
526
|
+
if (issue.environmentId !== environmentId)
|
|
527
|
+
throw new Error("Continuum issue ARN does not match the export environment.");
|
|
528
|
+
scopes.add(issue.scope);
|
|
529
|
+
return issue.arn;
|
|
530
|
+
}, target);
|
|
531
|
+
if (scopes.size > 1)
|
|
532
|
+
throw new Error("Continuum issues must belong to the same environment.");
|
|
533
|
+
return result;
|
|
534
|
+
}
|
|
535
|
+
export function normalizeContinuumFindings(input, sourceRepositoryUrl, target = "cloud") {
|
|
536
|
+
const issueReport = isRecord(input) && input["format"] === continuumIssueFormat;
|
|
537
|
+
const capturedSource = issueReport && input["sourceRepositoryUrl"] !== undefined
|
|
538
|
+
? declaredScannerRepositoryUrl(input["sourceRepositoryUrl"], "Continuum", target)
|
|
539
|
+
: undefined;
|
|
540
|
+
const repository = declaredScannerRepositoryUrl(sourceRepositoryUrl || capturedSource, "Continuum", target);
|
|
541
|
+
if (issueReport) {
|
|
542
|
+
if (capturedSource &&
|
|
543
|
+
repositoryUrlKey(capturedSource) !== repositoryUrlKey(repository))
|
|
544
|
+
throw new Error("The Continuum export repository does not match the declared source repository.");
|
|
545
|
+
const findings = normalizeContinuumIssues(input, capturedSource ?? repository, target);
|
|
546
|
+
return capturedSource
|
|
547
|
+
? { ...findings, report: { sourceRepositoryUrl: capturedSource } }
|
|
548
|
+
: findings;
|
|
549
|
+
}
|
|
550
|
+
const { rows, summary } = reportRows(input);
|
|
140
551
|
const scopes = new Set();
|
|
141
552
|
const output = normalizeRecords(rows, (value) => {
|
|
142
|
-
const
|
|
553
|
+
const capture = !summary && isFindingCapture(value) ? value : undefined;
|
|
554
|
+
const row = record(capture ? capture["finding"] : value, "Continuum finding");
|
|
555
|
+
const patches = optionalArray(capture?.["patches"], "Continuum patches").map(readPatch);
|
|
556
|
+
const linkedIssue = text(row["createdIssueId"]) ?? text(row["duplicateOfIssueId"]);
|
|
557
|
+
let validationIssue;
|
|
558
|
+
const evidenceArtifacts = issueEvidenceArtifacts(optionalArray(capture?.["evidenceArtifacts"], "Continuum evidence artifacts").flatMap((value) => {
|
|
559
|
+
const selected = selectFindingValidationArtifact(record(value, "Continuum validation artifact"), row["findingId"]);
|
|
560
|
+
if (!selected)
|
|
561
|
+
return [];
|
|
562
|
+
if (selected.scope === "issue") {
|
|
563
|
+
validationIssue ??= singleFindingValidationIssue(capture?.["validationIssue"], linkedIssue, findingIdentity(row));
|
|
564
|
+
if (!validationIssue)
|
|
565
|
+
return [];
|
|
566
|
+
}
|
|
567
|
+
return [selected.artifact];
|
|
568
|
+
}));
|
|
569
|
+
if ((patches.length || evidenceArtifacts.length) && !linkedIssue)
|
|
570
|
+
throw new Error(`Continuum ${patches.length ? "patches" : "validation artifacts"} require a finding linked to an issue.`);
|
|
143
571
|
if (row["type"] !== "CONTINUUM_CODE_VULN" &&
|
|
144
572
|
row["type"] !== "CUSTOMER_CODE_VULN")
|
|
145
573
|
throw new Error("Expected a Continuum code vulnerability finding type.");
|
|
146
574
|
const severity = requiredText(row["severity"], "Continuum severity").toLowerCase();
|
|
147
|
-
const vulnerabilities =
|
|
148
|
-
const { locations, code } = codeLocations(row, vulnerabilities);
|
|
575
|
+
const vulnerabilities = findingVulnerabilities(row);
|
|
576
|
+
const { locations, code } = codeLocations(findingCodeLocations(row, vulnerabilities));
|
|
149
577
|
const source = requiredText(row["source"], "Continuum source");
|
|
150
578
|
const status = requiredText(row["status"], "Continuum status");
|
|
151
579
|
const validation = record(row["validation"] ?? {}, "Continuum validation");
|
|
@@ -191,20 +619,39 @@ function normalize(input, sourceRepositoryUrl, target, previous) {
|
|
|
191
619
|
finding: structuredClone(row),
|
|
192
620
|
},
|
|
193
621
|
};
|
|
194
|
-
const updatedAt =
|
|
195
|
-
|
|
196
|
-
:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
622
|
+
const updatedAt = statusUpdatedAt(row["statusUpdatedAt"]);
|
|
623
|
+
const enrichment = {
|
|
624
|
+
packages: affectedPackages(packages, target),
|
|
625
|
+
source_updated_at: updatedAt,
|
|
626
|
+
};
|
|
627
|
+
// Native code findings can identify a CWE only in subCategory.
|
|
628
|
+
const namedCwe = evidence.details?.weakness_ids.length === 0
|
|
629
|
+
? subcategoryCwe(row)
|
|
630
|
+
: undefined;
|
|
631
|
+
const inferred = namedCwe
|
|
632
|
+
? { details: { ...evidence.details, weakness_ids: [namedCwe] } }
|
|
633
|
+
: undefined;
|
|
634
|
+
// Keep previously admissible evidence if an optional projection exceeds the Cloud budget.
|
|
635
|
+
return projectArtifactBodies({
|
|
636
|
+
...(evidenceArtifacts.length && {
|
|
637
|
+
evidence_artifacts: structuredClone(evidenceArtifacts),
|
|
638
|
+
}),
|
|
639
|
+
...(patches.length && { patches }),
|
|
640
|
+
}, target, (artifacts) => validateEnrichedExternalEvidence({
|
|
641
|
+
...evidence,
|
|
642
|
+
source_data: {
|
|
643
|
+
...evidence.source_data,
|
|
644
|
+
...(validationIssue &&
|
|
645
|
+
artifacts.evidence_artifacts?.length && {
|
|
646
|
+
validation_issue: validationIssue,
|
|
647
|
+
}),
|
|
648
|
+
...artifacts,
|
|
649
|
+
},
|
|
650
|
+
}, target, inferred ? { ...enrichment, ...inferred } : undefined, enrichment, packages.length && updatedAt !== null
|
|
204
651
|
? { source_updated_at: updatedAt }
|
|
205
|
-
: undefined);
|
|
652
|
+
: undefined, inferred));
|
|
206
653
|
}, (value) => {
|
|
207
|
-
const { arn, scope } =
|
|
654
|
+
const { arn, scope } = findingIdentity(!summary && isFindingCapture(value) ? value["finding"] : value);
|
|
208
655
|
scopes.add(scope);
|
|
209
656
|
return arn;
|
|
210
657
|
}, target);
|
|
@@ -212,14 +659,5 @@ function normalize(input, sourceRepositoryUrl, target, previous) {
|
|
|
212
659
|
throw new Error("Continuum findings must belong to the same environment.");
|
|
213
660
|
return output;
|
|
214
661
|
}
|
|
215
|
-
export
|
|
216
|
-
return normalize(input, sourceRepositoryUrl, target, false);
|
|
217
|
-
}
|
|
218
|
-
/** @internal Reconstruct the original evidence for an interrupted Cloud request. */
|
|
219
|
-
export function normalizePreviousContinuumFindings(input, sourceRepositoryUrl, target = "cloud") {
|
|
220
|
-
return normalize(input, sourceRepositoryUrl, target, true);
|
|
221
|
-
}
|
|
222
|
-
export async function readContinuumFindings(path, sourceRepositoryUrl, target = "cloud") {
|
|
223
|
-
return normalizeContinuumFindings(await readScannerJson(path), sourceRepositoryUrl, target);
|
|
224
|
-
}
|
|
662
|
+
export const readContinuumFindings = scannerJsonReader(normalizeContinuumFindings);
|
|
225
663
|
//# sourceMappingURL=continuum-findings.js.map
|