@openai/codex-security 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -61
- package/_bundled_plugin/.app.json +4 -0
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +46 -12
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -5
- package/_bundled_plugin/references/default-severity-rubric.md +28 -0
- package/_bundled_plugin/references/finding-detail-fields.md +1 -0
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
- package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
- package/_bundled_plugin/scripts/finding_preview.py +5 -29
- package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
- package/_bundled_plugin/scripts/report_projection.py +87 -136
- package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
- package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
- package/_bundled_plugin/scripts/workbench_cli.py +102 -13
- package/_bundled_plugin/scripts/workbench_constants.py +9 -0
- package/_bundled_plugin/scripts/workbench_db.py +186 -360
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
- package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
- package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
- package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
- package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_setup.py +239 -0
- package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
- package/_bundled_plugin/scripts/workbench_target.py +213 -20
- package/_bundled_plugin/scripts/workbench_validation.py +1 -9
- package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
- package/_bundled_plugin/shared/workbench-migrations.json +19 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
- package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
- package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +64 -35
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +14 -8
- package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +411 -160
- package/dist/api.js.map +1 -1
- package/dist/auth.js +6 -1
- package/dist/auth.js.map +1 -1
- package/dist/blackduck-findings.d.ts +8 -0
- package/dist/blackduck-findings.d.ts.map +1 -0
- package/dist/blackduck-findings.js +305 -0
- package/dist/blackduck-findings.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +51 -36
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-severity-records.d.ts +5 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +6 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +4 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +28 -9
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +608 -258
- package/dist/cli.js.map +1 -1
- package/dist/codex-prompt.d.ts +2 -0
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +6 -0
- package/dist/codex-prompt.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +6 -5
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +162 -40
- package/dist/config.js.map +1 -1
- package/dist/continuum-findings.d.ts +7 -0
- package/dist/continuum-findings.d.ts.map +1 -0
- package/dist/continuum-findings.js +157 -0
- package/dist/continuum-findings.js.map +1 -0
- package/dist/contract-values.d.ts +28 -0
- package/dist/contract-values.d.ts.map +1 -0
- package/dist/contract-values.js +75 -0
- package/dist/contract-values.js.map +1 -0
- package/dist/contract.d.ts +2 -20
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +58 -669
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +1 -4
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +19 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +2120 -39
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +5 -0
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts +2 -0
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +4 -0
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -4
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +11 -4
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/finding-schema.d.ts +19 -1
- package/dist/deduplication/finding-schema.d.ts.map +1 -1
- package/dist/deduplication/finding-schema.js +25 -0
- package/dist/deduplication/finding-schema.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +3 -8
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.d.ts +8 -2
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +36 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deep-scan.d.ts +11 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +235 -4
- package/dist/deep-scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +1 -2
- package/dist/default-severity-rubric.d.ts.map +1 -1
- package/dist/default-severity-rubric.js +2 -66
- package/dist/default-severity-rubric.js.map +1 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +7 -37
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +5 -11
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +9 -0
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +325 -179
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +12 -0
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +1202 -214
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +8 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +65 -54
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +2 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +111 -0
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +29 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +314 -44
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/finding-normalization.d.ts +1 -1
- package/dist/finding-normalization.d.ts.map +1 -1
- package/dist/finding-normalization.js +46 -11
- package/dist/finding-normalization.js.map +1 -1
- package/dist/finding-retrieval.d.ts +3 -3
- package/dist/finding-retrieval.d.ts.map +1 -1
- package/dist/finding-retrieval.js.map +1 -1
- package/dist/finding-workflow.d.ts +6 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -2
- package/dist/finding-workflow.js.map +1 -1
- package/dist/git-remote.d.ts +4 -0
- package/dist/git-remote.d.ts.map +1 -1
- package/dist/git-remote.js +20 -0
- package/dist/git-remote.js.map +1 -1
- package/dist/github-advisories.d.ts +3 -12
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +9 -29
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +7 -16
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +344 -56
- package/dist/github-findings.js.map +1 -1
- package/dist/github.d.ts +17 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +43 -30
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +2 -2
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +10 -11
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +69 -9
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts +15 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +55 -33
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +13 -18
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.js +18 -5
- package/dist/knowledge-base.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -0
- package/dist/local-git-metadata.d.ts.map +1 -0
- package/dist/local-git-metadata.js +131 -0
- package/dist/local-git-metadata.js.map +1 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +22 -12
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +34 -20
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +90 -35
- package/dist/patch-tui.js.map +1 -1
- package/dist/private-finding-import.d.ts +246 -0
- package/dist/private-finding-import.d.ts.map +1 -0
- package/dist/private-finding-import.js +387 -0
- package/dist/private-finding-import.js.map +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -2
- package/dist/project-config.js.map +1 -1
- package/dist/provider-profile.d.ts +10 -2
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +72 -10
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.js +7 -1
- package/dist/publication.js.map +1 -1
- package/dist/reader-selection.d.ts +13 -0
- package/dist/reader-selection.d.ts.map +1 -0
- package/dist/reader-selection.js +81 -0
- package/dist/reader-selection.js.map +1 -0
- package/dist/record.d.ts +6 -1
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -2
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts +5 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +30 -0
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +2 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -1
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +95 -52
- package/dist/runtime.js.map +1 -1
- package/dist/scan-activity.js +40 -17
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +11 -13
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +16 -37
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +2 -0
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +22 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +5 -5
- package/dist/scan-logs.js.map +1 -1
- package/dist/scanner-import.d.ts +46 -6
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +208 -42
- package/dist/scanner-import.js.map +1 -1
- package/dist/scanner-repository-url.d.ts +14 -0
- package/dist/scanner-repository-url.d.ts.map +1 -0
- package/dist/scanner-repository-url.js +67 -0
- package/dist/scanner-repository-url.js.map +1 -0
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +20 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +12 -0
- package/dist/semgrep-platform-findings.d.ts.map +1 -0
- package/dist/semgrep-platform-findings.js +198 -0
- package/dist/semgrep-platform-findings.js.map +1 -0
- package/dist/severity-rubric.d.ts +20 -0
- package/dist/severity-rubric.d.ts.map +1 -0
- package/dist/severity-rubric.js +73 -0
- package/dist/severity-rubric.js.map +1 -0
- package/dist/severity-store.js +15 -5
- package/dist/severity-store.js.map +1 -1
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +21 -20
- package/dist/snyk-findings.js.map +1 -1
- package/dist/sonar-collector.d.ts +16 -0
- package/dist/sonar-collector.d.ts.map +1 -0
- package/dist/sonar-collector.js +383 -0
- package/dist/sonar-collector.js.map +1 -0
- package/dist/sonar-findings.d.ts +49 -0
- package/dist/sonar-findings.d.ts.map +1 -0
- package/dist/sonar-findings.js +288 -0
- package/dist/sonar-findings.js.map +1 -0
- package/dist/sonar-import.d.ts +111 -0
- package/dist/sonar-import.d.ts.map +1 -0
- package/dist/sonar-import.js +279 -0
- package/dist/sonar-import.js.map +1 -0
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +2 -1
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +3 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +18 -12
- package/dist/targets.js.map +1 -1
- package/dist/terminal-columns.d.ts +4 -0
- package/dist/terminal-columns.d.ts.map +1 -0
- package/dist/terminal-columns.js +19 -0
- package/dist/terminal-columns.js.map +1 -0
- package/dist/validation-records.d.ts +0 -3
- package/dist/validation-records.d.ts.map +1 -1
- package/dist/validation-records.js +0 -16
- package/dist/validation-records.js.map +1 -1
- package/dist/veracode-findings.d.ts +7 -0
- package/dist/veracode-findings.d.ts.map +1 -0
- package/dist/veracode-findings.js +371 -0
- package/dist/veracode-findings.js.map +1 -0
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -0
- package/dist/windows-path.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -2
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +1 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +10 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +88 -49
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +1 -1
- package/docs/cli.md +310 -477
- package/docs/dedupe-records.md +10 -0
- package/docs/findings-service.md +21 -8
- package/docs/hosted-scans.md +16 -1
- package/package.json +8 -9
- package/schemas/external-findings.schema.json +12 -1
- package/schemas/hosted-scan-v2.fixture.json +16 -1
- package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
- package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
- package/dist/deduplication/records-protocol.d.ts +0 -4
- package/dist/deduplication/records-protocol.d.ts.map +0 -1
- package/dist/deduplication/records-protocol.js +0 -49
- package/dist/deduplication/records-protocol.js.map +0 -1
|
@@ -127,7 +127,6 @@ def collect_scan_usage(
|
|
|
127
127
|
rate_limits: dict[str, dict[str, Any]] = {}
|
|
128
128
|
tokens_updated_at = None
|
|
129
129
|
accepted_thread_ids: set[str] = set()
|
|
130
|
-
measured_thread_ids: set[str] = set()
|
|
131
130
|
excluded_thread_ids: set[str] = set()
|
|
132
131
|
for session in sessions:
|
|
133
132
|
if session.parent_thread_id in excluded_thread_ids:
|
|
@@ -171,7 +170,6 @@ def collect_scan_usage(
|
|
|
171
170
|
if "token_usage_unavailable" in usage.warnings:
|
|
172
171
|
missing_thread_ids.add(session.thread_id)
|
|
173
172
|
continue
|
|
174
|
-
measured_thread_ids.add(session.thread_id)
|
|
175
173
|
role = by_role["parent" if session.thread_id in parent_ids else "workers"]
|
|
176
174
|
_add_token_usage(role, usage.tokens)
|
|
177
175
|
role["threadCount"] += 1
|
|
@@ -182,7 +180,8 @@ def collect_scan_usage(
|
|
|
182
180
|
|
|
183
181
|
if not accepted_thread_ids:
|
|
184
182
|
return _unavailable_usage("scan_thread_unavailable", warnings=warnings)
|
|
185
|
-
|
|
183
|
+
thread_count = sum(role["threadCount"] for role in by_role.values())
|
|
184
|
+
if not thread_count:
|
|
186
185
|
return _unavailable_usage(
|
|
187
186
|
"token_usage_unavailable", warnings=warnings, rate_limits=rate_limits
|
|
188
187
|
)
|
|
@@ -202,7 +201,7 @@ def collect_scan_usage(
|
|
|
202
201
|
"coverage": "partial" if missing_thread_ids or warnings else "complete",
|
|
203
202
|
"source": "codex_rollout",
|
|
204
203
|
**{key: sum(role[key] for role in by_role.values()) for key in TOKEN_FIELDS.values()},
|
|
205
|
-
"threadCount":
|
|
204
|
+
"threadCount": thread_count,
|
|
206
205
|
"byRole": by_role,
|
|
207
206
|
"window": {"startedAt": started_at.isoformat(), "endedAt": stopped_at.isoformat()},
|
|
208
207
|
"observedAt": observed_at.isoformat(),
|
|
@@ -506,6 +505,14 @@ def _read_rollout_usage(
|
|
|
506
505
|
closed_turns: set[str] = set()
|
|
507
506
|
measured_turns: set[str] = set()
|
|
508
507
|
|
|
508
|
+
def past_scan_end(timestamp: datetime, turn_id: object) -> bool:
|
|
509
|
+
# The requested completion turn may finish after the scan was marked complete.
|
|
510
|
+
return (
|
|
511
|
+
completed_at is not None
|
|
512
|
+
and timestamp > completed_at
|
|
513
|
+
and (completed_turn_id is None or turn_id != completed_turn_id)
|
|
514
|
+
)
|
|
515
|
+
|
|
509
516
|
with session.path.open("rb") as source:
|
|
510
517
|
for line_number, raw_line in enumerate(source, start=1):
|
|
511
518
|
if not raw_line.endswith(b"\n"):
|
|
@@ -559,10 +566,8 @@ def _read_rollout_usage(
|
|
|
559
566
|
if task_started_at is None:
|
|
560
567
|
warnings.add("thread_ownership_unavailable")
|
|
561
568
|
return result
|
|
562
|
-
if task_started_at < started_at or (
|
|
563
|
-
|
|
564
|
-
and task_started_at > completed_at
|
|
565
|
-
and payload.get("turn_id") != completed_turn_id
|
|
569
|
+
if task_started_at < started_at or past_scan_end(
|
|
570
|
+
task_started_at, payload.get("turn_id")
|
|
566
571
|
):
|
|
567
572
|
warnings.add("thread_outside_scan_window")
|
|
568
573
|
return result
|
|
@@ -576,16 +581,8 @@ def _read_rollout_usage(
|
|
|
576
581
|
if event.get("type") == "event_msg" and payload.get("type") == "task_started":
|
|
577
582
|
# The same owner can resume as a model-backed coordinator. Only
|
|
578
583
|
# a provably post-scan turn leaves the original control zero intact.
|
|
579
|
-
|
|
580
|
-
if (
|
|
581
|
-
completed_at is None
|
|
582
|
-
or task_started_at is None
|
|
583
|
-
or task_started_at <= completed_at
|
|
584
|
-
or (
|
|
585
|
-
completed_turn_id is not None
|
|
586
|
-
and payload.get("turn_id") == completed_turn_id
|
|
587
|
-
)
|
|
588
|
-
):
|
|
584
|
+
timestamp = _timestamp(event.get("timestamp"))
|
|
585
|
+
if timestamp is None or not past_scan_end(timestamp, payload.get("turn_id")):
|
|
589
586
|
direct_control_session = False
|
|
590
587
|
if (
|
|
591
588
|
completed_turn_id is not None
|
|
@@ -601,14 +598,9 @@ def _read_rollout_usage(
|
|
|
601
598
|
if payload.get("turn_id") != current_turn_id:
|
|
602
599
|
observed_response_usage = _empty_token_usage()
|
|
603
600
|
current_turn_id = payload.get("turn_id")
|
|
604
|
-
timestamp = _timestamp(event.get("timestamp"))
|
|
605
601
|
if not isinstance(current_turn_id, str) or not current_turn_id or timestamp is None:
|
|
606
602
|
warnings.add("turn_record_invalid")
|
|
607
|
-
elif (
|
|
608
|
-
completed_at is None
|
|
609
|
-
or timestamp <= completed_at
|
|
610
|
-
or current_turn_id == completed_turn_id
|
|
611
|
-
):
|
|
603
|
+
elif not past_scan_end(timestamp, current_turn_id):
|
|
612
604
|
started_turns.add(current_turn_id)
|
|
613
605
|
open_turns.add(current_turn_id)
|
|
614
606
|
continue
|
|
@@ -624,11 +616,7 @@ def _read_rollout_usage(
|
|
|
624
616
|
or timestamp is None
|
|
625
617
|
):
|
|
626
618
|
warnings.add("turn_record_invalid")
|
|
627
|
-
elif (
|
|
628
|
-
completed_at is None
|
|
629
|
-
or timestamp <= completed_at
|
|
630
|
-
or terminal_turn_id == completed_turn_id
|
|
631
|
-
):
|
|
619
|
+
elif not past_scan_end(timestamp, terminal_turn_id):
|
|
632
620
|
open_turns.discard(terminal_turn_id)
|
|
633
621
|
if timestamp >= started_at:
|
|
634
622
|
if terminal_turn_id in started_turns:
|
|
@@ -648,11 +636,7 @@ def _read_rollout_usage(
|
|
|
648
636
|
if (
|
|
649
637
|
timestamp is not None
|
|
650
638
|
and timestamp >= started_at
|
|
651
|
-
and (
|
|
652
|
-
completed_at is None
|
|
653
|
-
or timestamp <= completed_at
|
|
654
|
-
or (completed_turn_id is not None and current_turn_id == completed_turn_id)
|
|
655
|
-
)
|
|
639
|
+
and not past_scan_end(timestamp, current_turn_id)
|
|
656
640
|
and "compaction_response_id" not in payload
|
|
657
641
|
and response_usage is None
|
|
658
642
|
):
|
|
@@ -675,15 +659,13 @@ def _read_rollout_usage(
|
|
|
675
659
|
):
|
|
676
660
|
warnings.add("token_record_invalid")
|
|
677
661
|
continue
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
)
|
|
681
|
-
if completed_at is not None and timestamp > completed_at and not is_completion_turn:
|
|
662
|
+
receipt_turn_id = payload.get("turn_id")
|
|
663
|
+
if past_scan_end(timestamp, receipt_turn_id):
|
|
682
664
|
continue
|
|
683
665
|
if response_usage is None:
|
|
684
666
|
response_usage = _empty_token_usage()
|
|
685
667
|
if current_turn_id is None:
|
|
686
|
-
current_turn_id =
|
|
668
|
+
current_turn_id = receipt_turn_id
|
|
687
669
|
if isinstance(current_turn_id, str):
|
|
688
670
|
open_turns.add(current_turn_id)
|
|
689
671
|
if response_id in response_ids:
|
|
@@ -691,14 +673,13 @@ def _read_rollout_usage(
|
|
|
691
673
|
response_ids.add(response_id)
|
|
692
674
|
_add_token_usage(observed_response_usage, usage)
|
|
693
675
|
turn_usage = _usage_counts(payload.get("turn_token_usage"))
|
|
694
|
-
receipt_turn_id = payload.get("turn_id")
|
|
695
676
|
if isinstance(receipt_turn_id, str):
|
|
696
677
|
measured_turns.add(receipt_turn_id)
|
|
697
678
|
if timestamp < started_at:
|
|
698
679
|
if turn_usage is not None:
|
|
699
680
|
observed_response_usage = turn_usage
|
|
700
681
|
continue
|
|
701
|
-
if
|
|
682
|
+
if completed_turn_id is not None and receipt_turn_id == completed_turn_id:
|
|
702
683
|
completed_turn_measured = True
|
|
703
684
|
if turn_usage is not None and any(
|
|
704
685
|
turn_usage[key] > observed_response_usage[key] for key in TOKEN_FIELDS.values()
|
|
@@ -713,11 +694,7 @@ def _read_rollout_usage(
|
|
|
713
694
|
in_window = (
|
|
714
695
|
timestamp is not None
|
|
715
696
|
and timestamp >= started_at
|
|
716
|
-
and (
|
|
717
|
-
completed_at is None
|
|
718
|
-
or timestamp <= completed_at
|
|
719
|
-
or (completed_turn_id is not None and current_turn_id == completed_turn_id)
|
|
720
|
-
)
|
|
697
|
+
and not past_scan_end(timestamp, current_turn_id)
|
|
721
698
|
)
|
|
722
699
|
if in_window:
|
|
723
700
|
rate_limits = _rate_limit_snapshot(payload.get("rate_limits"), timestamp)
|
|
@@ -730,7 +707,6 @@ def _read_rollout_usage(
|
|
|
730
707
|
result.rate_limits[key] = rate_limits
|
|
731
708
|
if "info" in payload and payload["info"] is None:
|
|
732
709
|
continue
|
|
733
|
-
timestamp = _timestamp(event.get("timestamp"))
|
|
734
710
|
snapshot = _token_snapshot(payload)
|
|
735
711
|
if timestamp is None or snapshot is None:
|
|
736
712
|
warnings.add("token_record_invalid")
|
|
@@ -740,16 +716,13 @@ def _read_rollout_usage(
|
|
|
740
716
|
for key, value in snapshot.items()
|
|
741
717
|
}
|
|
742
718
|
previous = snapshot
|
|
743
|
-
|
|
744
|
-
completed_turn_id is not None and current_turn_id == completed_turn_id
|
|
745
|
-
)
|
|
746
|
-
if completed_at is not None and timestamp > completed_at and not is_completion_turn:
|
|
719
|
+
if past_scan_end(timestamp, current_turn_id):
|
|
747
720
|
continue
|
|
748
721
|
if isinstance(current_turn_id, str):
|
|
749
722
|
measured_turns.add(current_turn_id)
|
|
750
723
|
if timestamp < started_at:
|
|
751
724
|
continue
|
|
752
|
-
if
|
|
725
|
+
if completed_turn_id is not None and current_turn_id == completed_turn_id:
|
|
753
726
|
completed_turn_measured = True
|
|
754
727
|
result.tokens_updated_at = max(result.tokens_updated_at or timestamp, timestamp)
|
|
755
728
|
if delta["totalTokens"] <= 0:
|
|
@@ -75,7 +75,7 @@ def apply_migrations(
|
|
|
75
75
|
elif version == 16:
|
|
76
76
|
should_backfill_targets = repair_stable_targets_migration(connection)
|
|
77
77
|
elif version in applied:
|
|
78
|
-
if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55):
|
|
78
|
+
if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59, 60):
|
|
79
79
|
repair_additive_migration(connection, version)
|
|
80
80
|
elif version == 11:
|
|
81
81
|
repair_deep_scan_migration(connection)
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""Read-only target and setup inspection shared by the MCP server and workbench."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from deep_scan_config import resolve_deep_scan_setup
|
|
13
|
+
from workbench_cli import parse_args
|
|
14
|
+
from workbench_constants import DIFF_TARGET_KINDS, EMPTY_GIT_TREE, EMPTY_GIT_TREES, optional_text
|
|
15
|
+
from workbench_target import (
|
|
16
|
+
git_bytes,
|
|
17
|
+
git_output,
|
|
18
|
+
git_target_metadata,
|
|
19
|
+
require_git_worktree_head,
|
|
20
|
+
worktree_content_digest,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def require_target(value: str) -> Path:
|
|
25
|
+
expanded = Path(value).expanduser()
|
|
26
|
+
if not expanded.is_absolute():
|
|
27
|
+
raise SystemExit("Scan target must be an absolute local directory path.")
|
|
28
|
+
target = expanded.resolve()
|
|
29
|
+
if not target.is_dir():
|
|
30
|
+
raise SystemExit(f"Scan target is not a readable local directory: {target}")
|
|
31
|
+
return target
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def inspect_target(target: Path) -> dict[str, Any]:
|
|
35
|
+
return {
|
|
36
|
+
"displayName": target.name,
|
|
37
|
+
"targetMetadata": git_target_metadata(target),
|
|
38
|
+
"targetPath": str(target),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def resolve_git_commit(target: Path, revision: str, label: str) -> str:
|
|
43
|
+
value = optional_text(revision, maximum=512)
|
|
44
|
+
if not value:
|
|
45
|
+
raise SystemExit(f"{label} is required.")
|
|
46
|
+
resolved = git_output(
|
|
47
|
+
target,
|
|
48
|
+
"rev-parse",
|
|
49
|
+
"--verify",
|
|
50
|
+
"--end-of-options",
|
|
51
|
+
f"{value}^{{commit}}",
|
|
52
|
+
)
|
|
53
|
+
if resolved is None:
|
|
54
|
+
raise SystemExit(f"{label} does not resolve to a local Git commit: {value}")
|
|
55
|
+
return resolved
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def require_diff_target(
|
|
59
|
+
target: Path,
|
|
60
|
+
kind: str | None,
|
|
61
|
+
base_revision: str | None,
|
|
62
|
+
head_revision: str | None,
|
|
63
|
+
content_digest: str | None,
|
|
64
|
+
) -> dict[str, str]:
|
|
65
|
+
current_head = require_review_changes_target(target)
|
|
66
|
+
if kind not in DIFF_TARGET_KINDS:
|
|
67
|
+
raise SystemExit("Choose which Git changes to review before starting a diff scan.")
|
|
68
|
+
if kind == "working_tree":
|
|
69
|
+
base = resolve_git_commit(target, base_revision or "HEAD", "Working-tree base")
|
|
70
|
+
head = resolve_git_commit(target, head_revision or current_head, "Working-tree HEAD")
|
|
71
|
+
current_digest = worktree_content_digest(target)
|
|
72
|
+
if base != current_head or head != current_head:
|
|
73
|
+
raise SystemExit(
|
|
74
|
+
"Repository HEAD changed after these working-tree changes were selected. "
|
|
75
|
+
"Select Uncommitted changes again."
|
|
76
|
+
)
|
|
77
|
+
if content_digest and content_digest != current_digest:
|
|
78
|
+
raise SystemExit(
|
|
79
|
+
"Working-tree contents changed after they were selected. "
|
|
80
|
+
"Select Uncommitted changes again."
|
|
81
|
+
)
|
|
82
|
+
return {
|
|
83
|
+
"kind": kind,
|
|
84
|
+
"baseRevision": current_head,
|
|
85
|
+
"headRevision": current_head,
|
|
86
|
+
"contentDigest": current_digest,
|
|
87
|
+
}
|
|
88
|
+
if kind == "commit":
|
|
89
|
+
head = resolve_git_commit(target, head_revision or "", "Commit")
|
|
90
|
+
commit = git_bytes(target, "cat-file", "-p", head)
|
|
91
|
+
if commit is None:
|
|
92
|
+
raise SystemExit(f"Commit is not available in the local checkout: {head}")
|
|
93
|
+
parent_line = next(
|
|
94
|
+
(
|
|
95
|
+
line
|
|
96
|
+
for line in commit.split(b"\n\n", 1)[0].splitlines()
|
|
97
|
+
if line.startswith(b"parent ")
|
|
98
|
+
),
|
|
99
|
+
None,
|
|
100
|
+
)
|
|
101
|
+
if parent_line is None:
|
|
102
|
+
parent = EMPTY_GIT_TREES[git_output(target, "rev-parse", "--show-object-format")]
|
|
103
|
+
else:
|
|
104
|
+
parent = resolve_git_commit(
|
|
105
|
+
target,
|
|
106
|
+
parent_line.removeprefix(b"parent ").decode("ascii").strip(),
|
|
107
|
+
"Commit parent",
|
|
108
|
+
)
|
|
109
|
+
if base_revision and base_revision != parent:
|
|
110
|
+
supplied_base = (
|
|
111
|
+
base_revision
|
|
112
|
+
if base_revision == EMPTY_GIT_TREE
|
|
113
|
+
else resolve_git_commit(target, base_revision, "Commit base")
|
|
114
|
+
)
|
|
115
|
+
if supplied_base != parent:
|
|
116
|
+
raise SystemExit("Commit base revision must match the selected commit's parent.")
|
|
117
|
+
return {"kind": kind, "baseRevision": parent, "headRevision": head}
|
|
118
|
+
base = resolve_git_commit(target, base_revision or "", "Base revision")
|
|
119
|
+
head = resolve_git_commit(target, head_revision or "", "Head revision")
|
|
120
|
+
if base == head:
|
|
121
|
+
raise SystemExit("Base and head revisions must identify different commits.")
|
|
122
|
+
return {"kind": kind, "baseRevision": base, "headRevision": head}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def inspect_setup_values(
|
|
126
|
+
target_path: str,
|
|
127
|
+
scope: str,
|
|
128
|
+
mode: str,
|
|
129
|
+
diff_target_kind: str | None,
|
|
130
|
+
diff_base_revision: str | None,
|
|
131
|
+
diff_head_revision: str | None,
|
|
132
|
+
diff_content_digest: str | None,
|
|
133
|
+
) -> dict[str, Any]:
|
|
134
|
+
target = require_target(target_path)
|
|
135
|
+
inspected = require_scannable_target(target)
|
|
136
|
+
normalized_scope = require_scope(scope, mode, target)
|
|
137
|
+
if mode == "diff" and normalized_scope != ".":
|
|
138
|
+
raise SystemExit("Review changes requires the whole target; use scope '.'.")
|
|
139
|
+
if mode != "diff" and any(
|
|
140
|
+
value is not None
|
|
141
|
+
for value in (
|
|
142
|
+
diff_target_kind,
|
|
143
|
+
diff_base_revision,
|
|
144
|
+
diff_head_revision,
|
|
145
|
+
diff_content_digest,
|
|
146
|
+
)
|
|
147
|
+
):
|
|
148
|
+
raise SystemExit("A Git diff target requires Review changes mode.")
|
|
149
|
+
diff_target = (
|
|
150
|
+
require_diff_target(
|
|
151
|
+
target,
|
|
152
|
+
diff_target_kind,
|
|
153
|
+
diff_base_revision,
|
|
154
|
+
diff_head_revision,
|
|
155
|
+
diff_content_digest,
|
|
156
|
+
)
|
|
157
|
+
if mode == "diff"
|
|
158
|
+
else None
|
|
159
|
+
)
|
|
160
|
+
return {
|
|
161
|
+
"diffTarget": diff_target,
|
|
162
|
+
"scope": normalized_scope,
|
|
163
|
+
"target": inspected,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def require_review_changes_target(target: Path) -> str:
|
|
168
|
+
revision = require_git_worktree_head(target)
|
|
169
|
+
repository_root = git_output(target, "rev-parse", "--show-toplevel")
|
|
170
|
+
if repository_root is None or not Path(repository_root).samefile(target):
|
|
171
|
+
raise SystemExit(
|
|
172
|
+
"Review changes requires the checked-out Git repository root as the target."
|
|
173
|
+
)
|
|
174
|
+
return revision
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def require_scannable_target(target: Path) -> dict[str, Any]:
|
|
178
|
+
inspected = inspect_target(target)
|
|
179
|
+
metadata = inspected["targetMetadata"]
|
|
180
|
+
if metadata["isGit"] and not metadata["isWorktree"]:
|
|
181
|
+
raise SystemExit(
|
|
182
|
+
"Codex Security requires a checked-out worktree, not a bare Git repository."
|
|
183
|
+
)
|
|
184
|
+
return inspected
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def require_scope(scope: str, mode: str, target: Path) -> str:
|
|
188
|
+
value = scope if scope.strip() else "."
|
|
189
|
+
requested_scope = Path(value)
|
|
190
|
+
if "\\" in value and (os.name != "nt" or not requested_scope.is_absolute()):
|
|
191
|
+
raise SystemExit("Scan scope must use repository-relative POSIX paths.")
|
|
192
|
+
if ".." in requested_scope.parts:
|
|
193
|
+
raise SystemExit("Scan scope must stay inside the scanned target.")
|
|
194
|
+
try:
|
|
195
|
+
resolved_scope = (
|
|
196
|
+
requested_scope if requested_scope.is_absolute() else target / requested_scope
|
|
197
|
+
).resolve()
|
|
198
|
+
relative_scope = resolved_scope.relative_to(target)
|
|
199
|
+
except (RuntimeError, ValueError) as exc:
|
|
200
|
+
raise SystemExit("Scan scope must stay inside the scanned target.") from exc
|
|
201
|
+
normalized = relative_scope.as_posix() or "."
|
|
202
|
+
if not normalized.strip():
|
|
203
|
+
normalized = "./" + normalized
|
|
204
|
+
if mode == "deep" and normalized != ".":
|
|
205
|
+
raise SystemExit("Deep Scan is repository-wide and cannot use a scoped path.")
|
|
206
|
+
if not resolved_scope.is_dir():
|
|
207
|
+
raise SystemExit("Scan scope must reference an existing directory inside the target.")
|
|
208
|
+
return normalized
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def inspect_selected_setup(args: argparse.Namespace) -> dict[str, Any]:
|
|
212
|
+
inspected = inspect_setup_values(
|
|
213
|
+
args.target_path,
|
|
214
|
+
args.scope,
|
|
215
|
+
args.mode,
|
|
216
|
+
args.diff_target_kind,
|
|
217
|
+
args.diff_base_revision,
|
|
218
|
+
args.diff_head_revision,
|
|
219
|
+
args.diff_content_digest,
|
|
220
|
+
)
|
|
221
|
+
if args.mode == "deep":
|
|
222
|
+
inspected["deepScanConfig"] = resolve_deep_scan_setup(
|
|
223
|
+
os.cpu_count() or 1, args.deep_scan_project_json
|
|
224
|
+
)
|
|
225
|
+
elif args.deep_scan_project_json is not None:
|
|
226
|
+
raise SystemExit("Project Deep Scan settings require Deep Scan mode.")
|
|
227
|
+
return inspected
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def inspect_command(args: argparse.Namespace) -> dict[str, Any]:
|
|
231
|
+
if args.command == "inspect-target":
|
|
232
|
+
return inspect_target(require_target(args.target_path))
|
|
233
|
+
return inspect_selected_setup(args)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def main() -> None:
|
|
237
|
+
sys.stdin.reconfigure(encoding="utf-8")
|
|
238
|
+
args = parse_args("Codex Security workbench persistence.", inspection_only=True)
|
|
239
|
+
print(json.dumps(inspect_command(args), allow_nan=False, sort_keys=True))
|
|
@@ -17,7 +17,7 @@ from unicodedata import normalize
|
|
|
17
17
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
18
18
|
from workbench_target import (
|
|
19
19
|
clean_worktree_content_digest,
|
|
20
|
-
|
|
20
|
+
git_command,
|
|
21
21
|
git_worktree_context,
|
|
22
22
|
)
|
|
23
23
|
from workbench_validation import reject_non_finite_json
|
|
@@ -74,19 +74,14 @@ def safe_source_path(target: Path, value: str) -> Path | None:
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
def offline_git_bytes(repository: Path, *arguments: str) -> bytes | None:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
for name, value in previous.items():
|
|
86
|
-
if value is None:
|
|
87
|
-
os.environ.pop(name, None)
|
|
88
|
-
else:
|
|
89
|
-
os.environ[name] = value
|
|
77
|
+
result = git_command(
|
|
78
|
+
repository,
|
|
79
|
+
*arguments,
|
|
80
|
+
text=False,
|
|
81
|
+
offline=True,
|
|
82
|
+
environment_overrides={"GIT_NO_REPLACE_OBJECTS": "1"},
|
|
83
|
+
)
|
|
84
|
+
return result.stdout if result.returncode == 0 else None
|
|
90
85
|
|
|
91
86
|
|
|
92
87
|
@cache
|
|
@@ -120,9 +115,7 @@ def tree_entries(repository: Path, tree: str) -> dict[str, tuple[tuple[str, str,
|
|
|
120
115
|
return {name: tuple(matches) for name, matches in entries.items()}
|
|
121
116
|
|
|
122
117
|
|
|
123
|
-
def exact_tree_path(
|
|
124
|
-
repository: Path, tree: str, value: str, *, require_unambiguous: bool = False
|
|
125
|
-
) -> tuple[str, str, str] | None:
|
|
118
|
+
def exact_tree_path(repository: Path, tree: str, value: str) -> tuple[str, str, str] | None:
|
|
126
119
|
path = relative_path(value)
|
|
127
120
|
if path is None:
|
|
128
121
|
return None
|
|
@@ -132,12 +125,11 @@ def exact_tree_path(
|
|
|
132
125
|
return None
|
|
133
126
|
entries = tree_entries(repository, object_id) or {}
|
|
134
127
|
aliases = entries.get(normalized_path_component(name), ())
|
|
135
|
-
if
|
|
128
|
+
if len(aliases) != 1:
|
|
136
129
|
return None
|
|
137
|
-
|
|
138
|
-
if
|
|
130
|
+
entry_name, kind, object_id = aliases[0]
|
|
131
|
+
if entry_name != name:
|
|
139
132
|
return None
|
|
140
|
-
_, kind, object_id = entry
|
|
141
133
|
return path.as_posix(), kind, object_id
|
|
142
134
|
|
|
143
135
|
|
|
@@ -329,7 +321,7 @@ def load_source_scopes(
|
|
|
329
321
|
repository, tree = context
|
|
330
322
|
scopes = []
|
|
331
323
|
for path in paths:
|
|
332
|
-
entry = exact_tree_path(repository, tree, path
|
|
324
|
+
entry = exact_tree_path(repository, tree, path)
|
|
333
325
|
if entry is None or entry[1] not in {"file", "directory"}:
|
|
334
326
|
continue
|
|
335
327
|
kind = entry[1]
|
|
@@ -375,7 +367,7 @@ def source_object_for_path(
|
|
|
375
367
|
if scope["kind"] == "file":
|
|
376
368
|
return scope["objectId"] if not suffix else None
|
|
377
369
|
relative = PurePosixPath(*suffix).as_posix()
|
|
378
|
-
entry = exact_tree_path(repository, scope["objectId"], relative
|
|
370
|
+
entry = exact_tree_path(repository, scope["objectId"], relative)
|
|
379
371
|
if entry is None:
|
|
380
372
|
selected = safe_source_path(target, scope["canonicalPath"])
|
|
381
373
|
if selected is not None:
|