Skip to content

Conversation

@zhao-oai
Copy link
Contributor

@zhao-oai zhao-oai commented Nov 13, 2025

  • enabling execpolicy2 parser to parse multiple policy files to build a combined Policy (useful if codex detects many .codexpolicy files)
  • adding functionality to Policy to allow evaluation of multiple cmds at once (useful when we have chained commands)

@zhao-oai zhao-oai changed the base branch from main to dev/zhao/execpolicy2 November 13, 2025 22:12
@zhao-oai
Copy link
Contributor Author

@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 13 to 17
/// Evaluate a command against a policy.
Check {
#[arg(short, long, value_name = "PATH")]
policy: PathBuf,
#[arg(short, long, value_name = "PATH", required = true)]
policies: Vec<PathBuf>,

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 Preserve --policy CLI flag name

Renaming the field from policy to policies in the Clap definition changed the generated long option to --policies, because #[arg(long)] derives the flag name from the field identifier. The README and existing CLI usage still rely on --policy, so the sample command (cargo run … -- check --policy …) now fails with “found argument '--policy' which wasn't expected”, and any automation using the old flag breaks. Please keep the long name stable by explicitly setting long = "policy" (or by keeping the field name singular) so the CLI remains backward compatible while still accepting multiple paths.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this crate hasn't been merged yet. we are free to make breaking changes

@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2 branch from 35f3561 to ce220f0 Compare November 14, 2025 03:07
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2-extension branch from 784ce0d to bdb5210 Compare November 14, 2025 03:08
Comment on lines 356 to 363
prefix_rule(
pattern = ["git", "status"],
decision = "allow",
)
prefix_rule(
pattern = ["git"],
decision = "prompt",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the decision for git status: is it prompt because that's stricter than allow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it should be prompt!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does that make the git status rule useless? How would it ever be allowed?

@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2 branch from ce220f0 to ce50c94 Compare November 14, 2025 19:16
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2-extension branch from 636cb31 to 340895f Compare November 14, 2025 19:16
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2 branch from ce50c94 to 94d2943 Compare November 17, 2025 05:06
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2-extension branch from 340895f to 51249c8 Compare November 17, 2025 05:07
Base automatically changed from dev/zhao/execpolicy2 to main November 17, 2025 18:15
@zhao-oai zhao-oai requested a review from bolinfest November 17, 2025 18:15
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2-extension branch from 51249c8 to c14008b Compare November 17, 2025 18:18
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy2-extension branch from c14008b to 43ca23f Compare November 17, 2025 18:28
Comment on lines 356 to 363
prefix_rule(
pattern = ["git", "status"],
decision = "allow",
)
prefix_rule(
pattern = ["git"],
decision = "prompt",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does that make the git status rule useless? How would it ever be allowed?

@zhao-oai
Copy link
Contributor Author

@bolinfest (not sure why it's not letting me reply) -- fixed the git status test case to be more realistic as well

#[test]
fn strictest_decision_across_multiple_commands() {
let policy_src = r#"
prefix_rule(
Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed, remove this and change ["git"] to "prompt".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is done!

@zhao-oai zhao-oai merged commit 7ab4548 into main Nov 18, 2025
25 checks passed
@zhao-oai zhao-oai deleted the dev/zhao/execpolicy2-extension branch November 18, 2025 00:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants