fix(core): whitelist TERM and COLORTERM in environment sanitization#20514
fix(core): whitelist TERM and COLORTERM in environment sanitization#20514sripasg merged 4 commits intogoogle-gemini:mainfrom
Conversation
Terminal editors (vim, emacs) and interactive commands (top) fail when these variables are redacted. They are safe to pass through as they only describe terminal capabilities. Fixes google-gemini#20444
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 compatibility issue where terminal-based applications and commands were not functioning as expected within the Gemini CLI environment. By explicitly allowing 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 addresses an issue with terminal-based tools by whitelisting the TERM and COLORTERM environment variables. These variables are now included in ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES to prevent them from being stripped during environment sanitization, which is necessary for the correct operation of terminal editors and other interactive commands. The change includes new unit tests that verify this behavior in both standard and strict sanitization modes. The implementation is straightforward and correctly resolves the reported issue.
|
Also, would it be possible for you to include screenshots/demo videos of how the tool handles before and after the environment sanitization fixes? |
|
Good point — since this is a sanitization-layer change, the impact is mostly visible when environment variable redaction is enabled. Before (without this fix):
After (with this fix): I can put together a quick terminal recording if that would help the review, but the two new tests in the PR (normal mode + strict/GitHub Actions mode) cover both scenarios programmatically. |
|
@M-DEV-1 Here's a side-by-side comparison showing the sanitization behavior before and after the fix. Left:
The important section is Strict mode (GitHub Actions): that's where the bug manifests. In normal redaction mode, these vars happened to pass through because they don't match any sensitive patterns, but strict mode redacts everything not explicitly whitelisted. |
Looks good! |
|
Thanks for flagging this @sripasg. I think there might be a misunderstanding though, this PR takes a different approach from #20440. We're not setting any fallback values like If the user's terminal has Happy to make changes if I'm missing something though. |
check which environment variables are allowed to pass through along with values.
sripasg
left a comment
There was a problem hiding this comment.
This looks good ! Thanks @deadsmash07
64eb0a2 to
e81a20a
Compare
…oogle-gemini#20514) Co-authored-by: Sri Pasumarthi <sripas@google.com> Co-authored-by: Sri Pasumarthi <111310667+sripasg@users.noreply.github.com>
…oogle-gemini#20514) Co-authored-by: Sri Pasumarthi <sripas@google.com> Co-authored-by: Sri Pasumarthi <111310667+sripasg@users.noreply.github.com>
…oogle-gemini#20514) Co-authored-by: Sri Pasumarthi <sripas@google.com> Co-authored-by: Sri Pasumarthi <111310667+sripasg@users.noreply.github.com>


Summary
TERMandCOLORTERMtoALWAYS_ALLOWED_ENVIRONMENT_VARIABLESin the environment sanitization servicesandbox.ts), so this aligns the sanitization behaviorDetails
Terminal-based editors fail to initialize ("Terminal type not defined") and interactive commands default to no-color mode because
TERMandCOLORTERMare stripped during environment sanitization. This change simply whitelists them so they pass through to spawned processes unchanged — no fallback values are introduced.Related Issues
Fixes #20444
How to Validate
EDITOR=vimorEDITOR=emacstopvia shell command and verify color support worksPre-Merge Checklist
npm run