@openai/codex-security 0.1.31 → 0.3.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 +442 -2434
- package/_bundled_plugin/.app.json +5 -1
- package/_bundled_plugin/.codex-plugin/plugin.json +9 -5
- package/_bundled_plugin/.mcp.json +3 -0
- package/_bundled_plugin/examples/completed-scan/coverage.json +0 -1
- package/_bundled_plugin/examples/completed-scan/report.md +28 -26
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +1 -1
- package/_bundled_plugin/mcp/helpers.mjs +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +7 -214
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +563 -0
- package/_bundled_plugin/mcp/server.mjs +1 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -13
- package/_bundled_plugin/references/artifact-storage.md +5 -5
- package/_bundled_plugin/references/config-preflight.md +1 -5
- package/_bundled_plugin/references/core-scan.md +34 -10
- package/_bundled_plugin/references/final-report.md +13 -13
- package/_bundled_plugin/references/finding-detail-fields.md +90 -80
- package/_bundled_plugin/references/sarif-adapter.md +1 -1
- package/_bundled_plugin/references/scan-artifacts.md +3 -4
- package/_bundled_plugin/references/scan-contract.md +11 -6
- package/_bundled_plugin/references/scan-prologue.md +12 -0
- package/_bundled_plugin/references/security-guidance.md +2 -2
- package/_bundled_plugin/references/standalone-validation.md +11 -0
- package/_bundled_plugin/references/threat-model.md +2 -2
- package/_bundled_plugin/schemas/coverage.schema.json +23 -47
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +2 -24
- package/_bundled_plugin/schemas/definitions/discovery-candidate.schema.json +49 -25
- package/_bundled_plugin/schemas/findings.schema.json +71 -192
- package/_bundled_plugin/schemas/scan-manifest.schema.json +83 -95
- package/_bundled_plugin/schemas/tools/candidate-attack-paths.schema.json +91 -83
- package/_bundled_plugin/schemas/tools/candidate-validations.schema.json +35 -64
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +5 -2
- package/_bundled_plugin/schemas/tools/discovery-candidates.schema.json +6 -55
- package/_bundled_plugin/schemas/tools/review-items.schema.json +2 -38
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +245 -356
- package/_bundled_plugin/scripts/codex_profile.mjs +239 -0
- package/_bundled_plugin/scripts/codex_session.mjs +53 -0
- package/_bundled_plugin/scripts/config_preflight.py +29 -69
- package/_bundled_plugin/scripts/deep_scan_config.py +9 -11
- package/_bundled_plugin/scripts/deep_scan_workbench.py +208 -363
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
- package/_bundled_plugin/scripts/finalize_scan_contract.py +733 -375
- package/_bundled_plugin/scripts/finding_preview.py +81 -91
- package/_bundled_plugin/scripts/generate_in_scope_files.py +48 -102
- package/_bundled_plugin/scripts/generate_rank_input.py +117 -888
- package/_bundled_plugin/scripts/launch_codex_security_mcp +35 -6
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +5 -5
- package/_bundled_plugin/scripts/rank_preview.py +43 -902
- package/_bundled_plugin/scripts/report_projection.py +143 -219
- package/_bundled_plugin/scripts/snapshot_sqlite.py +6 -1
- package/_bundled_plugin/scripts/threat_model_projection.py +161 -0
- package/_bundled_plugin/scripts/validate_scan_contract.py +4 -34
- package/_bundled_plugin/scripts/validate_tracking_source.py +3 -13
- package/_bundled_plugin/scripts/windows_scan_local_files.py +59 -9
- package/_bundled_plugin/scripts/workbench/handoff.py +25 -50
- package/_bundled_plugin/scripts/workbench/runtime_toml.py +22 -0
- package/_bundled_plugin/scripts/workbench/storage.py +21 -6
- package/_bundled_plugin/scripts/workbench_cli.py +99 -190
- package/_bundled_plugin/scripts/workbench_constants.py +6 -14
- package/_bundled_plugin/scripts/workbench_db.py +524 -672
- package/_bundled_plugin/scripts/workbench_feedback.py +6 -3
- package/_bundled_plugin/scripts/workbench_finding_index.py +20 -7
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +18 -4
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +136 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +28 -18
- package/_bundled_plugin/scripts/workbench_progress.py +26 -92
- package/_bundled_plugin/scripts/workbench_publication.py +77 -116
- package/_bundled_plugin/scripts/workbench_remediation.py +14 -20
- package/_bundled_plugin/scripts/workbench_saved_results.py +1402 -263
- package/_bundled_plugin/scripts/workbench_scan_history.py +57 -57
- package/_bundled_plugin/scripts/workbench_scan_start.py +109 -52
- package/_bundled_plugin/scripts/workbench_scan_usage.py +30 -49
- package/_bundled_plugin/scripts/workbench_schema.py +71 -1370
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +16 -7
- package/_bundled_plugin/scripts/workbench_target.py +526 -150
- package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
- package/_bundled_plugin/scripts/workbench_validation.py +19 -44
- package/_bundled_plugin/shared/workbench-history-repairs.json +218 -0
- package/_bundled_plugin/shared/workbench-migrations.json +397 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +15 -4
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +54 -0
- package/_bundled_plugin/skills/cloud-findings/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +6 -6
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +3 -3
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +50 -20
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +8 -14
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +22 -7
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +13 -1
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
- package/_bundled_plugin/skills/track-findings/SKILL.md +46 -178
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +16 -24
- package/_bundled_plugin/skills/track-findings/references/jira.md +15 -61
- package/_bundled_plugin/skills/triage-finding/SKILL.md +50 -289
- package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +23 -43
- package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +7 -1
- package/bin/codex-security.mjs +9 -2
- package/dist/api.d.ts +63 -15
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +970 -553
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +70 -0
- package/dist/artifact-export.d.ts.map +1 -0
- package/dist/artifact-export.js +292 -0
- package/dist/artifact-export.js.map +1 -0
- package/dist/auth.d.ts +2 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +27 -12
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +9 -9
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +2 -5
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts +28 -17
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +16 -35
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +285 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli-signals.d.ts +8 -0
- package/dist/cli-signals.d.ts.map +1 -0
- package/dist/cli-signals.js +28 -0
- package/dist/cli-signals.js.map +1 -0
- package/dist/cli.d.ts +22 -24
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1660 -1556
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +11 -17
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codeowners.d.ts +19 -0
- package/dist/codeowners.d.ts.map +1 -0
- package/dist/codeowners.js +138 -0
- package/dist/codeowners.js.map +1 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +1 -2
- package/dist/codex-prompt.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +3 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -0
- package/dist/codex-sdk-environment.js +68 -0
- package/dist/codex-sdk-environment.js.map +1 -0
- package/dist/component-plan.d.ts +2 -5
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +38 -34
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +7 -5
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +54 -44
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +93 -104
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +15 -2
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +124 -348
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +13 -6
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +75 -34
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +10 -2
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +116 -134
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +7 -6
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +1 -2
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +23 -16
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts +4 -2
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +33 -20
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +9 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +129 -20
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +5 -2
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +18 -4
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +26 -4
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +59 -47
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +59 -113
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/diagnostics.d.ts +17 -0
- package/dist/deduplication/diagnostics.d.ts.map +1 -0
- package/dist/deduplication/diagnostics.js +5 -0
- package/dist/deduplication/diagnostics.js.map +1 -0
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +7 -1
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts +31 -0
- package/dist/deduplication/local.d.ts.map +1 -0
- package/dist/deduplication/local.js +166 -0
- package/dist/deduplication/local.js.map +1 -0
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +12 -28
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +188 -12
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +34 -24
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/review.d.ts +7 -0
- package/dist/deduplication/review.d.ts.map +1 -1
- package/dist/deduplication/review.js.map +1 -1
- package/dist/deduplication/scan.d.ts +9 -3
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +159 -44
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +2 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +7 -23
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +2 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +32 -47
- package/dist/deep-progress.js.map +1 -1
- package/dist/deep-scan.d.ts +20 -0
- package/dist/deep-scan.d.ts.map +1 -0
- package/dist/deep-scan.js +113 -0
- package/dist/deep-scan.js.map +1 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -7
- package/dist/errors.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +53 -21
- package/dist/feedback.js.map +1 -1
- package/dist/finding-catalogue.d.ts.map +1 -1
- package/dist/finding-catalogue.js +26 -30
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-normalization.d.ts +5 -0
- package/dist/finding-normalization.d.ts.map +1 -0
- package/dist/finding-normalization.js +120 -0
- package/dist/finding-normalization.js.map +1 -0
- package/dist/finding-retrieval.d.ts +9 -0
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +13 -8
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +18 -13
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +2 -1
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +36 -9
- package/dist/findings-client.js.map +1 -1
- package/dist/findings-errors.d.ts +16 -0
- package/dist/findings-errors.d.ts.map +1 -0
- package/dist/findings-errors.js +24 -0
- package/dist/findings-errors.js.map +1 -0
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +16 -44
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +9 -4
- package/dist/github.js.map +1 -1
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +49 -39
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +7 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +115 -47
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +4 -10
- package/dist/linear.js.map +1 -1
- package/dist/mock-scan.d.ts.map +1 -1
- package/dist/mock-scan.js +0 -1
- package/dist/mock-scan.js.map +1 -1
- package/dist/models.d.ts +24 -2
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts +9 -3
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +225 -153
- package/dist/multiscan.js.map +1 -1
- package/dist/owner-evidence.d.ts +10 -2
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +69 -14
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +5 -6
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +10 -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 +5 -3
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +0 -1
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +2 -4
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts +21 -0
- package/dist/provider-profile.d.ts.map +1 -0
- package/dist/provider-profile.js +133 -0
- package/dist/provider-profile.js.map +1 -0
- package/dist/publication-events.d.ts +6 -8
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +40 -79
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +48 -76
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +1 -2
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +7 -16
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +1 -5
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +138 -199
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +2 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +4 -0
- package/dist/record.js.map +1 -0
- package/dist/request-metadata.d.ts +9 -0
- package/dist/request-metadata.d.ts.map +1 -0
- package/dist/request-metadata.js +13 -0
- package/dist/request-metadata.js.map +1 -0
- package/dist/result.d.ts +4 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +25 -17
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +619 -255
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +14 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -0
- package/dist/saved-scan-bootstrap.js +261 -0
- package/dist/saved-scan-bootstrap.js.map +1 -0
- package/dist/saved-scan.d.ts +1 -1
- package/dist/saved-scan.d.ts.map +1 -1
- package/dist/saved-scan.js +16 -32
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +19 -30
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +31 -18
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +307 -347
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +3 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +351 -92
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +55 -15
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-inputs.d.ts +6 -0
- package/dist/scan-inputs.d.ts.map +1 -0
- package/dist/scan-inputs.js +71 -0
- package/dist/scan-inputs.js.map +1 -0
- package/dist/scan-logs.d.ts +2 -3
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +14 -12
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-sessions.d.ts +4 -0
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +18 -3
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +5 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-skill-paths.d.ts +8 -0
- package/dist/scan-skill-paths.d.ts.map +1 -0
- package/dist/scan-skill-paths.js +47 -0
- package/dist/scan-skill-paths.js.map +1 -0
- package/dist/security-policy-cli.d.ts.map +1 -1
- package/dist/security-policy-cli.js +15 -33
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +17 -9
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +131 -98
- package/dist/security-policy.js.map +1 -1
- package/dist/server/api.d.ts +0 -1
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/api.js +0 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/embeddings.d.ts +3 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +11 -3
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/errors.d.ts +5 -2
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js +7 -0
- package/dist/server/errors.js.map +1 -1
- package/dist/server/sqlite-store.d.ts +0 -2
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +55 -55
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/server/storage.d.ts +0 -2
- package/dist/server/storage.d.ts.map +1 -1
- package/dist/server/storage.js.map +1 -1
- package/dist/severity-store.js +20 -32
- package/dist/severity-store.js.map +1 -1
- package/dist/standalone-validation-prompt.d.ts +2 -0
- package/dist/standalone-validation-prompt.d.ts.map +1 -0
- package/dist/standalone-validation-prompt.js +10 -0
- package/dist/standalone-validation-prompt.js.map +1 -0
- package/dist/suggest-owners.d.ts +6 -5
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +15 -10
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +12 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +124 -62
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +6 -1
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +28 -9
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.d.ts +2 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +27 -0
- package/dist/value.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -6
- package/dist/version.js.map +1 -1
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -2
- package/dist/windows-path.js.map +1 -1
- package/dist/workbench-arguments.d.ts +3 -0
- package/dist/workbench-arguments.d.ts.map +1 -0
- package/dist/workbench-arguments.js +15 -0
- package/dist/workbench-arguments.js.map +1 -0
- package/dist/worker-progress.d.ts +2 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +40 -46
- package/dist/worker-progress.js.map +1 -1
- package/docs/cli.md +1778 -0
- package/docs/dedupe-records.md +24 -0
- package/docs/findings-service.md +402 -0
- package/package.json +23 -23
- package/schemas/project-config.schema.json +5 -0
- package/_bundled_plugin/schemas/tools/worker-threat-model.schema.json +0 -18
- package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
- package/_bundled_plugin/scripts/workbench_dashboard.py +0 -159
- package/_bundled_plugin/scripts/workbench_findings.py +0 -221
- package/_bundled_plugin/scripts/workbench_severity.py +0 -119
- package/_bundled_plugin/skills/assess-patch-risk/scripts/validate_patch_risk_assessment.py +0 -163
- package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +0 -276
- package/dist/server/dashboard/app.css +0 -2
- package/dist/server/dashboard/app.js +0 -66
- package/dist/server/dashboard/index.html +0 -18
- package/dist/server/dashboard-types.d.ts +0 -48
- package/dist/server/dashboard-types.d.ts.map +0 -1
- package/dist/server/dashboard-types.js +0 -2
- package/dist/server/dashboard-types.js.map +0 -1
- package/dist/server/dashboard.d.ts +0 -6
- package/dist/server/dashboard.d.ts.map +0 -1
- package/dist/server/dashboard.js +0 -59
- package/dist/server/dashboard.js.map +0 -1
- package/dist/server/findings-service.d.ts +0 -20
- package/dist/server/findings-service.d.ts.map +0 -1
- package/dist/server/findings-service.js +0 -31
- package/dist/server/findings-service.js.map +0 -1
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -6
- package/dist/server/index.js.map +0 -1
- package/dist/server/routes.d.ts +0 -6
- package/dist/server/routes.d.ts.map +0 -1
- package/dist/server/routes.js +0 -86
- package/dist/server/routes.js.map +0 -1
- package/dist/server/serve.d.ts +0 -2
- package/dist/server/serve.d.ts.map +0 -1
- package/dist/server/serve.js +0 -28
- package/dist/server/serve.js.map +0 -1
- package/dist/server/server.d.ts +0 -10
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -17
- package/dist/server/server.js.map +0 -1
- package/dist/server/validation.d.ts +0 -17
- package/dist/server/validation.d.ts.map +0 -1
- package/dist/server/validation.js +0 -53
- package/dist/server/validation.js.map +0 -1
package/dist/import-scan.js
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { workbenchArgs } from "./workbench-arguments.js";
|
|
1
10
|
import { createHash } from "node:crypto";
|
|
2
11
|
import { constants } from "node:fs";
|
|
3
12
|
import { lstat, mkdir, mkdtemp, open, readFile, realpath, writeFile, } from "node:fs/promises";
|
|
4
13
|
import { tmpdir } from "node:os";
|
|
5
14
|
import { basename, dirname, join, resolve } from "node:path";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
6
16
|
import { loadContract, sameCheckedFileDevice } from "./contract.js";
|
|
7
|
-
import { CodexSecurityError, ScanInterruptedError,
|
|
17
|
+
import { CodexSecurityError, ScanInterruptedError, errorMessage, } from "./errors.js";
|
|
8
18
|
import { bindImportedFindings, parseImportedFindings, } from "./findings-import.js";
|
|
9
19
|
import { ScanResult } from "./result.js";
|
|
10
|
-
import { cleanupSdkDirectory, codexSecurityStateDirectory, expandHome, pluginMetadata,
|
|
20
|
+
import { bundledPluginRoot, cleanupSdkDirectory, codexSecurityStateDirectory, expandHome, pluginMetadata, prepareScanRegistrationOutput, preparePersistentOutputRoot, requireOutputOutsideRepository, requirePrivateOutputDirectory, requireSecureOutputAncestry, resolvePluginPath, resolvePluginPython, runWorkbench, validateOutputDir, } from "./runtime.js";
|
|
11
21
|
const IMPORT_DESCRIPTION = "Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.";
|
|
12
22
|
async function readImportSource(inputPath, signal) {
|
|
13
23
|
signal?.throwIfAborted();
|
|
@@ -56,7 +66,21 @@ export async function importScan(options, dependencies = {}) {
|
|
|
56
66
|
let scanDir = "";
|
|
57
67
|
try {
|
|
58
68
|
const pluginRoot = await resolvePluginPath(options.config?.pluginPath, workspace, signal);
|
|
59
|
-
const findings = await parseImportedFindings(
|
|
69
|
+
const findings = await parseImportedFindings(new TextDecoder("utf-8", { fatal: true }).decode(source), options.format, pluginRoot);
|
|
70
|
+
const helper = (await import(__rewriteRelativeImportExtension(pathToFileURL(join(await bundledPluginRoot(), "mcp/helpers.mjs")).href))).default;
|
|
71
|
+
try {
|
|
72
|
+
helper.parseCurrentFindings(findings.map((finding) => {
|
|
73
|
+
// Import assigns new identities and retains source metadata as provenance.
|
|
74
|
+
const { findingId, occurrenceId, fingerprints, writeup, ...content } = finding;
|
|
75
|
+
return {
|
|
76
|
+
...content,
|
|
77
|
+
provenance: { source: `${options.format}_import` },
|
|
78
|
+
};
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new CodexSecurityError(`Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`, { cause: error });
|
|
83
|
+
}
|
|
60
84
|
signal?.throwIfAborted();
|
|
61
85
|
await validateOutputDir(options.outputDir, options.archiveExisting);
|
|
62
86
|
if (options.dryRun) {
|
|
@@ -98,10 +122,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
98
122
|
const outputRoot = options.outputDir === undefined
|
|
99
123
|
? await preparePersistentOutputRoot(stateDirectory, "scans", "imports")
|
|
100
124
|
: undefined;
|
|
101
|
-
|
|
102
|
-
scanDir = await prepareOutputDir(options.outputDir, "import", outputRoot, (path) => requireOutputOutsideRepository(repository, path), options.archiveExisting, (path) => {
|
|
103
|
-
archivedScanDir = path;
|
|
104
|
-
});
|
|
125
|
+
scanDir = await prepareScanRegistrationOutput(options.outputDir, "import", outputRoot, (path) => requireOutputOutsideRepository(repository, path), options.archiveExisting);
|
|
105
126
|
const workbenchOptions = {
|
|
106
127
|
python,
|
|
107
128
|
pluginRoot,
|
|
@@ -109,21 +130,14 @@ export async function importScan(options, dependencies = {}) {
|
|
|
109
130
|
signal,
|
|
110
131
|
failureMessage: "Could not save the imported scan",
|
|
111
132
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"--repository",
|
|
133
|
+
signal?.throwIfAborted();
|
|
134
|
+
const registration = await workbench(workbenchOptions, workbenchArgs("register-cli-scan", {
|
|
115
135
|
repository,
|
|
116
|
-
"--scan-dir",
|
|
117
136
|
scanDir,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
: ["--archived-scan-dir", archivedScanDir]),
|
|
123
|
-
...(options.parentScanId === undefined
|
|
124
|
-
? []
|
|
125
|
-
: ["--parent-scan-id", options.parentScanId]),
|
|
126
|
-
], JSON.stringify({
|
|
137
|
+
registrationJsonStdin: true,
|
|
138
|
+
archiveExisting: Boolean(options.archiveExisting),
|
|
139
|
+
parentScanId: options.parentScanId,
|
|
140
|
+
}), JSON.stringify({
|
|
127
141
|
recipe: {
|
|
128
142
|
repository,
|
|
129
143
|
target: { kind: "repository", paths: [] },
|
|
@@ -141,6 +155,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
141
155
|
throw new CodexSecurityError("The workbench returned an invalid import scan registration.");
|
|
142
156
|
}
|
|
143
157
|
activeScan = { id: scanId, options: workbenchOptions };
|
|
158
|
+
signal?.throwIfAborted();
|
|
144
159
|
const bound = bindImportedFindings(findings, options.format, scanId, targetId);
|
|
145
160
|
const sourceRef = `artifacts/import/source.${options.format}`;
|
|
146
161
|
await mkdir(join(scanDir, "artifacts", "import"), { recursive: true });
|
|
@@ -165,17 +180,18 @@ export async function importScan(options, dependencies = {}) {
|
|
|
165
180
|
},
|
|
166
181
|
"findings.json": { findings: bound },
|
|
167
182
|
"coverage.json": {
|
|
168
|
-
completeness: "unknown",
|
|
169
183
|
inventoryStrategy: "custom",
|
|
170
|
-
surfaces:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
surfaces: findings.length
|
|
185
|
+
? [
|
|
186
|
+
{
|
|
187
|
+
id: "import",
|
|
188
|
+
label: basename(inputPath),
|
|
189
|
+
disposition: "reported",
|
|
190
|
+
receiptRefs: [sourceRef],
|
|
191
|
+
notes: IMPORT_DESCRIPTION,
|
|
192
|
+
},
|
|
193
|
+
]
|
|
194
|
+
: [],
|
|
179
195
|
explicitExclusions: [],
|
|
180
196
|
deferred: [],
|
|
181
197
|
},
|
|
@@ -183,11 +199,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
183
199
|
for (const [name, document] of Object.entries(documents)) {
|
|
184
200
|
await writeFile(join(scanDir, name), `${JSON.stringify(document, null, 2)}\n`, { flag: "wx", signal });
|
|
185
201
|
}
|
|
186
|
-
await workbench(workbenchOptions,
|
|
187
|
-
"prepare-scan-completion",
|
|
188
|
-
"--scan-id",
|
|
189
|
-
scanId,
|
|
190
|
-
]);
|
|
202
|
+
await workbench(workbenchOptions, workbenchArgs("prepare-scan-completion", { scanId }));
|
|
191
203
|
// Finalization normally recovers partial output. An import must retain every supplied row.
|
|
192
204
|
const contract = await loadContract(scanDir, {
|
|
193
205
|
pluginRoot,
|
|
@@ -197,8 +209,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
197
209
|
});
|
|
198
210
|
const expectedIds = new Set(bound.map((finding) => finding.findingId));
|
|
199
211
|
if (contract.findings.findings.length !== findings.length ||
|
|
200
|
-
contract.findings.findings.some((finding) => !expectedIds.delete(finding.findingId))
|
|
201
|
-
expectedIds.size !== 0) {
|
|
212
|
+
contract.findings.findings.some((finding) => !expectedIds.delete(finding.findingId))) {
|
|
202
213
|
throw new CodexSecurityError("Import finalization did not preserve every input finding; the scan was not completed.");
|
|
203
214
|
}
|
|
204
215
|
await workbench(workbenchOptions, ["complete-scan", "--scan-id", scanId]);
|
|
@@ -220,8 +231,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
220
231
|
"fail-scan",
|
|
221
232
|
"--scan-id",
|
|
222
233
|
activeScan.id,
|
|
223
|
-
|
|
224
|
-
safeErrorMessage(error).slice(0, 2400),
|
|
234
|
+
`--message=${errorMessage(error).slice(0, 2400)}`,
|
|
225
235
|
]).catch(() => undefined);
|
|
226
236
|
}
|
|
227
237
|
if (signal?.aborted) {
|
package/dist/import-scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,aAAa,CAAC;A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,kBAAkB,CAC1B,uFAAuF,CACxF,CAAC;QACJ,CAAC;QACD,MAAM,SAAS,CAAC,gBAAgB,EAAE,CAAC,eAAe,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,UAAU,GAAG,SAAS,CAAC;QACvB,OAAO,IAAI,UAAU,CAAC;YACpB,GAAG,QAAQ;YACX,OAAO;YACP,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE;gBACV,MAAM,EAAE,WAAW;gBACnB,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,kBAAkB;aAClC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,SAAS,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;gBAC5D,WAAW;gBACX,WAAW;gBACX,UAAU,CAAC,EAAE;gBACb,WAAW;gBACX,gBAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;aACvC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAC5B,wCAAwC,EACxC,OAAO,EACP,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n safeErrorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareOutputDir,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n source.toString(\"utf8\"),\n options.format,\n pluginRoot,\n );\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n let archivedScanDir: string | undefined;\n scanDir = await prepareOutputDir(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n (path) => {\n archivedScanDir = path;\n },\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n const registration = await workbench(\n workbenchOptions,\n [\n \"register-cli-scan\",\n \"--repository\",\n repository,\n \"--scan-dir\",\n scanDir,\n \"--registration-json-stdin\",\n ...(options.archiveExisting ? [\"--archive-existing\"] : []),\n ...(archivedScanDir === undefined\n ? []\n : [\"--archived-scan-dir\", archivedScanDir]),\n ...(options.parentScanId === undefined\n ? []\n : [\"--parent-scan-id\", options.parentScanId]),\n ],\n JSON.stringify({\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n \"coverage.json\": {\n completeness: \"unknown\",\n inventoryStrategy: \"custom\",\n surfaces: [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ],\n explicitExclusions: [],\n deferred: [],\n },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(workbenchOptions, [\n \"prepare-scan-completion\",\n \"--scan-id\",\n scanId,\n ]);\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n ) ||\n expectedIds.size !== 0\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n \"--message\",\n safeErrorMessage(error).slice(0, 2400),\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,UAAU,EACV,cAAc,EACd,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,GAGlB,MAAM,cAAc,CAAC;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,IAAI,CAC7B,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CACpD,EACD,CAAC;YACD,MAAM,IAAI,kBAAkB,CAC1B,uFAAuF,CACxF,CAAC;QACJ,CAAC;QACD,MAAM,SAAS,CAAC,gBAAgB,EAAE,CAAC,eAAe,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,UAAU,GAAG,SAAS,CAAC;QACvB,OAAO,IAAI,UAAU,CAAC;YACpB,GAAG,QAAQ;YACX,OAAO;YACP,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE;gBACV,MAAM,EAAE,WAAW;gBACnB,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,kBAAkB;aAClC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,SAAS,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;gBAC5D,WAAW;gBACX,WAAW;gBACX,UAAU,CAAC,EAAE;gBACb,aAAa,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE;aAClD,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAC5B,wCAAwC,EACxC,OAAO,EACP,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;AACH,CAAC","sourcesContent":["import { workbenchArgs } from \"./workbench-arguments.js\";\nimport { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n errorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n bundledPluginRoot,\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareScanRegistrationOutput,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(source),\n options.format,\n pluginRoot,\n );\n const helper = (\n await import(\n pathToFileURL(join(await bundledPluginRoot(), \"mcp/helpers.mjs\")).href\n )\n ).default;\n try {\n helper.parseCurrentFindings(\n findings.map((finding) => {\n // Import assigns new identities and retains source metadata as provenance.\n const { findingId, occurrenceId, fingerprints, writeup, ...content } =\n finding;\n return {\n ...content,\n provenance: { source: `${options.format}_import` },\n };\n }),\n );\n } catch (error) {\n throw new CodexSecurityError(\n `Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n scanDir = await prepareScanRegistrationOutput(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n signal?.throwIfAborted();\n const registration = await workbench(\n workbenchOptions,\n workbenchArgs(\"register-cli-scan\", {\n repository,\n scanDir,\n registrationJsonStdin: true,\n archiveExisting: Boolean(options.archiveExisting),\n parentScanId: options.parentScanId,\n }),\n JSON.stringify({\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n signal?.throwIfAborted();\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n \"coverage.json\": {\n inventoryStrategy: \"custom\",\n surfaces: findings.length\n ? [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ]\n : [],\n explicitExclusions: [],\n deferred: [],\n },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(\n workbenchOptions,\n workbenchArgs(\"prepare-scan-completion\", { scanId }),\n );\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n )\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n `--message=${errorMessage(error).slice(0, 2400)}`,\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace);\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { exportArtifact } from "./artifact-export.js";
|
|
2
|
+
export type { ExportArtifactOptions, ArtifactExportResult, } from "./artifact-export.js";
|
|
1
3
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
2
4
|
export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
|
|
3
5
|
export type { ResolvedProjectConfig, ProjectConfigProvenance, } from "./project-config.js";
|
|
@@ -5,7 +7,7 @@ export type { ProjectConfigInput, ProjectScope, } from "./project-config-schema.
|
|
|
5
7
|
export type { ScanSettings } from "./scan-settings.js";
|
|
6
8
|
export { classifySeverity } from "./classify-severity.js";
|
|
7
9
|
export { suggestOwners } from "./suggest-owners.js";
|
|
8
|
-
export type { OwnerFinding, OwnerIdentity, OwnerSuggestion, OwnerSuggestions, SuggestOwnersOptions, } from "./suggest-owners.js";
|
|
10
|
+
export type { OwnerFinding, CodeownerIdentity, OwnerIdentity, OwnerSuggestion, OwnerSuggestions, SuggestOwnersOptions, } from "./suggest-owners.js";
|
|
9
11
|
export type { ClassifySeverityOptions, SeverityClassificationFinding, SeverityClassification, SeverityAssessment, } from "./classify-severity.js";
|
|
10
12
|
export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
|
|
11
13
|
export type { ClassifyScanSeverityOptions, ScanSeverityClassification, } from "./classify-scan-severity.js";
|
|
@@ -14,17 +16,18 @@ export type { ComponentDeduplicationSummary, ComponentReceipt, ComponentScanOpti
|
|
|
14
16
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
15
17
|
export type { ComponentPlan, ComponentPlanningOptions, } from "./component-plan.js";
|
|
16
18
|
export { estimateScanCost } from "./cost.js";
|
|
17
|
-
export type { ScanCost, ScanSessionEvent } from "./cost.js";
|
|
19
|
+
export type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from "./cost.js";
|
|
20
|
+
export type { ScanTokenUsage } from "./cost-model.js";
|
|
18
21
|
export type { DeepScanProgress } from "./deep-progress.js";
|
|
19
22
|
export type { CustomValidationResult } from "./custom-validation.js";
|
|
20
23
|
export type { ScanActivity, ScanActivityStatus } from "./scan-activity.js";
|
|
21
24
|
export { matchScanFindings } from "./scan-comparison.js";
|
|
22
25
|
export type { ScanComparisonInput, ScanComparisonOptions, ScanComparisonProgress, ScanComparisonResult, } from "./scan-comparison.js";
|
|
23
|
-
export type { CodexSecurityMetadata, DeepScanOptions, ScanAuthMode, ScanAuthentication, ScanBudget, ScanOptions, ScanPreflight, ScanReconnectDetails, ScanTrustedAccessStatus, ScanWarningDetails, ValidationOptions, ValidationResult, } from "./api.js";
|
|
26
|
+
export type { CodexSecurityMetadata, DeepScanOptions, PatchOptions, PatchResult, ScanAuthMode, ScanAuthentication, ScanBudget, ScanOptions, ScanPreflight, ScanReconnectDetails, ScanTrustedAccessStatus, ScanWarningDetails, ValidationOptions, ValidationResult, } from "./api.js";
|
|
24
27
|
export type { ScanPhase, ScanProgress, ScanWorkerPhase, ScanWorkerStatus, } from "./worker-progress.js";
|
|
25
28
|
export { CodexLoginHandle } from "./auth.js";
|
|
26
29
|
export type { AccountStatus, LoginResult } from "./auth.js";
|
|
27
|
-
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
30
|
+
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, LocalPluginBootstrapError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, SandboxUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
28
31
|
export type { DeduplicationReviewFailureCategory, DeduplicationReviewFailureMetadata, DeduplicationReviewStage, ProtectedScanPathKind, } from "./errors.js";
|
|
29
32
|
export { DEFAULT_CODEX_CONFIG, mergedCodexConfig, writeCodexConfig, } from "./config.js";
|
|
30
33
|
export type { CodexSecurityConfig, JsonObject, JsonValue } from "./config.js";
|
|
@@ -38,10 +41,13 @@ export { publishScanToCustom } from "./custom-publish.js";
|
|
|
38
41
|
export type { PublishScanToCustomOptions, CustomPublicationResult, } from "./custom-publish.js";
|
|
39
42
|
export { deduplicateRecords } from "./deduplication/records.js";
|
|
40
43
|
export type { DeduplicateRecordsInput, DeduplicateRecordsOptions, DeduplicateRecordsResult, } from "./deduplication/records.js";
|
|
41
|
-
export type { DeduplicationReviewRequest, DeduplicationReviewRunner, } from "./deduplication/review.js";
|
|
44
|
+
export type { DeduplicationReviewRequest, DeduplicationReviewAttribution, DeduplicationReviewRunner, } from "./deduplication/review.js";
|
|
42
45
|
export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
|
|
43
46
|
export type { DeduplicateScanDirectoryOptions, DeduplicateScanOptions, DeduplicateScanResult, } from "./deduplication/scan.js";
|
|
44
47
|
export type { DeduplicationRefusal } from "./deduplication/deduplication.js";
|
|
48
|
+
export type { FindingEmbeddingBinding } from "./deduplication/local.js";
|
|
49
|
+
export type { DeduplicationDiagnostic, DeduplicationDiagnosticObserver, } from "./deduplication/diagnostics.js";
|
|
50
|
+
export type { FindingEmbedder } from "./server/embeddings.js";
|
|
45
51
|
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
46
52
|
export type { GitHubCodeScanningImportOptions, ImportedGitHubCodeScanningAlert, } from "./github.js";
|
|
47
53
|
export type { CheckScanPublicationOptions, CheckScanPublicationResult, PublishScanOptions, PublishScanProgress, PublishScanResult, } from "./publish.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,6BAA6B,G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a,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { exportArtifact } from "./artifact-export.js";
|
|
1
2
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
2
3
|
export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
|
|
3
4
|
export { classifySeverity } from "./classify-severity.js";
|
|
@@ -8,7 +9,7 @@ export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
|
8
9
|
export { estimateScanCost } from "./cost.js";
|
|
9
10
|
export { matchScanFindings } from "./scan-comparison.js";
|
|
10
11
|
export { CodexLoginHandle } from "./auth.js";
|
|
11
|
-
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
12
|
+
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, LocalPluginBootstrapError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, SandboxUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
12
13
|
export { DEFAULT_CODEX_CONFIG, mergedCodexConfig, writeCodexConfig, } from "./config.js";
|
|
13
14
|
export { loadContract, requireScanFile } from "./contract.js";
|
|
14
15
|
export { resolveSecurityPolicyTarget, securityPolicyDiff, } from "./security-policy.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAepD,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6BzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAWhE,OAAO,EACL,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAajC,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { exportArtifact } from \"./artifact-export.js\";\nexport type {\n ExportArtifactOptions,\n ArtifactExportResult,\n} from \"./artifact-export.js\";\nexport { CodexSecurity, createSecurity } from \"./api.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n CodeownerIdentity,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from \"./cost.js\";\nexport type { ScanTokenUsage } from \"./cost-model.js\";\nexport type { DeepScanProgress } from \"./deep-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n PatchOptions,\n PatchResult,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n LocalPluginBootstrapError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n SandboxUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewAttribution,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport type { FindingEmbeddingBinding } from \"./deduplication/local.js\";\nexport type {\n DeduplicationDiagnostic,\n DeduplicationDiagnosticObserver,\n} from \"./deduplication/diagnostics.js\";\nexport type { FindingEmbedder } from \"./server/embeddings.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n"]}
|
package/dist/knowledge-base.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export interface PreparedKnowledgeBase {
|
|
2
2
|
path: string;
|
|
3
3
|
sources: string[];
|
|
4
|
+
protectedRoots: string[];
|
|
4
5
|
cleanup(): Promise<void>;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
+
export interface KnowledgeBaseSnapshot {
|
|
8
|
+
readonly sources: readonly string[];
|
|
9
|
+
readonly protectedRoots?: readonly string[];
|
|
10
|
+
readonly documents: Readonly<Record<string, string>>;
|
|
11
|
+
}
|
|
12
|
+
export declare function prepareKnowledgeBase(input: readonly string[] | KnowledgeBaseSnapshot, signal?: AbortSignal, directory?: string): Promise<PreparedKnowledgeBase>;
|
|
7
13
|
//# sourceMappingURL=knowledge-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AAyFD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,qBAAqB,EAChD,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC,CAyChC"}
|