Skip to content

Conversation

@bolinfest
Copy link
Collaborator

I noted that the logic for determining whether an rg or git invocation was
safe diverged between is_safe_command.rs and windows_safe_commands.rs, so
this PR reconciles the two in a shared shared_rules.rs file.

I noted that the logic for determining whether an `rg` or `git` invocation was
safe diverged between `is_safe_command.rs` and `windows_safe_commands.rs`, so
this PR reconciles the two in a shared `shared_rules.rs` file.
@jif-oai
Copy link
Collaborator

jif-oai commented Dec 13, 2025

@codex review

Copy link
Contributor

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

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.

ℹ️ 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 on lines +38 to +42
if arg.starts_with('-') {
if arg.eq_ignore_ascii_case("-c") || arg.eq_ignore_ascii_case("--config") {
if iter.next().is_none() {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Reject git -c/--config to prevent approval bypass

The shared Git safelist now accepts -c/--config without validating which config keys are being set. Because Git uses config values to launch external programs (e.g., core.pager or diff.external during log/show/diff), a command like git -c core.pager=sh -c '...' log will be treated as safe and skip approval. This is a regression for non‑Windows callers where any leading option previously made the command unsafe. Consider rejecting -c/--config here or whitelisting only known‑safe keys.

Useful? React with 👍 / 👎.

Copy link
Contributor

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

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.

ℹ️ 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 on lines +39 to +43
if arg.eq_ignore_ascii_case("-c") || arg.eq_ignore_ascii_case("--config") {
if iter.next().is_none() {
return false;
}
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Disallow git -c/--config overrides in safe list

Because Unix now uses is_safe_git_command, this helper explicitly allows -c/--config before a whitelisted subcommand. git -h documents that -c <name>=<value> overrides config and -p/--paginate forces a pager, so an invocation like git -c core.pager=/usr/bin/env -p log can spawn an arbitrary executable while still being treated as “safe.” Previously, any pre-subcommand option (including -c) caused Unix commands to be rejected, so this is a security regression. Consider disallowing -c/--config (and --config-env) or whitelisting specific keys/values instead.

Useful? React with 👍 / 👎.

Copy link
Contributor

@LIHUA919 LIHUA919 left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants