#8633: fix: support wildcard patterns (* and **) in exec allowlist
stale
Cluster:
Session Management Enhancements
## Summary
- Fix bug where `*` and `**` patterns in exec-approvals.json allowlist were silently ignored
- Add special handling for `*` and `**` as universal "allow all" patterns
- Allow patterns containing wildcards to be processed (previously skipped if no path separator)
## Problem
When users configure `exec-approvals.json` with a wildcard pattern like `*` in the allowlist:
```json
{
"agents": {
"*": {
"allowlist": [{ "pattern": "*" }]
}
}
}
```
The pattern was being skipped because `matchAllowlist()` checked for path separators (`/`, `\`, `~`) and discarded patterns without them. This caused commands to be denied even though the user expected all commands to be allowed.
## Solution
1. Treat `*` and `**` as special "match all" patterns that immediately return a match
2. Allow patterns containing wildcards (`*` or `?`) to be processed, not just patterns with path separators
## Test plan
- [x] Added unit tests for `*` and `**` universal patterns
- [x] All existing tests pass (40 tests in exec-approvals.test.ts)
- [x] `pnpm build && pnpm check && pnpm test` passes
Fixes #8585
---
🤖 Generated with Claude Code
**AI Disclosure**: This PR was generated with AI assistance (Claude Opus 4.5).
- Testing level: Unit tests added and full test suite verified
- Code understanding: Reviewed matchAllowlist function logic and identified the hasPath check as the root cause
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates exec allowlist matching so wildcard patterns are no longer silently skipped: it treats `*` and `**` as universal allow-all entries and allows patterns containing `*`/`?` to be evaluated even when they don’t look path-like. Unit tests were added to cover `*` and `**` in `matchAllowlist()`.
One behavioral edge case remains: `matchAllowlist()` returns `null` whenever `resolvedPath` is missing, which means the new universal patterns still won’t match in those scenarios.
<h3>Confidence Score: 4/5</h3>
- This PR is largely safe to merge, with a small behavioral edge case around unresolved executables.
- Changes are small and localized with added unit coverage. The main risk is that universal `*`/`**` patterns are still bypassed when `resolvedPath` is undefined due to the existing early return, which could surprise users relying on allow-all behavior in environments where command resolution fails.
- src/infra/exec-approvals.ts (matchAllowlist early return behavior)
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21733: security(exec): platform-aware allowlist matching and restricted sa...
by Esubaalew · 2026-02-20
77.6%
#20435: fix(exec): prioritize user 'always allow' config over tool defaults...
by ChisomUma · 2026-02-18
73.9%
#11854: fix: resolve per-agent tools.exec config in pi-tools
by Yida-Dev · 2026-02-08
73.3%
#14734: test(agents): guard against stale allowAgents in existing sessions
by davidahmann · 2026-02-12
72.7%
#16194: fix: route exec approvals to explicit targets regardless of session...
by MisterGuy420 · 2026-02-14
72.7%
#21661: fix(agents): treat approval timeout as denial regardless of askFall...
by AI-Reviewer-QS · 2026-02-20
72.7%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
72.6%
#19254: fix(feishu): honor wildcard group config for reply policy
by WaynePika · 2026-02-17
72.4%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
72.2%
#9259: Fix: Restore explicit glob patterns in package.json files field
by vishaltandale00 · 2026-02-05
72.2%