docs: fix inconsistent commandRegex example in policy engine - #19027
Conversation
- Remove incorrect `^` anchor from the `commandRegex` example in `policy-engine.md`. - Clarify that `commandRegex` prepends `"command":"` to the pattern, effectively matching from the start of the command value. - Add a regression test in `toml-loader.test.ts` to verify that `^` in `commandRegex` does not match the stringified JSON arguments.
Summary of ChangesHello @NTaylorMullen, 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 addresses an inconsistency in the policy engine's Highlights
Changelog
Activity
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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request clarifies the commandRegex documentation within the policy engine, correcting the understanding that the regex matches against the full JSON representation of arguments, and includes a regression test in toml-loader.test.ts. While these changes improve clarity and robustness, they also expose a critical architectural vulnerability. The policy engine's current method of matching commandRegex against a full JSON string of tool arguments allows for easy policy bypass through injection into non-validated fields, which could lead to unauthorized arbitrary command execution if an attacker can manipulate tool arguments. The remediation suggestion has been updated to reflect that toolCall.args must be parsed as a JSON string before accessing its properties.
|
Size Change: -2 B (0%) Total Size: 24.4 MB ℹ️ View Unchanged
|
Summary
Fix inconsistent
commandRegexdocumentation and example. The example incorrectly used a^anchor which would never match because the pattern is tested against stringified JSON arguments.Details
docs/core/policy-engine.mdto remove^from thecommandRegexexample.commandRegexprepends\"command\":\"to the pattern.packages/core/src/policy/toml-loader.test.tsto verify that^incommandRegexcauses a mismatch.Related Issues
Fixes https://chat.google.com/room/AAQApBm33UQ/zJmZJPS5j1s/zJmZJPS5j1s?cls=10
How to Validate
npm test -w @google/gemini-cli-core -- src/policy/toml-loader.test.tsshould NOT match if ^ is used in commandRegex because it matches against full JSONpasses.docs/core/policy-engine.md.Pre-Merge Checklist