mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-19 14:30:52 -07:00
feat(browser): add sensitive action controls and read-only noise reduction (#22867)
This commit is contained in:
@@ -301,4 +301,55 @@ describe('mcpToolWrapper', () => {
|
||||
expect(mockBrowserManager.callTool).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Hard Block: upload_file', () => {
|
||||
beforeEach(() => {
|
||||
mockMcpTools.push({
|
||||
name: 'upload_file',
|
||||
description: 'Upload a file',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: { path: { type: 'string' } },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should block upload_file when blockFileUploads is true', async () => {
|
||||
const tools = await createMcpDeclarativeTools(
|
||||
mockBrowserManager,
|
||||
mockMessageBus,
|
||||
false,
|
||||
true, // blockFileUploads
|
||||
);
|
||||
|
||||
const uploadTool = tools.find((t) => t.name === 'upload_file')!;
|
||||
const invocation = uploadTool.build({ path: 'test.txt' });
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
|
||||
expect(result.error).toBeDefined();
|
||||
expect(result.llmContent).toContain('File uploads are blocked');
|
||||
expect(mockBrowserManager.callTool).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT block upload_file when blockFileUploads is false', async () => {
|
||||
const tools = await createMcpDeclarativeTools(
|
||||
mockBrowserManager,
|
||||
mockMessageBus,
|
||||
false,
|
||||
false, // blockFileUploads
|
||||
);
|
||||
|
||||
const uploadTool = tools.find((t) => t.name === 'upload_file')!;
|
||||
const invocation = uploadTool.build({ path: 'test.txt' });
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.llmContent).toBe('Tool result');
|
||||
expect(mockBrowserManager.callTool).toHaveBeenCalledWith(
|
||||
'upload_file',
|
||||
expect.anything(),
|
||||
expect.anything(),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user