Skip to content

Conversation

@zhao-oai
Copy link
Contributor

@zhao-oai zhao-oai commented Dec 4, 2025

adding execpolicy support into the posix mcp

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

@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch 4 times, most recently from fb0cb00 to e9a6dc4 Compare December 4, 2025 21:20
@zhao-oai zhao-oai requested a review from bolinfest December 4, 2025 21:21
bolinfest added a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from a6eddba to 185e685 Compare December 4, 2025 23:17
zhao-oai pushed a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 185e685 to 2d1a155 Compare December 4, 2025 23:29
zhao-oai pushed a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 2d1a155 to d0519b6 Compare December 4, 2025 23:31
zhao-oai pushed a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from d0519b6 to 1b2b3ca Compare December 4, 2025 23:32
zhao-oai pushed a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 1b2b3ca to 212857d Compare December 4, 2025 23:33
zhao-oai pushed a commit that referenced this pull request Dec 4, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 212857d to 627e70d Compare December 4, 2025 23:47
@zhao-oai zhao-oai requested a review from bolinfest December 4, 2025 23:49
@zhao-oai
Copy link
Contributor Author

zhao-oai commented Dec 4, 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 +199 to +207
Ok(match evaluation.decision {
Decision::Forbidden => ExecPolicyOutcome::Forbidden,
Decision::Prompt => ExecPolicyOutcome::Prompt {
run_with_escalated_permissions: decision_driven_by_policy,
},
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 Policy prompts are always escalated

When execpolicy yields Decision::Prompt, run_with_escalated_permissions is set whenever any non-heuristic rule matched, so determine_action will run the command via EscalateAction::Escalate after the user approves. That means an execpolicy rule that merely requests approval will cause the command to bypass the sandbox entirely once accepted, whereas the core execpolicy flow only bypasses the sandbox for explicit Allow rules (see core/src/exec_policy.rs where bypass_sandbox is tied to Decision::Allow). This over-escalates any prompted command defined in policy, weakening sandbox protections without the policy opting into it.

Useful? React with 👍 / 👎.

zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 627e70d to fd8d68a Compare December 5, 2025 00:52
zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from fd8d68a to aa58369 Compare December 5, 2025 00:56
zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from aa58369 to d65dd48 Compare December 5, 2025 00:57
zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from d65dd48 to be05876 Compare December 5, 2025 01:06
zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from be05876 to 1ef31fc Compare December 5, 2025 01:07
zhao-oai pushed a commit that referenced this pull request Dec 5, 2025
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 1ef31fc to 4c23d0b Compare December 5, 2025 01:08
…7615)

The caller should decide whether wrapping the policy in `Arc<RwLock>` is
necessary. This should make #7609 a
bit smoother.

- `exec_policy_for()` -> `load_exec_policy_for_features()`
- introduce `load_exec_policy()` that does not take `Features` as an arg
- both return `Result<Policy, ExecPolicyError>` instead of
Result<Arc<RwLock<Policy>>, ExecPolicyError>`

This simplifies the tests as they have no need for `Arc<RwLock>`.

.
@zhao-oai zhao-oai force-pushed the dev/zhao/execpolicy-mcp branch from 4c23d0b to f1ddea3 Compare December 5, 2025 01:14
@zhao-oai zhao-oai requested a review from bolinfest December 5, 2025 01:15
Comment on lines +189 to +195
let evaluation = policy.check(&command, &|cmd| {
if command_might_be_dangerous(cmd) {
Decision::Prompt
} else {
Decision::Allow
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This HeuristicsFallback abstraction feels weird to me. I'm going to revisit in a follow-up.

Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

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

Let's get this in and I can change, as necessary.

@bolinfest bolinfest merged commit b1c918d into main Dec 5, 2025
45 of 47 checks passed
@bolinfest bolinfest deleted the dev/zhao/execpolicy-mcp branch December 5, 2025 05:55
@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 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