Add support for policy engine in extensions#20049
Conversation
Summary of ChangesHello @chrstnb, 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 significantly enhances the Gemini CLI's extensibility by allowing extensions to securely integrate with the core policy engine. It introduces a dedicated policy tier for extensions, ensuring their rules are applied appropriately within the existing hierarchy. The changes include robust security measures to prevent extensions from undermining user control or system safety, alongside automated management of policy registration and unregistration. This enables extensions to provide valuable guardrails and custom security checks, making the CLI more adaptable and secure. 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 introduces a well-designed feature enabling extensions to contribute to the policy engine, including a new policy tier and security restrictions to prevent extensions from bypassing user confirmations. While the security architecture is generally well-thought-out, a critical Path Traversal vulnerability was identified in the extension policy loading logic. The policies path from the manifest is not validated to remain within the extension's directory, which could lead to unauthorized file access and must be addressed. Additionally, an issue was found where a safety checker's source is modified twice, which would break the unregistration logic.
|
Size Change: +4.15 kB (+0.02%) Total Size: 25.7 MB
ℹ️ View Unchanged
|
|
Build failed: Build process failed with link errors: |
|
Build failed: Build process failed with link errors: |
43de1f6 to
9851e0c
Compare
Abhijit-2592
left a comment
There was a problem hiding this comment.
LGTM with minor cosmetic comments
Co-authored-by: Jerop Kipruto <jerop@google.com>
Co-authored-by: Jerop Kipruto <jerop@google.com>
Summary
Add support for extensions to contribute policy rules and safety checkers to the policy engine. It establishes a secure framework for extensions to provide guardrails while preventing them from bypassing user confirmation or security modes.
Details
1. Core policy engine enhancements
removeRulesBySourceandremoveCheckersBySourcetoPolicyEngineto allow surgical removal of extension-contributed rules when an extension is deactivated.2. Extension configuration and manifest
policiesproperty has been removed fromgemini-extension.json.GeminiCLIExtensioninterface to carry parsed rules and checkers through the system lifecycle.3. Security mandates (critical)
To prevent extensions from compromising system security, the following restrictions are enforced during policy loading:
allowrules: Any rule contributing anALLOWdecision is strictly ignored. Extensions can only useDENYorASK_USERdecisions.yolomode: Extensions are prohibited from contributing rules or checkers foryolomode.4. Lifecycle automation
ExtensionLoadernow automatically registers policy rules and checkers when an extension starts.sourcefield to avoid affecting other extensions or system policies.5. Documentation and examples
docs/extensions/reference.mdwith:policies/directory).allowandyoloconfigurations.packages/cli/src/commands/extensions/examples/policies, which provides a hands-on example of contributing rules and safety checkers via the newpolicies/directory.6. Verification and quality
npm run buildandnpm run lint.Related Issues
Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1407
Fixes #19702
How to Validate
Pre-Merge Checklist