@openai/codex-security 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +2 -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/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/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +29 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +29 -3
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- 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 +244 -217
- 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 +281 -119
- package/_bundled_plugin/scripts/workbench_scan_start.py +143 -9
- 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_target.py +471 -84
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +60 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +24 -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/collect_continuum.py +224 -0
- 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 +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +437 -154
- 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.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 +5 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1763 -894
- 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-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-findings.d.ts +1 -1
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +93 -31
- package/dist/continuum-findings.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/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 +234 -53
- 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 +326 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +1 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +31 -51
- 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 +3 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +29 -176
- 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/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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +79 -37
- 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.d.ts.map +1 -1
- package/dist/project-config.js +53 -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 +778 -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.map +1 -1
- package/dist/scan-comparison.js +6 -2
- 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/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/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 +104 -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 +6 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +76 -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 +6 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +140 -37
- package/dist/trusted-executable.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/cli.md +373 -106
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +903 -0
- package/package.json +10 -6
- package/schemas/external-findings.schema.json +2 -1
- 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,17 +1,15 @@
|
|
|
1
|
-
import { validateExternalEvidence, } from "./external-import-contract.js";
|
|
1
|
+
import { canonicalNumber, validateExternalEvidence, } from "./external-import-contract.js";
|
|
2
2
|
import { snapshotSourceRepositories, } from "./external-findings.js";
|
|
3
|
-
import {
|
|
4
|
-
import { snykRepositoryUrls } from "./snyk-findings.js";
|
|
3
|
+
import { isSnykRestFormat, SNYK_REST_ISSUES_FORMAT, snykRepositoryUrls, } from "./snyk-findings.js";
|
|
5
4
|
import { isGitHubCloudHost } from "./git-remote.js";
|
|
6
5
|
import { gitPathToHttpPath, ambiguousGitIpHost, gitServiceHostname, gitTransportBytes, hostedRepositoryMatches, hostedRepositoryUrlKey, isPublicGitHost, normalizeHostedGitRepositoryUrl, } from "./hosted-git-repository.js";
|
|
7
6
|
import { hostedNumberToken, parseHostedScannerJson, stringifyHostedEvidence, hostedScannerHttp, hostedRepositoryUrl, } from "./hosted-scanner-http.js";
|
|
8
7
|
import { isRecord } from "./record.js";
|
|
9
|
-
import { legacyDecimalInteger } from "./hosted-scanner-v1.js";
|
|
10
8
|
import { isSafeNonNegativeInteger } from "./value.js";
|
|
11
9
|
import { checkSnykTokenOrigin, snykApiToken } from "./snyk-token-origin.js";
|
|
12
10
|
import { regexes } from "zod/v4/core";
|
|
13
11
|
import { array, normalizeRecords, record as scannerRecord, hostedRepositoryPath, repositoryFilePath, requiredText, scannerSeverity, stableId, strings, text, } from "./scanner-import.js";
|
|
14
|
-
export {
|
|
12
|
+
export { isSnykRestFormat, SNYK_REST_ISSUES_FORMAT };
|
|
15
13
|
const issueTimestamp = new RegExp(regexes.datetime({ offset: true }).source, "i");
|
|
16
14
|
export const snykRestApiVersion = "2026-03-25";
|
|
17
15
|
const formatVersion = {
|
|
@@ -201,8 +199,6 @@ function trustedScmBinding(url, references, allowGitHub, allowGitLab) {
|
|
|
201
199
|
}
|
|
202
200
|
return { url };
|
|
203
201
|
}
|
|
204
|
-
class SnykTargetRepositoryMismatch extends Error {
|
|
205
|
-
}
|
|
206
202
|
function checkRemote(remote, selected, origin, references) {
|
|
207
203
|
if (remote === null || remote === "")
|
|
208
204
|
return;
|
|
@@ -222,7 +218,7 @@ function checkRemote(remote, selected, origin, references) {
|
|
|
222
218
|
gitlab,
|
|
223
219
|
};
|
|
224
220
|
if (!snykRestRepositoryMatches(binding, url))
|
|
225
|
-
throw new
|
|
221
|
+
throw new Error("Snyk target URL does not match the selected source repository URL.");
|
|
226
222
|
return {
|
|
227
223
|
github,
|
|
228
224
|
enterprise,
|
|
@@ -572,117 +568,30 @@ function linkedSnykResources(data, json, hosted) {
|
|
|
572
568
|
}
|
|
573
569
|
return {};
|
|
574
570
|
}
|
|
575
|
-
function retainedRelationship(resource, name) {
|
|
576
|
-
const links = resource?.["relationships"];
|
|
577
|
-
const relation = isRecord(links) ? links[name] : undefined;
|
|
578
|
-
const data = isRecord(relation) ? relation["data"] : undefined;
|
|
579
|
-
if (data === null)
|
|
580
|
-
return null;
|
|
581
|
-
if (isRecord(data) &&
|
|
582
|
-
(data["type"] === name ||
|
|
583
|
-
(name === "organization" && data["type"] === "org")))
|
|
584
|
-
return data;
|
|
585
|
-
}
|
|
586
|
-
/** Read only vendor-typed claims still present in an already-approved request. */
|
|
587
|
-
function retainedSnykAssets(data) {
|
|
588
|
-
const assets = [];
|
|
589
|
-
const id = (resource) => {
|
|
590
|
-
const value = resource?.["id"];
|
|
591
|
-
return isUuid(value) ? value.toLowerCase() : undefined;
|
|
592
|
-
};
|
|
593
|
-
for (const json of [false, true]) {
|
|
594
|
-
const project = originalSnykResource(data, "project", json);
|
|
595
|
-
let expanded;
|
|
596
|
-
if (project?.["type"] === "project") {
|
|
597
|
-
const attributes = project["attributes"];
|
|
598
|
-
const origin = isRecord(attributes) ? attributes["origin"] : undefined;
|
|
599
|
-
expanded = retainedRelationship(project, "target");
|
|
600
|
-
assets.push({
|
|
601
|
-
projectId: id(project),
|
|
602
|
-
product: projectProduct(isRecord(attributes) ? attributes["type"] : undefined),
|
|
603
|
-
targetId: expanded === null ? null : undefined,
|
|
604
|
-
organizationId: id(retainedRelationship(project, "organization")),
|
|
605
|
-
origin: typeof origin === "string" && scmOrigins.has(origin)
|
|
606
|
-
? origin
|
|
607
|
-
: undefined,
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
for (const target of [
|
|
611
|
-
expanded,
|
|
612
|
-
originalSnykResource(data, "target", json),
|
|
613
|
-
]) {
|
|
614
|
-
if (target?.["type"] !== "target")
|
|
615
|
-
continue;
|
|
616
|
-
const attributes = target["attributes"];
|
|
617
|
-
const url = isRecord(attributes) ? attributes["url"] : undefined;
|
|
618
|
-
const integration = retainedRelationship(target, "integration");
|
|
619
|
-
const integrationAttributes = integration?.["attributes"];
|
|
620
|
-
const type = isRecord(integrationAttributes)
|
|
621
|
-
? integrationAttributes["integration_type"]
|
|
622
|
-
: undefined;
|
|
623
|
-
assets.push({
|
|
624
|
-
url: typeof url === "string" ? url : undefined,
|
|
625
|
-
targetId: id(target),
|
|
626
|
-
integrationId: id(integration),
|
|
627
|
-
deployment: typeof type === "string"
|
|
628
|
-
? concreteDeployment(scmOrigins.get(type))
|
|
629
|
-
: undefined,
|
|
630
|
-
organizationId: id(retainedRelationship(target, "organization")),
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return assets;
|
|
635
|
-
}
|
|
636
571
|
function snykRowEvidence(finding, hostedReport = false) {
|
|
637
572
|
const retained = finding.evidence.source_data;
|
|
638
573
|
const marked = snykRestId.test(finding.source_finding_id) ||
|
|
639
574
|
isSnykRestFormat(retained?.["format"]);
|
|
640
575
|
const hosted = hostedReport || marked;
|
|
641
|
-
const
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
644
|
-
return {
|
|
576
|
+
const original = retained && linkedSnykResources(retained, true, hosted);
|
|
577
|
+
const retired = retained && linkedSnykResources(retained, false, hosted);
|
|
578
|
+
if (original || retired || marked)
|
|
579
|
+
return { ...original, retired };
|
|
645
580
|
}
|
|
646
581
|
export function isSnykRestFinding(finding) {
|
|
647
582
|
return snykRowEvidence(finding) !== undefined;
|
|
648
583
|
}
|
|
649
|
-
/** Recover the native occurrence from an earlier normalized submission with a caller-assigned ID. */
|
|
650
|
-
export function snykRestCheckpointFindingId(finding, references) {
|
|
651
|
-
const data = finding.evidence.source_data;
|
|
652
|
-
const evidence = snykRowEvidence(finding);
|
|
653
|
-
if (!data || (!evidence?.v1?.issue && !evidence?.v2?.issue))
|
|
654
|
-
return;
|
|
655
|
-
const format = evidence.v2?.issue
|
|
656
|
-
? SNYK_REST_ISSUES_FORMAT
|
|
657
|
-
: SNYK_REST_ISSUES_V1;
|
|
658
|
-
const document = readSnykRestDocument({
|
|
659
|
-
...data,
|
|
660
|
-
format: data["format"] ?? format,
|
|
661
|
-
});
|
|
662
|
-
const { source } = savedContext(document, references);
|
|
663
|
-
const issue = parseHostedScannerJson(requiredText(document["issueJson"], "Snyk original issue"));
|
|
664
|
-
const { attributes } = selectedIssue(scopedIssue(issue, source), source);
|
|
665
|
-
return snykIssueId(attributes, source, data["snykRestIssueKey"]);
|
|
666
|
-
}
|
|
667
|
-
export function snykRestFindingRepository(finding, references = []) {
|
|
668
|
-
return bindSnykFinding(finding, references, snykRowEvidence(finding));
|
|
669
|
-
}
|
|
670
584
|
function bindSnykFinding(finding, references, originals, report, retain) {
|
|
671
585
|
const retained = record(finding.evidence.source_data, "Original Snyk REST issue evidence");
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
if (isSnykRestFormat(format) &&
|
|
678
|
-
(format === SNYK_REST_ISSUES_V1 ? originals?.v2 : originals?.v1))
|
|
679
|
-
throw new Error("A normalized Snyk row cannot claim both v1 and v2 native representations.");
|
|
680
|
-
const document = readSnykRestDocument({ ...retained, format }, report?.fields);
|
|
681
|
-
const issue = (format === SNYK_REST_ISSUES_FORMAT ? originals?.v2?.issue : undefined) ??
|
|
586
|
+
if (originals?.retired)
|
|
587
|
+
throw new Error("A Snyk REST finding must use the current collector's original JSON evidence.");
|
|
588
|
+
const format = retained["format"] ?? SNYK_REST_ISSUES_FORMAT;
|
|
589
|
+
const document = { ...retained, format };
|
|
590
|
+
const issue = originals?.issue ??
|
|
682
591
|
parseHostedScannerJson(requiredText(document["issueJson"], "Snyk original issue"));
|
|
683
592
|
// A selected issue can retain any of its original monitor fields. Fill only those it omitted.
|
|
684
593
|
let projected = false;
|
|
685
|
-
if (report &&
|
|
594
|
+
if (report && originals?.issue) {
|
|
686
595
|
for (const [field, value] of Object.entries(report.fields)) {
|
|
687
596
|
if (document[field] !== undefined)
|
|
688
597
|
continue;
|
|
@@ -700,29 +609,7 @@ function bindSnykFinding(finding, references, originals, report, retain) {
|
|
|
700
609
|
const { id: issueId, attributes } = selectedIssue(scopedIssue(issue, source), source);
|
|
701
610
|
verifySnykFindingId(finding, attributes, source);
|
|
702
611
|
projectSnykIssue(attributes, asset, { ...retained, format }, "local");
|
|
703
|
-
if (retain
|
|
704
|
-
// The legacy witness stores the original decimal token, including its spelling.
|
|
705
|
-
const context = projected
|
|
706
|
-
? encodeSnykV1File({
|
|
707
|
-
...repository.scope,
|
|
708
|
-
apiVersion: source.apiVersion,
|
|
709
|
-
format,
|
|
710
|
-
project: asset.project,
|
|
711
|
-
target: asset.target,
|
|
712
|
-
})
|
|
713
|
-
: { format };
|
|
714
|
-
retain(finding, {
|
|
715
|
-
...retained,
|
|
716
|
-
...context,
|
|
717
|
-
...(isRecord(context["numericFields"]) && {
|
|
718
|
-
numericFields: {
|
|
719
|
-
...context["numericFields"],
|
|
720
|
-
...(isRecord(retained["numericFields"]) && retained["numericFields"]),
|
|
721
|
-
},
|
|
722
|
-
}),
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
else if (retain && format === SNYK_REST_ISSUES_FORMAT) {
|
|
612
|
+
if (retain) {
|
|
726
613
|
retain(finding, {
|
|
727
614
|
...retained,
|
|
728
615
|
...(projected && source),
|
|
@@ -772,14 +659,14 @@ function problemIds(entries, type) {
|
|
|
772
659
|
}
|
|
773
660
|
return [...ids];
|
|
774
661
|
}
|
|
775
|
-
function findingFilePath(value
|
|
662
|
+
function findingFilePath(value) {
|
|
776
663
|
const path = hostedRepositoryPath(value);
|
|
777
|
-
if (
|
|
664
|
+
if (path?.endsWith("/.") || !repositoryFilePath(path))
|
|
778
665
|
return null;
|
|
779
666
|
return path;
|
|
780
667
|
}
|
|
781
|
-
function packageEvidence(coordinates, { manager, targetFile }
|
|
782
|
-
const manifest = findingFilePath(targetFile
|
|
668
|
+
function packageEvidence(coordinates, { manager, targetFile }) {
|
|
669
|
+
const manifest = findingFilePath(targetFile);
|
|
783
670
|
const packages = [];
|
|
784
671
|
for (const coordinate of coordinates) {
|
|
785
672
|
const fixed = records(coordinate, "remedies").flatMap((remedy) => {
|
|
@@ -807,10 +694,15 @@ function packageEvidence(coordinates, { manager, targetFile }, v2) {
|
|
|
807
694
|
function codeStartLine(region) {
|
|
808
695
|
const start = isRecord(region) ? region["start"] : undefined;
|
|
809
696
|
const token = isRecord(start) ? hostedNumberToken(start["line"]) : undefined;
|
|
810
|
-
const line =
|
|
811
|
-
return
|
|
812
|
-
|
|
813
|
-
|
|
697
|
+
const line = Number(token);
|
|
698
|
+
return token &&
|
|
699
|
+
isSafeNonNegativeInteger(line) &&
|
|
700
|
+
line > 0 &&
|
|
701
|
+
String(line) === canonicalNumber(token)
|
|
702
|
+
? line
|
|
703
|
+
: null;
|
|
704
|
+
}
|
|
705
|
+
function codeEvidence(coordinates, scm) {
|
|
814
706
|
const locations = [];
|
|
815
707
|
const revisions = new Set();
|
|
816
708
|
for (const coordinate of coordinates) {
|
|
@@ -820,9 +712,9 @@ function codeEvidence(coordinates, scm, v2) {
|
|
|
820
712
|
continue;
|
|
821
713
|
const location = record(value, "Snyk source location");
|
|
822
714
|
revisions.add(text(location["commit_id"]));
|
|
823
|
-
const path = findingFilePath(location["file"]
|
|
715
|
+
const path = findingFilePath(location["file"]);
|
|
824
716
|
if (scm && path)
|
|
825
|
-
locations.push(
|
|
717
|
+
locations.push({ path, line: codeStartLine(location["region"]) });
|
|
826
718
|
}
|
|
827
719
|
}
|
|
828
720
|
return {
|
|
@@ -832,7 +724,6 @@ function codeEvidence(coordinates, scm, v2) {
|
|
|
832
724
|
}
|
|
833
725
|
function projectSnykIssue(attributes, { source, context }, sourceData, target) {
|
|
834
726
|
const code = source.product === "code";
|
|
835
|
-
const v2 = sourceData["format"] !== SNYK_REST_ISSUES_V1;
|
|
836
727
|
const status = attributes["status"];
|
|
837
728
|
if ((status !== "open" && status !== "resolved") ||
|
|
838
729
|
typeof attributes["ignored"] !== "boolean")
|
|
@@ -854,9 +745,9 @@ function projectSnykIssue(attributes, { source, context }, sourceData, target) {
|
|
|
854
745
|
severity: severity === "info" ? "informational" : scannerSeverity(severity),
|
|
855
746
|
advisory_ids: code ? [] : problemIds(problems),
|
|
856
747
|
...(code
|
|
857
|
-
? codeEvidence(activeCoordinates, context.scm
|
|
748
|
+
? codeEvidence(activeCoordinates, context.scm)
|
|
858
749
|
: {
|
|
859
|
-
packages: packageEvidence(activeCoordinates, context
|
|
750
|
+
packages: packageEvidence(activeCoordinates, context),
|
|
860
751
|
}),
|
|
861
752
|
source_updated_at: Math.floor(updated / 1000),
|
|
862
753
|
source_data: sourceData,
|
|
@@ -873,27 +764,23 @@ function projectSnykIssue(attributes, { source, context }, sourceData, target) {
|
|
|
873
764
|
}, target);
|
|
874
765
|
}
|
|
875
766
|
export function normalizeSnykIssues(input, target = "local", references = []) {
|
|
876
|
-
const
|
|
877
|
-
const document = readSnykRestDocument(wire);
|
|
767
|
+
const document = record(input, "Snyk REST Issues export");
|
|
878
768
|
const asset = savedContext(document, references);
|
|
879
769
|
const { source, repository } = asset;
|
|
880
770
|
const issues = readIssues(document, source);
|
|
881
|
-
const legacy = originalSnykEvidence(wire, source);
|
|
882
771
|
// normalizeRecords identifies every row before projecting any evidence.
|
|
883
772
|
const resourceCounts = new Map();
|
|
884
|
-
const result = normalizeRecords(issues
|
|
773
|
+
const result = normalizeRecords(issues, (issue) => {
|
|
885
774
|
if (resourceCounts.get(resourceId(issue, "issue")) > 1)
|
|
886
775
|
throw new Error("The saved Snyk report contains overlapping issue IDs.");
|
|
887
776
|
const attributes = record(issue["attributes"], "Snyk issue attributes");
|
|
888
|
-
const sourceData =
|
|
889
|
-
|
|
890
|
-
:
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
issueJson: stringifyHostedEvidence(issue),
|
|
894
|
-
};
|
|
777
|
+
const sourceData = {
|
|
778
|
+
...source,
|
|
779
|
+
snykRestIssueKey: attributes["key"],
|
|
780
|
+
issueJson: stringifyHostedEvidence(issue),
|
|
781
|
+
};
|
|
895
782
|
return projectSnykIssue(attributes, asset, sourceData, target);
|
|
896
|
-
}, (
|
|
783
|
+
}, (issue) => {
|
|
897
784
|
const identifier = resourceIdentifier(issue, "issue");
|
|
898
785
|
const raw = issue["attributes"];
|
|
899
786
|
const product = isRecord(raw) ? raw["type"] : undefined;
|
|
@@ -911,13 +798,13 @@ export function normalizeSnykIssues(input, target = "local", references = []) {
|
|
|
911
798
|
...(repository.platform && {
|
|
912
799
|
sourceRepositoryPlatform: repository.platform,
|
|
913
800
|
}),
|
|
914
|
-
snykRestContext:
|
|
801
|
+
snykRestContext: source,
|
|
915
802
|
};
|
|
916
803
|
}
|
|
917
804
|
/** Reconcile the original records, normalized projections, and reader or destination URLs. */
|
|
918
|
-
export function snykRestImportRepository(input, provider, urls = [], trustedSources = [], retain,
|
|
805
|
+
export function snykRestImportRepository(input, provider, urls = [], trustedSources = [], retain, declaredCloudRepository) {
|
|
919
806
|
const project = input.snykRestContext !== undefined
|
|
920
|
-
? savedContext(
|
|
807
|
+
? savedContext(record(input.snykRestContext, "Snyk report context"), trustedSources)
|
|
921
808
|
: undefined;
|
|
922
809
|
const rows = input.findings.map((finding) => ({
|
|
923
810
|
finding,
|
|
@@ -934,27 +821,8 @@ export function snykRestImportRepository(input, provider, urls = [], trustedSour
|
|
|
934
821
|
targetJson: JSON.stringify(project.target),
|
|
935
822
|
},
|
|
936
823
|
};
|
|
937
|
-
const retainedIssues = [];
|
|
938
|
-
const retainedRows = [];
|
|
939
824
|
const boundRows = hosted
|
|
940
|
-
? rows.
|
|
941
|
-
try {
|
|
942
|
-
return [
|
|
943
|
-
bindSnykFinding(finding, trustedSources, originals, context, retain),
|
|
944
|
-
];
|
|
945
|
-
}
|
|
946
|
-
catch (error) {
|
|
947
|
-
if (!allowOpaqueLegacyRows ||
|
|
948
|
-
error instanceof SnykTargetRepositoryMismatch)
|
|
949
|
-
throw error;
|
|
950
|
-
for (const issue of [originals?.v1?.issue, originals?.v2?.issue])
|
|
951
|
-
if (issue)
|
|
952
|
-
retainedIssues.push({ finding, issue });
|
|
953
|
-
if (originals && finding.evidence.source_data)
|
|
954
|
-
retainedRows.push(finding.evidence.source_data);
|
|
955
|
-
return [];
|
|
956
|
-
}
|
|
957
|
-
})
|
|
825
|
+
? rows.map(({ finding, originals }) => bindSnykFinding(finding, trustedSources, originals, context, retain))
|
|
958
826
|
: [];
|
|
959
827
|
const selected = project?.repository.scope ?? boundRows[0]?.scope;
|
|
960
828
|
const bindings = project ? [...boundRows, project.repository] : boundRows;
|
|
@@ -967,51 +835,13 @@ export function snykRestImportRepository(input, provider, urls = [], trustedSour
|
|
|
967
835
|
boundRows.some((row) => (project.repository.targetId && !row.targetId) ||
|
|
968
836
|
(project.repository.nativeUrl && !row.nativeUrl)))
|
|
969
837
|
throw new Error("The selected Snyk finding is missing the report's native target. Keep its full project or omit the project to use the report context.");
|
|
970
|
-
const retainedAssets = retainedRows.flatMap(retainedSnykAssets);
|
|
971
|
-
const monitorBindings = [...bindings, ...retainedAssets];
|
|
972
838
|
for (const key of ["targetId", "integrationId", "deployment"]) {
|
|
973
|
-
|
|
974
|
-
if (key === "deployment" && !bindings.some((binding) => binding.deployment))
|
|
975
|
-
continue;
|
|
976
|
-
const ids = new Set(monitorBindings
|
|
977
|
-
.map((binding) => binding[key])
|
|
978
|
-
.filter((id) => id !== undefined));
|
|
839
|
+
const ids = new Set(bindings.map((binding) => binding[key]).filter((id) => id !== undefined));
|
|
979
840
|
if (ids.size > 1)
|
|
980
841
|
throw new Error("The Snyk project scope names conflicting targets or integrations.");
|
|
981
842
|
}
|
|
982
843
|
const scopes = boundRows.map(({ scope }) => scope);
|
|
983
844
|
const claims = new Set(bindings.map((binding) => binding.url));
|
|
984
|
-
const retainedScms = [];
|
|
985
|
-
for (const { url, origin, product, projectId, organizationId, } of retainedAssets) {
|
|
986
|
-
if (url)
|
|
987
|
-
claims.add(url);
|
|
988
|
-
if (origin)
|
|
989
|
-
retainedScms.push(reportedScm(repositoryUrl, origin));
|
|
990
|
-
if (selected)
|
|
991
|
-
scopes.push({
|
|
992
|
-
...selected,
|
|
993
|
-
projectId: projectId ?? selected.projectId,
|
|
994
|
-
organizationId: organizationId ?? selected.organizationId,
|
|
995
|
-
product: product ?? selected.product,
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
// Already-approved rows can lack the original project while retaining a
|
|
999
|
-
// monitored issue, partial scope, or source URL that contradicts a new claim.
|
|
1000
|
-
if (selected) {
|
|
1001
|
-
for (const { finding, issue } of retainedIssues) {
|
|
1002
|
-
const { attributes } = selectedIssue(scopedIssue(issue, selected), selected);
|
|
1003
|
-
if (snykRestId.test(finding.source_finding_id))
|
|
1004
|
-
verifySnykFindingId(finding, attributes, selected);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
for (const { sourceRepositoryUrl, ...fields } of retainedRows) {
|
|
1008
|
-
if (sourceRepositoryUrl !== undefined)
|
|
1009
|
-
claims.add(requiredText(sourceRepositoryUrl, "Snyk source repository URL"));
|
|
1010
|
-
if (selected) {
|
|
1011
|
-
const supplied = { ...selected, ...fields };
|
|
1012
|
-
scopes.push(scope(supplied, supplied.apiOrigin));
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
845
|
if (bindings.some((binding) => binding.scm !== bindings[0]?.scm) ||
|
|
1016
846
|
(selected &&
|
|
1017
847
|
scopes.some((scope) => scope.apiOrigin !== selected.apiOrigin ||
|
|
@@ -1039,9 +869,7 @@ export function snykRestImportRepository(input, provider, urls = [], trustedSour
|
|
|
1039
869
|
claims.add(url);
|
|
1040
870
|
// Saved SCM metadata can contradict a caller's mapping but cannot establish one.
|
|
1041
871
|
const source = trustedScmBinding(repositoryUrl, trustedSources, input.sourceRepositoryPlatform !== "other" &&
|
|
1042
|
-
retainedScms.every(({ github }) => github) &&
|
|
1043
872
|
bindings.every((binding) => binding.platform !== "other" && !binding.gitlab), input.sourceRepositoryPlatform !== "github" &&
|
|
1044
|
-
retainedScms.every(({ gitlab }) => gitlab) &&
|
|
1045
873
|
bindings.every((binding) => binding.gitlab || binding.platform === undefined));
|
|
1046
874
|
for (const url of claims)
|
|
1047
875
|
if (!snykRestRepositoryMatches(source, url))
|