gemini-cli
gemini-cli copied to clipboard
fix(folder trust): add validation for trusted folder level
Summary
This PR introduces validation for the trustLevel values in the trusted-folders.json configuration file. It ensures that only recognized trust levels are processed, preventing potential errors from invalid or misspelled entries.
Details
Previously GC started up with any string as a trustLevel without validation. This could lead to overriding the settings or ignoring them all together.
This change adds a type guard (isTrustLevel) to validate each entry when loading the trusted folders configuration.
Related Issues
Fixes 921
How to Validate
Add to the following to settings.json
security: {
folderTrust: {
enabled: true,
},
},
Add to .gemini/trustedFolders.json
{
"<cwd>": "DO_NOT_TRUSTtest"
}
On main this will not cause an error, on this new branch it will prevent correctly prevent startup.
Pre-Merge Checklist
- [x] Added/updated tests (if needed)
- [ ] Validated on required platforms/methods:
- [ ] MacOS
- [x] npm run
- [ ] npx
- [ ] Docker
- [ ] Podman
- [ ] Seatbelt
- [ ] Windows
- [ ] npm run
- [ ] npx
- [ ] Docker
- [ ] Linux
- [ ] npm run
- [ ] npx
- [ ] Docker
- [ ] MacOS