Tighten private Auto Memory patch allowlist#26535
Conversation
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 introduces stricter validation for private and global memory patches to ensure they only target intended files. By centralizing target validation logic and providing a mechanism for fine-grained path filtering, the system now prevents unauthorized modifications to system files, nested directories, and non-markdown content, while maintaining compatibility with existing workflows. 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
|
|
Size Change: +4.3 kB (+0.01%) Total Size: 34 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request enhances memory patch security by implementing fine-grained validation for patch targets. It introduces a validation context and specific checks to ensure patches only modify allowed markdown files within the project or global memory directories. The core patch application logic was also updated to support these additional constraints. Review feedback identifies opportunities to optimize path resolution logic by removing redundant calls and simplifying filename validation logic.
Summary
Tightens Auto Memory private patch validation so private memory patches can only target the project memory document set:
MEMORY.mdand direct sibling markdown files in the project memory directory.Details
Private memory patch listing, aggregate apply/dismiss, and direct apply now share a kind-aware target validator. The validator rejects in-root but non-memory targets such as extraction state files, locks,
.inbox/,skills/, nested paths, and non-markdown files.The shared parsed-patch applicator now accepts an optional resolved-target predicate so memory patches can narrow a coarse root allowlist without changing skill patch behavior.
Also tightened the global memory single-file contract so child paths under
~/.gemini/GEMINI.md/are rejected.Related Issues
Fixes #26520
How to Validate
Run:
Expected results:
skill_extraction.eval.tsreports 4 passed and 1 skipped. The skipped case is gated behindRUN_SCRATCHPAD_STATS=1..extraction-state.json,.extraction.lock,.inbox/*,skills/*, non-markdown files, and nested markdown paths are omitted from listing and rejected on direct apply.MEMORY.mdand direct sibling*.mdfiles still pass.Pre-Merge Checklist