mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 04:54:25 -07:00
feat(core,cli): implement session-linked tool output storage and cleanup (#18416)
This commit is contained in:
@@ -1121,7 +1121,7 @@ describe('fileUtils', () => {
|
||||
|
||||
const expectedOutputFile = path.join(
|
||||
tempRootDir,
|
||||
'tool_output',
|
||||
'tool-outputs',
|
||||
'shell_123.txt',
|
||||
);
|
||||
expect(result.outputFile).toBe(expectedOutputFile);
|
||||
@@ -1149,7 +1149,7 @@ describe('fileUtils', () => {
|
||||
// ../../dangerous/tool -> ______dangerous_tool
|
||||
const expectedOutputFile = path.join(
|
||||
tempRootDir,
|
||||
'tool_output',
|
||||
'tool-outputs',
|
||||
'______dangerous_tool_1.txt',
|
||||
);
|
||||
expect(result.outputFile).toBe(expectedOutputFile);
|
||||
@@ -1170,12 +1170,36 @@ describe('fileUtils', () => {
|
||||
// ../../etc/passwd -> ______etc_passwd
|
||||
const expectedOutputFile = path.join(
|
||||
tempRootDir,
|
||||
'tool_output',
|
||||
'tool-outputs',
|
||||
'shell_______etc_passwd.txt',
|
||||
);
|
||||
expect(result.outputFile).toBe(expectedOutputFile);
|
||||
});
|
||||
|
||||
it('should sanitize sessionId in filename/path', async () => {
|
||||
const content = 'content';
|
||||
const toolName = 'shell';
|
||||
const id = '1';
|
||||
const sessionId = '../../etc/passwd';
|
||||
|
||||
const result = await saveTruncatedToolOutput(
|
||||
content,
|
||||
toolName,
|
||||
id,
|
||||
tempRootDir,
|
||||
sessionId,
|
||||
);
|
||||
|
||||
// ../../etc/passwd -> ______etc_passwd
|
||||
const expectedOutputFile = path.join(
|
||||
tempRootDir,
|
||||
'tool-outputs',
|
||||
'session-______etc_passwd',
|
||||
'shell_1.txt',
|
||||
);
|
||||
expect(result.outputFile).toBe(expectedOutputFile);
|
||||
});
|
||||
|
||||
it('should format multi-line output correctly', () => {
|
||||
const lines = Array.from({ length: 50 }, (_, i) => `line ${i}`);
|
||||
const content = lines.join('\n');
|
||||
|
||||
Reference in New Issue
Block a user