fix(sdk): bind post-scan artifact restoration - #468
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review Please review the current head, |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review Please review commit |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review Please review the current head |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8fc845591
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
kmbroai
left a comment
There was a problem hiding this comment.
Critical review
Reviewed head 1664172ca719ae1f4dc07ed23e6e228aab900324 and compared the overlapping newer #626 implementation.
Recommendation: supersede this PR with #626 rather than merging both. The underlying restoration fix is necessary, but this older version changes an unrelated write contract and ties recovery to the selected plugin's helper API.
[P2] Restrict unchanged-content short-circuiting to restoration
The new comparison in write_scan_local_bytes returns early for all identical writes, including ordinary callers that previously received a new private file. I executed the actual helper against an existing 0644 artifact with identical contents: this head left both its mode and inode unchanged. The corresponding #626 helper replaced it and produced mode 0600. Gate the optimization on restoration identity being supplied, as #626 does. Content equality is not equivalent to preserving the original writer's metadata/replacement contract.
Custom-plugin and bundle compatibility
prepareScanArtifactRestorer invokes options.pluginRoot and assumes that plugin contains the newly introduced scan_root_identity API. An otherwise compatible existing custom plugin will fail restoration setup and therefore skip requested post-scan instructions. Recovery is an SDK guarantee, so use the SDK-owned helper independently of the selected scan plugin. This PR also changes bundled Python code without advancing the bundled version markers; the version-keyed install/cache path needs an upgrade plan. #626 addresses both points and avoids the unbounded whole-file equality read in this version.
Existing feedback and verification
The earlier checked-path/rename race is addressed in the current implementation by held descriptors/handles; the unrelated credential-lock edit was removed. I am not re-reporting those old comments as current defects.
Ran the checked-in post-scan suite: 13 passed, 0 failed, plus the paired ordinary-write reproduction above. Linux with Bun 1.3.14 / Node 22.13.1 and cached dependencies; no native Windows or live model run. Keep the regression fixtures, but consolidate the production fix into #626.
Summary
Keep completed scan artifacts inside the validated scan output tree when a post-scan follow-up fails.
Changes
mainand remove unrelated credential-lock changes from this branch; that work remains in fix(runtime): use process-owned credential-home locks #613.Testing
bun test --timeout 30000 tests-ts/api-post-scan.test.ts tests-ts/contract.test.ts: 56 passedbun test --timeout 30000 tests-ts/api.test.ts: 118 passed, 2 platform skipsbun test --timeout 30000 tests-ts/api-credentials.test.ts: 5 passedpnpm run typespnpm run formatpnpm run builduv run ruff check _bundled_plugin/scripts/finalize_scan_contract.py _bundled_plugin/scripts/windows_scan_local_files.pypnpm pack --pack-destination ../../distpnpm run check:package ../../dist/openai-codex-security-0.1.16.tgz: installed-package smoke passed and 255 entries validatedgit diff --checkandgit diff --cached --checkNative Windows execution remains covered by CI; I did not wait for CI before moving to the next PR.
Risk and rollout
This does not change the documented SDK surface, CLI, flags, environment variables, dependencies, or state format. Failed follow-ups may atomically replace damaged sealed artifacts, then the completed contract is revalidated. Unchanged artifacts keep their existing file identity and timestamps.
If the scan root or an artifact parent changes identity, restoration fails closed instead of writing through the replacement path. If restoration setup itself is unavailable, the follow-up is skipped and the completed scan is returned with a warning.
Public disclosure review
The second attestation remains unchecked because already-published history includes an author email, access-restricted report links, and public review discussion of the vulnerability. This update does not rewrite public history.