mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
fix(core): prevent subagent bypass in plan mode (#18484)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
type SafetyCheckerRule,
|
||||
InProcessCheckerType,
|
||||
ApprovalMode,
|
||||
PRIORITY_SUBAGENT_TOOL,
|
||||
} from './types.js';
|
||||
import type { FunctionCall } from '@google/genai';
|
||||
import { SafetyCheckDecision } from '../safety/protocol.js';
|
||||
@@ -1481,6 +1482,37 @@ describe('PolicyEngine', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Plan Mode vs Subagent Priority (Regression)', () => {
|
||||
it('should DENY subagents in Plan Mode despite dynamic allow rules', async () => {
|
||||
// Plan Mode Deny (1.06) > Subagent Allow (1.05)
|
||||
|
||||
const fixedRules: PolicyRule[] = [
|
||||
{
|
||||
decision: PolicyDecision.DENY,
|
||||
priority: 1.06,
|
||||
modes: [ApprovalMode.PLAN],
|
||||
},
|
||||
{
|
||||
toolName: 'codebase_investigator',
|
||||
decision: PolicyDecision.ALLOW,
|
||||
priority: PRIORITY_SUBAGENT_TOOL,
|
||||
},
|
||||
];
|
||||
|
||||
const fixedEngine = new PolicyEngine({
|
||||
rules: fixedRules,
|
||||
approvalMode: ApprovalMode.PLAN,
|
||||
});
|
||||
|
||||
const fixedResult = await fixedEngine.check(
|
||||
{ name: 'codebase_investigator' },
|
||||
undefined,
|
||||
);
|
||||
|
||||
expect(fixedResult.decision).toBe(PolicyDecision.DENY);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shell command parsing failure', () => {
|
||||
it('should return ALLOW in YOLO mode even if shell command parsing fails', async () => {
|
||||
const { splitCommands } = await import('../utils/shell-utils.js');
|
||||
|
||||
Reference in New Issue
Block a user