mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
feat(policy): allow 'modes' in user and admin policies (#15977)
This commit is contained in:
@@ -293,7 +293,6 @@ export async function loadPoliciesFromToml(
|
||||
|
||||
// Validate shell command convenience syntax
|
||||
const tomlRules = validationResult.data.rule ?? [];
|
||||
const tomlCheckers = validationResult.data.safety_checker ?? [];
|
||||
|
||||
for (let i = 0; i < tomlRules.length; i++) {
|
||||
const rule = tomlRules[i];
|
||||
@@ -310,36 +309,6 @@ export async function loadPoliciesFromToml(
|
||||
});
|
||||
// Continue to next rule, don't skip the entire file
|
||||
}
|
||||
|
||||
if (tier > 1 && rule.modes && rule.modes.length > 0) {
|
||||
errors.push({
|
||||
filePath,
|
||||
fileName: file,
|
||||
tier: tierName,
|
||||
ruleIndex: i,
|
||||
errorType: 'rule_validation',
|
||||
message: 'Restricted property "modes"',
|
||||
details: `Rule #${i + 1}: The "modes" property is currently reserved for Tier 1 (system) policies and cannot be used in ${tierName} policies.`,
|
||||
suggestion: 'Remove the "modes" property from this rule.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < tomlCheckers.length; i++) {
|
||||
const checker = tomlCheckers[i];
|
||||
if (tier > 1 && checker.modes && checker.modes.length > 0) {
|
||||
errors.push({
|
||||
filePath,
|
||||
fileName: file,
|
||||
tier: tierName,
|
||||
ruleIndex: i,
|
||||
errorType: 'rule_validation',
|
||||
message: 'Restricted property "modes" in safety checker',
|
||||
details: `Safety Checker #${i + 1}: The "modes" property is currently reserved for Tier 1 (system) policies and cannot be used in ${tierName} policies.`,
|
||||
suggestion:
|
||||
'Remove the "modes" property from this safety checker.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Transform rules
|
||||
@@ -375,7 +344,7 @@ export async function loadPoliciesFromToml(
|
||||
toolName: effectiveToolName,
|
||||
decision: rule.decision,
|
||||
priority: transformPriority(rule.priority, tier),
|
||||
modes: tier === 1 ? rule.modes : undefined,
|
||||
modes: rule.modes,
|
||||
allowRedirection: rule.allow_redirection,
|
||||
};
|
||||
|
||||
@@ -440,7 +409,7 @@ export async function loadPoliciesFromToml(
|
||||
toolName: effectiveToolName,
|
||||
priority: checker.priority,
|
||||
checker: checker.checker as SafetyCheckerConfig,
|
||||
modes: tier === 1 ? checker.modes : undefined,
|
||||
modes: checker.modes,
|
||||
};
|
||||
|
||||
if (argsPattern) {
|
||||
|
||||
Reference in New Issue
Block a user