mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-21 09:13:05 -07:00
fix(core): restore strict sanitization config and allow list precedence
This commit is contained in:
@@ -370,7 +370,7 @@ describe('getSecureSanitizationConfig', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should not filter out variables from allowed list that match NEVER_ALLOWED_NAME_PATTERNS', () => {
|
||||
it('should filter out variables from allowed list that match NEVER_ALLOWED_NAME_PATTERNS', () => {
|
||||
const requestedConfig = {
|
||||
allowedEnvironmentVariables: ['SAFE_VAR', 'MY_SECRET_TOKEN'],
|
||||
};
|
||||
@@ -378,7 +378,7 @@ describe('getSecureSanitizationConfig', () => {
|
||||
const config = getSecureSanitizationConfig(requestedConfig);
|
||||
|
||||
expect(config.allowedEnvironmentVariables).toContain('SAFE_VAR');
|
||||
expect(config.allowedEnvironmentVariables).toContain('MY_SECRET_TOKEN');
|
||||
expect(config.allowedEnvironmentVariables).not.toContain('MY_SECRET_TOKEN');
|
||||
});
|
||||
|
||||
it('should deduplicate variables in allowed and blocked lists', () => {
|
||||
|
||||
@@ -213,6 +213,12 @@ export function getSecureSanitizationConfig(
|
||||
if (NEVER_ALLOWED_ENVIRONMENT_VARIABLES.has(upperKey)) {
|
||||
return false;
|
||||
}
|
||||
// Never allow variables that match sensitive name patterns
|
||||
for (const pattern of NEVER_ALLOWED_NAME_PATTERNS) {
|
||||
if (pattern.test(upperKey)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user