Repository navigation
docs(extensions): correct excludeTools examples that never match - #28963
chandlerm923 wants to merge 1 commit into
Conversation
`excludeTools` entries are compared against whole tool names: `Config.getExcludeTools()` collects them into a `Set` and `ToolRegistry` tests membership with `Set.has()`. An entry such as `run_shell_command(rm -rf)` therefore matches nothing and is silently ignored, yet `best-practices.md` presented that form and stated it "ensures the CLI blocks dangerous commands". Show the form that works, and point readers at the policy engine for command-level blocking, which is where that capability now lives (the settings-level `tools.exclude` was deprecated in favour of it). The policy snippet mirrors the shipped example extension in `examples/policies/`. Related to google-gemini#28962
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request corrects misleading documentation regarding the 'excludeTools' property in extension manifests. It clarifies that 'excludeTools' matches only against full tool names and does not support partial command-level filtering as previously suggested. The changes direct users toward the policy engine for fine-grained command control and update the associated example manifest to reflect valid usage. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request updates the documentation and example configuration for excludeTools to clarify that it only supports matching whole tool names. It guides users to use the policy engine in the policies/ directory for restricting individual commands instead. I have no additional feedback to provide as there are no review comments.
Note: Security Review has been skipped due to the limited scope of the PR.
Summary
docs/extensions/best-practices.mdtold extension authors to write{ "excludeTools": ["run_shell_command(rm -rf *)"] }and stated that this "ensures the CLI blocks dangerous commands". It does not.
Extension
excludeToolsentries are compared against whole tool names, so anentry containing
(...)matches nothing and is silently dropped — the tool staysavailable to the model with no warning.
This corrects the two extension doc pages and the shipped example manifest to
show a form that actually takes effect.
Details
Config.getExcludeTools()foldsextension.excludeToolsinto aSet(
packages/core/src/config/config.ts:2431-2439), andToolRegistry.isActiveTooltests membership directly (
packages/core/src/tools/tool-registry.ts:637):possibleNamesholds the tool's real names —run_shell_command, its classname, and MCP-qualified variants — none of which equal
"run_shell_command(rm -rf *)".The parenthesised
toolName(args)shape is real syntax, but it belongs totools.core/tools.allowed, which are parsed bymapToolsToRules(
packages/core/src/policy/config.ts:445-476). ExtensionexcludeToolsnevergoes through that path.
For the "block one specific command" case the page was describing, that
capability now lives in the policy engine: the settings-level
tools.excludewasdeprecated in its favour (#18508, documented at
docs/tools/shell.md:158anddocs/cli/enterprise.md:267), and extensions can ship rules in apolicies/directory. The TOML snippet added here mirrors the shipped example extension in
packages/cli/src/commands/extensions/examples/policies/.Note on
decision: that example extension usesask_userforrm -rf, but theoriginal prose promised the CLI "blocks" the command, so
denypreserves thestated intent. Happy to switch it to
ask_userif you'd rather the two examplesmatch exactly.
Related Issues
Related to #28962
How to Validate
The exclusion behaviour, using the real
ConfigandToolRegistry:excludeToolsentryrun_shell_commandstill registered[]["run_shell_command"]["run_shell_command(rm -rf)"]["run_shell_command(rm -rf *)"]The policy snippet added to
best-practices.md, loaded through the realextension policy loader and evaluated by
PolicyEngine:Docs checks:
Pre-Merge Checklist
documentation change