@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,21 +1,16 @@
|
|
|
1
|
-
import { DEFAULT_CLOUD_STRING_BYTES,
|
|
1
|
+
import { DEFAULT_CLOUD_STRING_BYTES, canonicalNumber, validateExternalEvidence, } from "./external-import-contract.js";
|
|
2
2
|
import { hostedRepositoryMatches, normalizeHostedGitRepositoryUrl, hostedRepositoryUrlKey, isPublicGitHost as publicGitHost, gitServiceHostname, } from "./hosted-git-repository.js";
|
|
3
3
|
import { isGitHubCloudHost } from "./git-remote.js";
|
|
4
4
|
import { position, weaknessIds } from "./native-json-findings.js";
|
|
5
|
-
import { array,
|
|
5
|
+
import { array, normalizeRecords, record, relativePath, repositoryFilePath, scannerSeverity, strings, requiredText, stableId, text, } from "./scanner-import.js";
|
|
6
6
|
import { hostedNumberToken, hostedNativeRepositoryUrl, hostedRepositoryUrl, } from "./hosted-scanner-http.js";
|
|
7
7
|
import { isRecord } from "./record.js";
|
|
8
8
|
import { declaredScannerRepositoryUrl, validScannerRepositoryUrl, } from "./scanner-repository-url.js";
|
|
9
|
-
import { legacyDecimalInteger, restoreLegacyHostedNumbers, } from "./hosted-scanner-v1.js";
|
|
10
|
-
import { semgrepV1Id, upgradeSemgrepPlatformReport, } from "./semgrep-platform-v1.js";
|
|
11
9
|
export const semgrepPlatformFormat = "semgrep-platform-findings/v2";
|
|
12
|
-
export const semgrepPlatformLegacyFormat = "semgrep-platform-findings/v1";
|
|
13
10
|
export const SEMGREP_PLATFORM_PRODUCTS = ["sast", "sca", "ai_sast"];
|
|
14
11
|
export const semgrepSelectionFormat = "semgrep-platform-selection/v1";
|
|
15
12
|
export function isSemgrepPlatformFormat(format) {
|
|
16
|
-
return
|
|
17
|
-
format === semgrepPlatformFormat ||
|
|
18
|
-
format === semgrepPlatformLegacyFormat);
|
|
13
|
+
return format === semgrepSelectionFormat || format === semgrepPlatformFormat;
|
|
19
14
|
}
|
|
20
15
|
function selectedProjectUrl(value, label) {
|
|
21
16
|
return declaredScannerRepositoryUrl(value, label, "local");
|
|
@@ -27,19 +22,13 @@ export function semgrepPlatformReportScope(input, provider, references = []) {
|
|
|
27
22
|
input.semgrepPlatformScope !== undefined &&
|
|
28
23
|
!isSemgrepPlatformFormat(format))
|
|
29
24
|
throw new Error("A normalized Semgrep Platform report scope requires its source format.");
|
|
30
|
-
if (format
|
|
31
|
-
provider === "semgrep" &&
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
input.findings.some((row) => isSemgrepPlatformEvidence(row, provider)))) {
|
|
36
|
-
// The object-row SDK retained only the binding on the envelope, including empty reports.
|
|
37
|
-
return {
|
|
38
|
-
url: hostedRepositoryUrl(input.sourceRepositoryUrl, "Semgrep Platform"),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (!isSemgrepPlatformFormat(format))
|
|
25
|
+
if (!isSemgrepPlatformFormat(format)) {
|
|
26
|
+
if (provider === "semgrep" &&
|
|
27
|
+
typeof format === "string" &&
|
|
28
|
+
format.startsWith("semgrep-platform-"))
|
|
29
|
+
throw new Error("Unsupported Semgrep Platform format. Recollect the findings.");
|
|
42
30
|
return;
|
|
31
|
+
}
|
|
43
32
|
const scope = record("semgrepPlatformScope" in input ? input.semgrepPlatformScope : undefined, "Normalized Semgrep report scope");
|
|
44
33
|
const readUrl = format === semgrepSelectionFormat
|
|
45
34
|
? selectedProjectUrl
|
|
@@ -56,8 +45,8 @@ export function semgrepPlatformReportScope(input, provider, references = []) {
|
|
|
56
45
|
url,
|
|
57
46
|
};
|
|
58
47
|
}
|
|
59
|
-
export function semgrepPlatformReportRepository(input
|
|
60
|
-
return semgrepPlatformReportScope(input
|
|
48
|
+
export function semgrepPlatformReportRepository(input) {
|
|
49
|
+
return semgrepPlatformReportScope(input)?.url;
|
|
61
50
|
}
|
|
62
51
|
// Raw JSON numbers are represented as JavaScript objects during lossless parsing.
|
|
63
52
|
export function responseRecord(value, label) {
|
|
@@ -90,7 +79,7 @@ function sourceLine(value, coerceStrings) {
|
|
|
90
79
|
const token = hostedNumberToken(value);
|
|
91
80
|
// A long fraction can round to an integer if it is converted before checking its decimal value.
|
|
92
81
|
if (token !== undefined)
|
|
93
|
-
return position(Number(
|
|
82
|
+
return position(Number(semgrepPlatformIdOrUndefined(wireJson.rawJSON(token))), "Semgrep source line");
|
|
94
83
|
return position(coerceStrings ? Number(semgrepPlatformId(value)) : value, "Semgrep source line");
|
|
95
84
|
}
|
|
96
85
|
export function parseSemgrepResponse(json) {
|
|
@@ -119,15 +108,6 @@ export function semgrepPlatformId(value) {
|
|
|
119
108
|
throw new Error("Expected an exact, positive Semgrep Platform ID.");
|
|
120
109
|
return id;
|
|
121
110
|
}
|
|
122
|
-
// Older selections retained full decimal ID tokens beyond Semgrep's native int64 range.
|
|
123
|
-
function archivedPlatformId(value) {
|
|
124
|
-
const token = wireJson.isRawJSON(value)
|
|
125
|
-
? canonicalNumber(value.rawJSON, Math.max(21, value.rawJSON.length))
|
|
126
|
-
: value;
|
|
127
|
-
return typeof token === "string" && /^[1-9][0-9]*$/u.test(token)
|
|
128
|
-
? token
|
|
129
|
-
: semgrepPlatformId(value);
|
|
130
|
-
}
|
|
131
111
|
function savedPlatformId(value) {
|
|
132
112
|
if (typeof value !== "string")
|
|
133
113
|
return semgrepPlatformId(value);
|
|
@@ -150,7 +130,7 @@ function scopeOf(deployment, project, ref, readId = semgrepPlatformId, readUrl =
|
|
|
150
130
|
product: "sast",
|
|
151
131
|
};
|
|
152
132
|
}
|
|
153
|
-
export function projectAliases(name, url, references = []
|
|
133
|
+
export function projectAliases(name, url, references = []) {
|
|
154
134
|
const { hostname, pathname } = new URL(url);
|
|
155
135
|
const path = pathname.slice(1).replace(/\/$/u, "");
|
|
156
136
|
const decodePath = (decode) => path
|
|
@@ -177,39 +157,10 @@ export function projectAliases(name, url, references = [], earlyV1 = false) {
|
|
|
177
157
|
key(path.slice(path.lastIndexOf("/") + 1)),
|
|
178
158
|
]));
|
|
179
159
|
const shortName = name.slice(name.lastIndexOf("/") + 1);
|
|
180
|
-
const historicalPaths = [];
|
|
181
|
-
if (earlyV1) {
|
|
182
|
-
// Older exports used decodeURI, which preserves escaped reserved delimiters.
|
|
183
|
-
for (const historical of [path, decodePath(decodeURI)]) {
|
|
184
|
-
if (!publicGitHost(hostname))
|
|
185
|
-
historicalPaths.push(historical);
|
|
186
|
-
if (publicHost || source.platform === "github")
|
|
187
|
-
historicalPaths.push(historical.replace(/\.git$/u, ""));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const hasHistoricalPath = (label) => historicalPaths.some((path) => label === path || label === path.slice(path.lastIndexOf("/") + 1));
|
|
191
160
|
return {
|
|
192
|
-
|
|
193
|
-
has: (label) => label === name ||
|
|
194
|
-
label === shortName ||
|
|
195
|
-
pathKeys.has(key(label)) ||
|
|
196
|
-
hasHistoricalPath(label),
|
|
161
|
+
has: (label) => label === name || label === shortName || pathKeys.has(key(label)),
|
|
197
162
|
};
|
|
198
163
|
}
|
|
199
|
-
/** Older captures could derive a row label from their verified HTTP mapping for an SSH project. */
|
|
200
|
-
export function legacyProjectAliases(name, url, references, mapping) {
|
|
201
|
-
const native = projectAliases(name, url, references, true);
|
|
202
|
-
const mapped = mapping && mapping !== url
|
|
203
|
-
? projectAliases(name, mapping, references, true)
|
|
204
|
-
: undefined;
|
|
205
|
-
return {
|
|
206
|
-
has: (label) => native.has(label) || !!mapped?.hasHistoricalPath(label),
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
/** Compare HTTP origins canonically without folding paths on independent custom Git hosts. */
|
|
210
|
-
export function semgrepRepositoryUrlKey(value) {
|
|
211
|
-
return hostedRepositoryUrlKey(nativeHttp(value));
|
|
212
|
-
}
|
|
213
164
|
/** A real HTTP URL can elide its default port. Git transport serializations retain explicit ports. */
|
|
214
165
|
function nativeHttp(url) {
|
|
215
166
|
return URL.parse(url)?.href ?? url;
|
|
@@ -279,9 +230,6 @@ export function semgrepNativeProjectUrl(value, references) {
|
|
|
279
230
|
}
|
|
280
231
|
return hostedNativeRepositoryUrl(value, label);
|
|
281
232
|
}
|
|
282
|
-
function referenceRepositoryKey(references, target = "local") {
|
|
283
|
-
return (url) => repositoryContext(url, references, target).key(url);
|
|
284
|
-
}
|
|
285
233
|
function repositoryContext(projectUrl, references = [], target = "local") {
|
|
286
234
|
const source = semgrepPlatformRepositoryReference(projectUrl, typeof references === "function" ? [] : references);
|
|
287
235
|
const github = source.platform === "github";
|
|
@@ -466,18 +414,18 @@ export function normalizeSelectedSemgrepPlatformFindings(options) {
|
|
|
466
414
|
}, hostedRepositoryUrl);
|
|
467
415
|
return {
|
|
468
416
|
...normalizePlatformRows(rows.map((finding) => ({ finding, selectable: true })), scope, "local"),
|
|
469
|
-
|
|
417
|
+
...reportScope(semgrepSelectionFormat, scope),
|
|
470
418
|
};
|
|
471
419
|
}
|
|
472
|
-
function sourceId(scope, finding
|
|
420
|
+
function sourceId(scope, finding) {
|
|
473
421
|
// Keep the same tuple for a selected import and a subsequent scoped Platform collection.
|
|
474
422
|
const exact = (id) => Number.isSafeInteger(Number(id)) ? Number(id) : id;
|
|
475
423
|
return stableId("semgrep-platform", [
|
|
476
424
|
scope.deployment,
|
|
477
|
-
exact(
|
|
425
|
+
exact(semgrepPlatformId(wireJson.rawJSON(scope.project.id))),
|
|
478
426
|
scope.product,
|
|
479
427
|
scope.ref,
|
|
480
|
-
exact(
|
|
428
|
+
exact(semgrepPlatformId(finding["id"])),
|
|
481
429
|
]);
|
|
482
430
|
}
|
|
483
431
|
function scopeProduct(native, complete) {
|
|
@@ -487,8 +435,7 @@ function scopeProduct(native, complete) {
|
|
|
487
435
|
return product;
|
|
488
436
|
}
|
|
489
437
|
function readScope(input, references, target = "local") {
|
|
490
|
-
const complete = input["format"] === semgrepPlatformFormat
|
|
491
|
-
input["format"] === semgrepPlatformLegacyFormat;
|
|
438
|
+
const complete = input["format"] === semgrepPlatformFormat;
|
|
492
439
|
const product = scopeProduct(input["product"], complete);
|
|
493
440
|
const project = responseRecord(input["project"], "Semgrep project");
|
|
494
441
|
if (input["format"] === semgrepPlatformFormat &&
|
|
@@ -537,10 +484,10 @@ function matchesNativeInteger(value, expected) {
|
|
|
537
484
|
return value === expected;
|
|
538
485
|
return expected === 0
|
|
539
486
|
? /^-?0(?:\.0+)?(?:e[+-]?\d+)?$/iu.test(token)
|
|
540
|
-
:
|
|
487
|
+
: canonicalNumber(token) === String(expected);
|
|
541
488
|
}
|
|
542
489
|
const generatedId = /^semgrep-platform:[0-9a-f]{64}$/u;
|
|
543
|
-
/**
|
|
490
|
+
/** Recognize reserved Platform IDs and native scope before accepting normalized evidence. */
|
|
544
491
|
export function isSemgrepPlatformEvidence(finding, provider) {
|
|
545
492
|
const data = finding.evidence.source_data;
|
|
546
493
|
if (generatedId.test(finding.source_finding_id))
|
|
@@ -564,91 +511,38 @@ export function isSemgrepPlatformEvidence(finding, provider) {
|
|
|
564
511
|
typeof data["deployment"] === "string" &&
|
|
565
512
|
SEMGREP_PLATFORM_PRODUCTS.some((product) => product === data["product"]));
|
|
566
513
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
? references
|
|
571
|
-
: referenceRepositoryKey(references, target), references);
|
|
572
|
-
return {
|
|
573
|
-
...converted,
|
|
574
|
-
semgrepPlatformFindingJson: array(converted["findings"], "Semgrep findings")[0],
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
/** Keep caller-supplied metadata while replacing the scanner's old wire representation. */
|
|
578
|
-
function canonicalSourceDataWithExtensions(retained, canonical, original) {
|
|
579
|
-
const extensions = (original, verified, replaced = []) => Object.fromEntries(Object.entries(original).filter(([key]) => !Object.hasOwn(verified, key) && !replaced.includes(key)));
|
|
580
|
-
return {
|
|
581
|
-
...canonical,
|
|
582
|
-
...extensions(retained, canonical, [
|
|
583
|
-
...(original ? ["finding", "numericFields", "sourceRepositoryUrl"] : []),
|
|
584
|
-
"nativeProjectUrl",
|
|
585
|
-
"repositoryAliases",
|
|
586
|
-
"repositoryWitnessJson",
|
|
587
|
-
"idEncoding",
|
|
588
|
-
]),
|
|
589
|
-
project: {
|
|
590
|
-
...canonical.project,
|
|
591
|
-
...extensions(record(retained["project"], "Semgrep project"), canonical.project),
|
|
592
|
-
},
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
function legacyWitnessKey(scope, projectUrlKey, label) {
|
|
596
|
-
return JSON.stringify([
|
|
597
|
-
scope.deployment,
|
|
598
|
-
scope.project.id,
|
|
599
|
-
scope.product,
|
|
600
|
-
scope.ref,
|
|
601
|
-
projectUrlKey,
|
|
602
|
-
label,
|
|
603
|
-
]);
|
|
604
|
-
}
|
|
605
|
-
function nativeOccurrence(retained, references, target) {
|
|
606
|
-
let data = !isSemgrepPlatformFormat(retained["format"])
|
|
607
|
-
? {
|
|
608
|
-
...retained,
|
|
609
|
-
format: (!Object.hasOwn(retained, "semgrepPlatformFindingJson") &&
|
|
610
|
-
"finding" in retained) ||
|
|
611
|
-
retained["idEncoding"] === "v1-decimal"
|
|
612
|
-
? semgrepPlatformLegacyFormat
|
|
613
|
-
: "repositoryAliases" in retained
|
|
614
|
-
? semgrepPlatformFormat
|
|
615
|
-
: semgrepSelectionFormat,
|
|
616
|
-
}
|
|
617
|
-
: retained;
|
|
618
|
-
const legacy = data["format"] === semgrepPlatformLegacyFormat;
|
|
619
|
-
const original = legacy && !Object.hasOwn(data, "semgrepPlatformFindingJson");
|
|
620
|
-
if (original)
|
|
621
|
-
data = upgradeOriginalSemgrepFinding(data, references, target);
|
|
514
|
+
function nativeOccurrence(data, references, target) {
|
|
515
|
+
if (!isSemgrepPlatformFormat(data["format"]))
|
|
516
|
+
throw new Error("Unsupported Semgrep finding format. Recollect the Platform findings.");
|
|
622
517
|
const { scope, aliases } = readScope(data, references, target);
|
|
623
518
|
const repository = repositoryContext(scope.project.url, references, target);
|
|
624
519
|
const row = parseSemgrepResponse(requiredText(data["semgrepPlatformFindingJson"], "Semgrep finding JSON"));
|
|
625
|
-
return {
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
export function
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return witnesses;
|
|
520
|
+
return { scope, aliases, repository, row };
|
|
521
|
+
}
|
|
522
|
+
/** Reproduce the native Cloud title fallback for an unmodified Platform message title. */
|
|
523
|
+
export function storedSemgrepCloudEvidence(finding, references = []) {
|
|
524
|
+
const { evidence } = finding;
|
|
525
|
+
if (evidence.title !== evidence.description ||
|
|
526
|
+
Buffer.byteLength(evidence.title) <= DEFAULT_CLOUD_STRING_BYTES ||
|
|
527
|
+
!evidence.source_data ||
|
|
528
|
+
!isSemgrepPlatformEvidence(finding, "semgrep"))
|
|
529
|
+
return;
|
|
530
|
+
const { row, scope, aliases, repository } = nativeOccurrence(evidence.source_data, references, "local");
|
|
531
|
+
if (sourceId(scope, row) !== finding.source_finding_id)
|
|
532
|
+
return;
|
|
533
|
+
const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository);
|
|
534
|
+
const projectNames = aliases &&
|
|
535
|
+
projectAliases(scope.project.name, scope.project.url, references);
|
|
536
|
+
const title = (target) => normalizePlatformRows([{ finding: row, selectable }], scope, target, projectNames).findings[0]?.evidence.title;
|
|
537
|
+
if (title("local") !== evidence.title)
|
|
538
|
+
return;
|
|
539
|
+
const cloud = title("cloud");
|
|
540
|
+
if (cloud && cloud !== evidence.title)
|
|
541
|
+
return { ...evidence, title: cloud };
|
|
648
542
|
}
|
|
649
543
|
/** Recheck the source repository when an SDK caller supplies normalized evidence directly. */
|
|
650
|
-
export function semgrepPlatformFindingRepository(finding, provider, references = []
|
|
651
|
-
return semgrepPlatformFindingBinding(finding, provider, references
|
|
544
|
+
export function semgrepPlatformFindingRepository(finding, provider, references = []) {
|
|
545
|
+
return semgrepPlatformFindingBinding(finding, provider, references)?.url;
|
|
652
546
|
}
|
|
653
547
|
export function platformLocationPath(value) {
|
|
654
548
|
const path = text(value);
|
|
@@ -657,79 +551,20 @@ export function platformLocationPath(value) {
|
|
|
657
551
|
? path
|
|
658
552
|
: null;
|
|
659
553
|
}
|
|
660
|
-
function platformLocation(location, product,
|
|
554
|
+
function platformLocation(location, product, coerceStrings) {
|
|
661
555
|
const path = platformLocationPath(location["file_path"]);
|
|
662
|
-
|
|
663
|
-
|
|
556
|
+
if (!path)
|
|
557
|
+
return { locations: [], endLine: null };
|
|
558
|
+
const line = sourceLine(location["line"], coerceStrings);
|
|
559
|
+
const endLine = line !== null && product !== "sca"
|
|
560
|
+
? sourceLine(location["end_line"], coerceStrings)
|
|
664
561
|
: null;
|
|
665
|
-
|
|
666
|
-
if (!path && !oldPath)
|
|
667
|
-
return unprojected;
|
|
668
|
-
// V1 retained coordinates for unprojected paths without validating them.
|
|
669
|
-
const newlyProjectable = !!bulk?.legacy && !oldPath;
|
|
670
|
-
const coerce = newlyProjectable || (!!bulk && !bulk.legacy && !selectable);
|
|
671
|
-
try {
|
|
672
|
-
const line = sourceLine(location["line"], coerce);
|
|
673
|
-
const endLine = line !== null && product !== "sca"
|
|
674
|
-
? sourceLine(location["end_line"], coerce)
|
|
675
|
-
: null;
|
|
676
|
-
if (bulk?.legacy && oldPath !== path)
|
|
677
|
-
validateCodeLineRange(line, endLine);
|
|
678
|
-
return path ? { locations: [{ path, line }], endLine } : unprojected;
|
|
679
|
-
}
|
|
680
|
-
catch (error) {
|
|
681
|
-
if (newlyProjectable)
|
|
682
|
-
return unprojected;
|
|
683
|
-
throw error;
|
|
684
|
-
}
|
|
562
|
+
return { locations: [{ path, line }], endLine };
|
|
685
563
|
}
|
|
686
564
|
function platformSeverity(value, selectable) {
|
|
687
565
|
const severity = text(value)?.toLowerCase();
|
|
688
566
|
return scannerSeverity(selectable && severity === "informational" ? null : severity);
|
|
689
567
|
}
|
|
690
|
-
/** Upgrade only values produced by the original object-row reader; keep SDK-authored evidence. */
|
|
691
|
-
function migrateLegacyProjection(evidence, row, scope, selectable, references) {
|
|
692
|
-
const severity = text(row["severity"]);
|
|
693
|
-
const oldSeverity = scannerSeverity(severity === "informational" ? null : severity);
|
|
694
|
-
const upgradeSeverity = evidence.severity === oldSeverity &&
|
|
695
|
-
oldSeverity !== scannerSeverity(severity?.toLowerCase());
|
|
696
|
-
const location = isRecord(row["location"]) ? row["location"] : {};
|
|
697
|
-
const oldPath = hostedRepositoryPath(location["file_path"]);
|
|
698
|
-
const first = evidence.locations?.[0];
|
|
699
|
-
// Only replace the exact location and end line produced by the original object-row reader.
|
|
700
|
-
const oldLocation = oldPath !== platformLocationPath(location["file_path"]) &&
|
|
701
|
-
(oldPath
|
|
702
|
-
? evidence.locations?.length === 1 &&
|
|
703
|
-
first?.path === oldPath &&
|
|
704
|
-
matchesNativeInteger(location["line"], first.line)
|
|
705
|
-
: evidence.locations?.length === 0) &&
|
|
706
|
-
matchesNativeInteger(oldPath && scope.product !== "sca" && first?.line != null
|
|
707
|
-
? location["end_line"]
|
|
708
|
-
: null, evidence.details?.code?.end_line);
|
|
709
|
-
if (!upgradeSeverity && !oldLocation)
|
|
710
|
-
return;
|
|
711
|
-
const projected = normalizePlatformRows([{ finding: row, selectable }], scope, "local", {
|
|
712
|
-
legacy: true,
|
|
713
|
-
projectNames: projectAliases(scope.project.name, scope.project.url, references),
|
|
714
|
-
}).findings[0]?.evidence;
|
|
715
|
-
if (!projected)
|
|
716
|
-
return;
|
|
717
|
-
return {
|
|
718
|
-
...(upgradeSeverity && { severity: projected.severity }),
|
|
719
|
-
...(oldLocation && { locations: projected.locations }),
|
|
720
|
-
...(oldLocation &&
|
|
721
|
-
evidence.details?.code &&
|
|
722
|
-
projected.details?.code && {
|
|
723
|
-
details: {
|
|
724
|
-
...evidence.details,
|
|
725
|
-
code: {
|
|
726
|
-
...evidence.details.code,
|
|
727
|
-
end_line: projected.details.code.end_line,
|
|
728
|
-
},
|
|
729
|
-
},
|
|
730
|
-
}),
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
568
|
function qualifiedBranch(ref) {
|
|
734
569
|
return ref.startsWith("refs/") ? ref : `refs/heads/${ref}`;
|
|
735
570
|
}
|
|
@@ -759,12 +594,10 @@ export function hasRetainedSemgrepScope(finding) {
|
|
|
759
594
|
SEMGREP_PLATFORM_PRODUCTS.some((known) => known === product));
|
|
760
595
|
});
|
|
761
596
|
}
|
|
762
|
-
export function semgrepPlatformFindingBinding(finding, provider, references = [],
|
|
597
|
+
export function semgrepPlatformFindingBinding(finding, provider, references = [], reportScope, projectedSources = [], target = "local") {
|
|
763
598
|
const retained = finding.evidence.source_data;
|
|
764
599
|
if (!isSemgrepPlatformEvidence(finding, provider)) {
|
|
765
|
-
|
|
766
|
-
if (!replayApprovedRequest &&
|
|
767
|
-
provider === "semgrep" &&
|
|
600
|
+
if (provider === "semgrep" &&
|
|
768
601
|
reportScope?.format !== undefined &&
|
|
769
602
|
hasRetainedSemgrepScope(retained?.["finding"]))
|
|
770
603
|
throw new Error("Retained Semgrep finding scope requires the original collection scope in a marked Platform report.");
|
|
@@ -789,7 +622,7 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
|
|
|
789
622
|
}
|
|
790
623
|
if (!retained)
|
|
791
624
|
throw new Error("Missing the original Semgrep finding evidence.");
|
|
792
|
-
const {
|
|
625
|
+
const { scope, aliases, repository, row } = nativeOccurrence(retained, references, target);
|
|
793
626
|
checkProjectedProduct(finding, scope.product, true);
|
|
794
627
|
if (reportScope?.deployment !== undefined &&
|
|
795
628
|
(scope.deployment !== reportScope.deployment ||
|
|
@@ -797,54 +630,36 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
|
|
|
797
630
|
scope.ref !== reportScope.ref ||
|
|
798
631
|
scope.product !== reportScope.product))
|
|
799
632
|
throw new Error("The Semgrep report repository scope does not match the finding's deployment, project ID, ref, or product.");
|
|
800
|
-
const other =
|
|
801
|
-
if ((
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
const id = originalRow["id"];
|
|
806
|
-
const nativeId = semgrepPlatformIdOrUndefined(id) ??
|
|
807
|
-
(typeof id === "string" ? legacyDecimalInteger(id) : undefined);
|
|
808
|
-
if ((legacy || nativeId !== undefined) &&
|
|
809
|
-
stringifySemgrepFinding(originalRow) !== stringifySemgrepFinding(row))
|
|
633
|
+
const other = retained["finding"];
|
|
634
|
+
if (isRecord(other) && Object.hasOwn(other, "id")) {
|
|
635
|
+
const original = parseSemgrepResponse(JSON.stringify(other));
|
|
636
|
+
if (semgrepPlatformIdOrUndefined(original["id"]) !== undefined &&
|
|
637
|
+
stringifySemgrepFinding(original) !== stringifySemgrepFinding(row))
|
|
810
638
|
throw new Error("The retained Semgrep finding representations disagree.");
|
|
811
639
|
}
|
|
812
|
-
const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository
|
|
640
|
+
const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository);
|
|
813
641
|
if (reportScope?.format === semgrepSelectionFormat && !selectable)
|
|
814
642
|
throw new Error("Semgrep finding does not belong to the selected project and ref.");
|
|
815
|
-
|
|
816
|
-
const nativeId = sourceId(scope, row, occurrenceId);
|
|
643
|
+
const nativeId = sourceId(scope, row);
|
|
817
644
|
if (generatedId.test(finding.source_finding_id) &&
|
|
818
|
-
finding.source_finding_id !== nativeId)
|
|
819
|
-
|
|
820
|
-
finding.source_finding_id !== sourceId(scope, row, archivedPlatformId))
|
|
821
|
-
throw new Error("The generated Semgrep finding ID does not match its native occurrence.");
|
|
822
|
-
occurrenceId = archivedPlatformId;
|
|
823
|
-
}
|
|
645
|
+
finding.source_finding_id !== nativeId)
|
|
646
|
+
throw new Error("The generated Semgrep finding ID does not match its native occurrence.");
|
|
824
647
|
const { name, url } = scope.project;
|
|
825
648
|
let namedOnly = aliases && repositoryWithOnlyAlias(row, projectAliases(name, url));
|
|
826
|
-
const raw =
|
|
827
|
-
? namedOnly &&
|
|
828
|
-
legacyWitnesses?.get(legacyWitnessKey(scope, repository.key(url), namedOnly))
|
|
829
|
-
: data["repositoryWitnessJson"];
|
|
649
|
+
const raw = retained["repositoryWitnessJson"];
|
|
830
650
|
// Only rely on the reader's platform hint when there is no independent proof.
|
|
831
651
|
if (namedOnly &&
|
|
832
652
|
raw === undefined &&
|
|
833
653
|
projectAliases(name, url, references).has(namedOnly))
|
|
834
654
|
namedOnly = undefined;
|
|
835
|
-
|
|
836
|
-
namedOnly &&
|
|
837
|
-
legacyProjectAliases(name, url, references, scope.sourceRepositoryUrl).has(namedOnly);
|
|
838
|
-
if (raw !== undefined || (namedOnly && !legacyPath)) {
|
|
655
|
+
if (raw !== undefined || namedOnly) {
|
|
839
656
|
const label = text(record(row["repository"], "Semgrep finding repository")["name"]);
|
|
840
657
|
const witness = parseSemgrepResponse(requiredText(raw, "Semgrep repository alias witness"));
|
|
841
658
|
if (!label ||
|
|
842
659
|
witness["name"] !== label ||
|
|
843
660
|
(witness["id"] == null && !text(witness["url"])))
|
|
844
661
|
throw new Error("Semgrep repository alias lacks a matching project ID or URL.");
|
|
845
|
-
checkSemgrepPlatformRow({ repository: witness }, scope, aliases ?? new Set([label]), repository,
|
|
846
|
-
? semgrepV1Id
|
|
847
|
-
: (id) => semgrepPlatformId(wireJson.rawJSON(savedPlatformId(id))));
|
|
662
|
+
checkSemgrepPlatformRow({ repository: witness }, scope, aliases ?? new Set([label]), repository, (id) => semgrepPlatformId(wireJson.rawJSON(savedPlatformId(id))));
|
|
848
663
|
}
|
|
849
664
|
const claimed = finding.evidence.details?.repository?.url;
|
|
850
665
|
if (finding.evidence.branch !== scope.ref ||
|
|
@@ -852,38 +667,28 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
|
|
|
852
667
|
(!!claimed &&
|
|
853
668
|
repository.key(hostedRepositoryUrl(claimed, "Semgrep evidence repository")) !== repository.key(scope.project.url)))
|
|
854
669
|
throw new Error("The normalized finding does not match its original Semgrep repository and ref.");
|
|
855
|
-
const canonical = platformSourceData(row, scope, selectable, aliases
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (!original &&
|
|
860
|
-
data["format"] === semgrepPlatformFormat &&
|
|
861
|
-
canonical.format === semgrepSelectionFormat) {
|
|
862
|
-
const selectedSeverity = platformSeverity(row["severity"], true);
|
|
863
|
-
if (selectedSeverity !== finding.evidence.severity &&
|
|
864
|
-
finding.evidence.severity === platformSeverity(row["severity"], false))
|
|
865
|
-
migration = { severity: selectedSeverity };
|
|
866
|
-
}
|
|
867
|
-
// The original reader projected the HTTP mapping when the native project URL used SSH.
|
|
868
|
-
const oldMappedUrl = original &&
|
|
869
|
-
scope.product !== "sca" &&
|
|
870
|
-
scope.nativeProjectUrl !== undefined &&
|
|
871
|
-
claimed === scope.sourceRepositoryUrl &&
|
|
872
|
-
claimed !== scope.project.url;
|
|
873
|
-
const details = migration?.details ?? finding.evidence.details;
|
|
670
|
+
const canonical = platformSourceData(row, scope, selectable, aliases !== undefined, namedOnly);
|
|
671
|
+
const { repositoryAliases: _aliases, repositoryWitnessJson: _witness, nativeProjectUrl: _native, ...metadata } = retained;
|
|
672
|
+
const selectedSeverity = platformSeverity(row["severity"], true);
|
|
673
|
+
const previousSeverity = platformSeverity(row["severity"], false);
|
|
874
674
|
return {
|
|
875
|
-
url
|
|
675
|
+
url,
|
|
876
676
|
nativeId,
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
677
|
+
// A reader-provided repository binding can promote a backlog row to a selected SAST row.
|
|
678
|
+
migration: retained["format"] === semgrepPlatformFormat &&
|
|
679
|
+
canonical.format === semgrepSelectionFormat &&
|
|
680
|
+
finding.evidence.severity === previousSeverity &&
|
|
681
|
+
previousSeverity !== selectedSeverity
|
|
682
|
+
? { severity: selectedSeverity }
|
|
683
|
+
: undefined,
|
|
684
|
+
sourceData: {
|
|
685
|
+
...metadata,
|
|
686
|
+
...canonical,
|
|
687
|
+
project: {
|
|
688
|
+
...record(retained["project"], "Semgrep project"),
|
|
689
|
+
...canonical.project,
|
|
690
|
+
},
|
|
691
|
+
},
|
|
887
692
|
};
|
|
888
693
|
}
|
|
889
694
|
/** Normalize a saved selection or Platform project export. The default target is local. */
|
|
@@ -891,15 +696,10 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
|
|
|
891
696
|
? (options.sourceRepositories ?? [])
|
|
892
697
|
: []) {
|
|
893
698
|
const declaredUrl = typeof options === "string" ? options : options.sourceRepositoryUrl;
|
|
894
|
-
const
|
|
895
|
-
const sourceFormat =
|
|
699
|
+
const input = record(report, "Semgrep Platform report");
|
|
700
|
+
const sourceFormat = input["format"];
|
|
896
701
|
if (!isSemgrepPlatformFormat(sourceFormat))
|
|
897
702
|
throw new Error("Expected a Semgrep Platform selection or project export.");
|
|
898
|
-
const legacy = sourceFormat === semgrepPlatformLegacyFormat;
|
|
899
|
-
const readId = legacy ? semgrepV1Id : semgrepPlatformId;
|
|
900
|
-
const input = legacy
|
|
901
|
-
? upgradeSemgrepPlatformReport(saved, declaredUrl, referenceRepositoryKey(references, target), references)
|
|
902
|
-
: saved;
|
|
903
703
|
const { scope, aliases } = readScope(input, references, target);
|
|
904
704
|
const repository = selectionRepository(scope.project.url, references, target);
|
|
905
705
|
if (declaredUrl &&
|
|
@@ -914,7 +714,7 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
|
|
|
914
714
|
const rows = entries.map((value) => {
|
|
915
715
|
const raw = requiredText(value, "Semgrep finding JSON");
|
|
916
716
|
const finding = parseSemgrepResponse(raw);
|
|
917
|
-
const selectable = checkSemgrepPlatformRow(finding, scope, aliases, repository
|
|
717
|
+
const selectable = checkSemgrepPlatformRow(finding, scope, aliases, repository);
|
|
918
718
|
if (aliases) {
|
|
919
719
|
const repo = record(finding["repository"] ?? {}, "Semgrep finding repository");
|
|
920
720
|
const label = text(repo["name"]);
|
|
@@ -926,27 +726,20 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
|
|
|
926
726
|
if (aliases && !matchesNativeInteger(input["findingCount"], rows.length))
|
|
927
727
|
throw new Error("Incomplete Semgrep Platform export: finding count does not match.");
|
|
928
728
|
if (aliases) {
|
|
929
|
-
// v1 also accepted decodeURI path labels. Keep a witness for their current-format replay.
|
|
930
|
-
const archiveNames = legacy
|
|
931
|
-
? legacyProjectAliases(scope.project.name, scope.project.url, references, scope.sourceRepositoryUrl)
|
|
932
|
-
: projectNames;
|
|
933
729
|
for (const { finding } of rows) {
|
|
934
|
-
const name = repositoryWithOnlyAlias(finding,
|
|
730
|
+
const name = repositoryWithOnlyAlias(finding, projectNames);
|
|
935
731
|
if (name && !verifiedLabels.has(name))
|
|
936
732
|
throw new Error("Semgrep finding repository lacks a matching project name, ID or URL.");
|
|
937
733
|
}
|
|
938
734
|
}
|
|
939
735
|
const unhintedNames = projectAliases(scope.project.name, scope.project.url);
|
|
940
|
-
const result = normalizePlatformRows(rows, scope, target, aliases
|
|
941
|
-
?
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
: undefined, aliases ? readId : archivedPlatformId);
|
|
736
|
+
const result = normalizePlatformRows(rows, scope, target, aliases && {
|
|
737
|
+
has: (name) => (verifiedLabels.has(name) ? unhintedNames : projectNames).has(name),
|
|
738
|
+
});
|
|
739
|
+
return { ...result, ...reportScope(sourceFormat, scope) };
|
|
740
|
+
}
|
|
741
|
+
function reportScope(sourceFormat, scope) {
|
|
948
742
|
return {
|
|
949
|
-
...result,
|
|
950
743
|
sourceFormat,
|
|
951
744
|
sourceRepositoryUrl: scope.project.url,
|
|
952
745
|
semgrepPlatformScope: {
|
|
@@ -957,12 +750,14 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
|
|
|
957
750
|
},
|
|
958
751
|
};
|
|
959
752
|
}
|
|
960
|
-
export function stringifySemgrepFinding(finding
|
|
753
|
+
export function stringifySemgrepFinding(finding) {
|
|
961
754
|
const repo = finding["repository"];
|
|
962
755
|
const nativeIds = [finding["id"], isRecord(repo) ? repo["id"] : undefined];
|
|
963
756
|
return JSON.stringify(finding, (_key, value) => {
|
|
964
757
|
if (wireJson.isRawJSON(value)) {
|
|
965
|
-
const id = nativeIds.includes(value)
|
|
758
|
+
const id = nativeIds.includes(value)
|
|
759
|
+
? semgrepPlatformIdOrUndefined(value)
|
|
760
|
+
: undefined;
|
|
966
761
|
return wireJson.rawJSON(id ?? canonicalNumber(value.rawJSON));
|
|
967
762
|
}
|
|
968
763
|
if (isRecord(value))
|
|
@@ -972,33 +767,22 @@ export function stringifySemgrepFinding(finding, idOf = semgrepPlatformIdOrUndef
|
|
|
972
767
|
return value;
|
|
973
768
|
});
|
|
974
769
|
}
|
|
975
|
-
function platformSourceData(finding, scope, selectable, bulk, namedOnly
|
|
770
|
+
function platformSourceData(finding, scope, selectable, bulk, namedOnly) {
|
|
976
771
|
const repo = record(finding["repository"] ?? {}, "Semgrep finding repository");
|
|
977
772
|
const label = text(repo["name"]);
|
|
978
|
-
// Ordinary v1 and v2 rows share one stored representation on replay.
|
|
979
|
-
// Preserve the legacy discriminator only when reopening the raw IDs needs it.
|
|
980
773
|
const { nativeProjectUrl, ...evidenceScope } = scope;
|
|
981
774
|
const nativeBulkScope = !selectable ||
|
|
982
775
|
scope.sourceRepositoryUrl !== undefined ||
|
|
983
776
|
nativeProjectUrl !== undefined;
|
|
984
|
-
const
|
|
985
|
-
[finding["id"], repo["id"]].some((id) => typeof id === "string" &&
|
|
986
|
-
semgrepPlatformIdOrUndefined(id) === undefined);
|
|
987
|
-
// Native SAST rows with their own repository and ref replay identically in either import mode.
|
|
988
|
-
const needsBulkScope = bulk && (nativeBulkScope || needsLegacyId);
|
|
777
|
+
const needsBulkScope = bulk && nativeBulkScope;
|
|
989
778
|
return {
|
|
990
|
-
format:
|
|
991
|
-
? semgrepPlatformLegacyFormat
|
|
992
|
-
: needsBulkScope
|
|
993
|
-
? semgrepPlatformFormat
|
|
994
|
-
: semgrepSelectionFormat,
|
|
779
|
+
format: needsBulkScope ? semgrepPlatformFormat : semgrepSelectionFormat,
|
|
995
780
|
...evidenceScope,
|
|
996
781
|
project: {
|
|
997
782
|
...scope.project,
|
|
998
783
|
url: nativeProjectUrl ??
|
|
999
784
|
(scope.sourceRepositoryUrl ? null : scope.project.url),
|
|
1000
785
|
},
|
|
1001
|
-
...(needsLegacyId && { idEncoding: "v1-decimal" }),
|
|
1002
786
|
...(needsBulkScope && { repositoryAliases: label ? [label] : [] }),
|
|
1003
787
|
// Store the verified binding independently of the native fields retained on its proving row.
|
|
1004
788
|
...(namedOnly && {
|
|
@@ -1007,35 +791,34 @@ function platformSourceData(finding, scope, selectable, bulk, namedOnly, idOf =
|
|
|
1007
791
|
name: namedOnly,
|
|
1008
792
|
}),
|
|
1009
793
|
}),
|
|
1010
|
-
semgrepPlatformFindingJson: stringifySemgrepFinding(finding
|
|
794
|
+
semgrepPlatformFindingJson: stringifySemgrepFinding(finding),
|
|
1011
795
|
};
|
|
1012
796
|
}
|
|
1013
797
|
// Selected rows and complete captures share their evidence projection and identity tuple.
|
|
1014
|
-
function normalizePlatformRows(rows, scope, target,
|
|
1015
|
-
const legacy = bulk?.legacy;
|
|
798
|
+
function normalizePlatformRows(rows, scope, target, projectNames) {
|
|
1016
799
|
return normalizeRecords(rows, ({ finding, selectable }) => {
|
|
1017
800
|
const rule = responseRecord(finding["rule"] ?? {}, "Semgrep rule");
|
|
1018
801
|
const name = text(rule["name"]) ?? text(finding["rule_name"]);
|
|
1019
802
|
const description = text(rule["message"]) ?? text(finding["rule_message"]);
|
|
1020
803
|
const location = responseRecord(finding["location"] ?? {}, "Semgrep location");
|
|
1021
|
-
const { locations, endLine } = platformLocation(location, scope.product, selectable
|
|
1022
|
-
const namedOnly =
|
|
804
|
+
const { locations, endLine } = platformLocation(location, scope.product, !!projectNames && !selectable);
|
|
805
|
+
const namedOnly = projectNames && repositoryWithOnlyAlias(finding, projectNames);
|
|
1023
806
|
const common = {
|
|
1024
807
|
description,
|
|
1025
808
|
severity: platformSeverity(finding["severity"], selectable),
|
|
1026
809
|
locations,
|
|
1027
810
|
branch: scope.ref,
|
|
1028
|
-
source_data: platformSourceData(finding, scope, selectable,
|
|
811
|
+
source_data: platformSourceData(finding, scope, selectable, projectNames !== undefined, namedOnly),
|
|
1029
812
|
};
|
|
1030
813
|
let messageTitle = description ??
|
|
1031
|
-
(
|
|
814
|
+
(scope.product === "sast"
|
|
1032
815
|
? null
|
|
1033
|
-
: `Semgrep finding ${
|
|
816
|
+
: `Semgrep finding ${semgrepPlatformId(finding["id"])}`);
|
|
1034
817
|
if (target === "cloud" &&
|
|
1035
818
|
description &&
|
|
1036
819
|
Buffer.byteLength(description) > DEFAULT_CLOUD_STRING_BYTES) {
|
|
1037
820
|
const id = finding["id"];
|
|
1038
|
-
messageTitle = `Semgrep finding ${text(id) ??
|
|
821
|
+
messageTitle = `Semgrep finding ${text(id) ?? semgrepPlatformId(id)}`;
|
|
1039
822
|
}
|
|
1040
823
|
if (scope.product === "sca") {
|
|
1041
824
|
const dependency = responseRecord(finding["found_dependency"] ?? {}, "Semgrep found dependency");
|
|
@@ -1073,6 +856,6 @@ function normalizePlatformRows(rows, scope, target, bulk, readId = bulk?.legacy
|
|
|
1073
856
|
code: { end_line: endLine },
|
|
1074
857
|
},
|
|
1075
858
|
}, target);
|
|
1076
|
-
}, ({ finding }) => sourceId(scope, finding
|
|
859
|
+
}, ({ finding }) => sourceId(scope, finding), target);
|
|
1077
860
|
}
|
|
1078
861
|
//# sourceMappingURL=semgrep-platform-findings.js.map
|