Repository navigation
fix(extensions): preserve symlinks in extension source path while enforcing folder trust - #20867
Conversation
…orcing folder trust
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 addresses a bug where the CLI's extension installation process would resolve symlinks to their physical disk locations, leading to unstable extension metadata. The changes ensure that symlinks are preserved in the extension's stored source path, while simultaneously maintaining robust security by performing folder trust checks against the real path. Additionally, it improves the reliability of local extension copying by using the real path for the source during the copy operation. 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
|
|
Size Change: +150 B (0%) Total Size: 26 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug with symlink handling during extension installation. However, this change introduces security risks. Specifically, the allowedExtensions security policy can now be bypassed using symlinks (high severity). Additionally, the extension loader fails to re-verify the trust of the target directory when following a symlink during load. While this could allow the execution of untrusted code, it is considered low-risk as it requires an attacker to have write access to the user's extension directory.
cfd40ae to
a80f16c
Compare
|
The core logic looks solid and correctly addresses the metadata path stability issue without compromising security checks (the However, I noticed one small cross-platform issue in the new test that needs a quick fix:
fs.symlinkSync(extensionDir, symlinkDir);On Windows, Node.js defaults the symlink type to Could you update this to explicitly pass fs.symlinkSync(extensionDir, symlinkDir, 'dir'); |
On Windows, Node.js defaults fs.symlinkSync type to 'file'. Explicitly passing 'dir' ensures that directory symlinks are created correctly, fixing potential test failures for Windows developers.
Done |
…orcing folder trust (google-gemini#20867)
…orcing folder trust (google-gemini#20867)
…orcing folder trust (google-gemini#20867)
…orcing folder trust (google-gemini#20867)
…orcing folder trust (google-gemini#20867)
…orcing folder trust (google-gemini#20867)
…orcing folder trust (#20867)
…orcing folder trust (google-gemini#20867)
Summary
This PR fixes a bug where extension installation and linking resolved symlinks to their real disk locations. This was breaking the use of stable symlinks by replacing them with ephemeral real paths in the extension metadata.
Details
install.tsandextension-manager.tsto usepath.resolve()for theinstallMetadata.sourceinstead ofgetRealPath(). This ensures symlinks are preserved in the extension's configuration.trustedFolders.jsonstill utilize the real path. This ensures that spoofing protection is maintained (swapping a symlink to a new location will still trigger a trust prompt).ExtensionManagerto use the real path forlocalSourcePathduring the copy phase of local installations, preventingENOTDIRerrors when copying from a symlink.Related Issues
Fixes the issue reported regarding symlink resolution.
How to Validate
npm test -w @google/gemini-cli -- src/config/extension-manager-symlink.test.tsPre-Merge Checklist