Skip to content

fix(git): pin trusted executables across scan hosts - #467

Draft
mldangelo-oai wants to merge 9 commits into
mainfrom
mdangelo/codex/trust-repository-git-executable
Draft

fix(git): pin trusted executables across scan hosts#467
mldangelo-oai wants to merge 9 commits into
mainfrom
mdangelo/codex/trust-repository-git-executable

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Use one trusted Git executable consistently across SDK scans, the bundled workbench, and MCP hosts.

Fixes #129. Extends the still-open proposal in #140.

Changes

  • Carry selected absolute tool invocations and the sanitized environment through scan hosts, including committed inventory and changed-file ranking.
  • Keep executable selection anchored to the scanned repository while preserving safe user Git configuration, optional-Git behavior, and trusted wrapper invocation names.
  • Use one executable-inspection result instead of resolving Git twice. Preserve platform-default lookup when PATH is omitted without broadening an explicitly empty or rejected path.
  • Share Python executable checks between Git and ripgrep, retaining repository-path and Windows native-executable protections. Inventory helpers report an unavailable tool before spawning and can safely use tools added later by Codex.
  • When trusted host ripgrep is unavailable, copy only the running SDK's packaged native ripgrep into its existing private runtime workspace and validate the copied absolute path. This preserves repository-local npm installations without allowing executable lookup inside the scanned repository.
  • Preserve case-distinct POSIX environment variables and normalize Windows PATH aliases consistently.
  • Treat missing or non-directory historical targets as unavailable Git probes so completed history and repository matching remain usable. Unrelated filesystem errors still propagate.
  • Keep both bundled-plugin version fields at 0.1.22 so cached hosts refresh the helper changes.
  • Merge the recorded main additively.

Testing

Current head 743e32f0:

  • bun test --timeout 30000 tests-ts/runtime.test.ts --test-name-pattern 'stages only package-owned native ripgrep and cleans failed copies|resolves the exact npm Codex executable|uses an explicit Codex executable override' — three passed.
  • bun test --timeout 30000 tests-ts/api.test.ts --test-name-pattern 'binds staged bundled ripgrep only when a trusted host tool is unavailable|cleans the bootstrap workspace when credential-home cleanup fails' — two passed. New package, filesystem, and platform cases use isolated mocks.
  • bun test --timeout 30000 tests-ts/workbench-tool-environment.test.ts tests-ts/workbench-scan-history.test.ts — ten tests passed on Python 3.12.12 and again on Python 3.10.19 with tomli 2.3.0.
  • bun --no-env-file test --randomize --seed 12345 --timeout 30000 ./tests-ts — 1,316 passed, 11 skipped, zero failures, and 9,286 assertions with Bun 1.3.14. Live integration and machine-policy opt-ins were disabled.
  • pnpm run types and pnpm run format — passed.
  • ruff check --no-cache _bundled_plugin/scripts/workbench_target.py _bundled_plugin/scripts/generate_in_scope_files.py _bundled_plugin/scripts/generate_rank_input.py — passed. These modules and workbench_scan_history also imported successfully under Python 3.10.19.
  • pnpm run build, pnpm pack, pnpm run check:package, and the separate pnpm run test:package on the resulting openai-codex-security-0.1.14.tgz — passed. The package validator checked 218 archive entries and 106 bundled-plugin files. Both installed checks ran the actual nested worker with its original timeout.
  • git diff --check — passed.
  • Three fresh native reviews plus independent exact-head verification — clean, with no confirmed findings.

The source head and tree stayed clean and unchanged through all local gates. Standard and cross-platform remote CI remain pending for the published head.

Risk and rollout

Git remains optional, safe user settings remain available, and the existing snapshot and scan-completion contracts are unchanged. The packaged-ripgrep fallback uses the installed application's native-package provenance and existing runtime cleanup; it does not relax the Python repository exclusion or add a persistent executable cache. Explicit disable bindings remain effective on POSIX and Windows. The missing-PATH behavior follows the documented Node command-lookup defaults.

Integrate #449 first and retain its streamed Git command support, committed-object immutability, and offline-read policy. Preserve its shared-runner routing and immutable blob-read flags. Reconcile the shared inventory and containment changes in #320 and #472 when they land. This branch uses paired plugin version 0.1.22; the recorded #449, #462, and #472 heads carried competing 0.1.21 updates. Before merging, update both version fields together to the next monotonic version after the preceding plugin changes, then rerun the integration checks on the resulting head.

Public disclosure review

Newly authored material was reviewed for public disclosure. Existing automated review comments contain access-restricted report references; maintainer cleanup remains outstanding.

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions github-actions Bot added the bug Something isn't working label Aug 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5dc0f1c298

ℹ️ 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".

Comment thread sdk/typescript/src/api.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 5dc0f1c298

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9be47a60bb

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9be47a60bb

ℹ️ 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".

Comment thread sdk/typescript/src/api.ts Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_target.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 49000ab013

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49000ab013

ℹ️ 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".

Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_target.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_target.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 78123a7e99

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 78123a7e99

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 743e32f028ab8bb71e5d2607f1b30832269aabba.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 743e32f028

ℹ️ 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".

Comment thread sdk/typescript/src/api.ts
Comment on lines +651 to +655
const git = await inspectTrustedExecutable(
"git",
pluginEnvironment,
protectedGitRoot,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor explicit Git disable bindings

When the SDK environment sets CODEX_SECURITY_GIT="" to disable optional Git, this lookup ignores the binding, discovers Git from PATH, and later replaces the empty value with that executable. Codebase scans therefore use a Git snapshot instead of the requested directory fallback, while diff scans proceed rather than reporting Git as unavailable. Check the binding before lookup, including case-insensitive aliases on Windows, as is already done for ripgrep.

AGENTS.md reference: sdk/typescript/AGENTS.md:L19-L20

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 743e32f028

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundled workbench resolves Git from inherited PATH instead of the trusted executable boundary

1 participant