mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-15 12:30:32 -07:00
fix(core-tools): resolve defensive path resolution for at-reference files and fix macOS tests (#28053)
Co-authored-by: David Pierce <davidapierce@google.com>
This commit is contained in:
@@ -84,7 +84,10 @@ describe('EditTool', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'edit-tool-test-'));
|
||||
const rawTempDir = fs.mkdtempSync(
|
||||
path.join(os.tmpdir(), 'edit-tool-test-'),
|
||||
);
|
||||
tempDir = fs.realpathSync(rawTempDir);
|
||||
rootDir = path.join(tempDir, 'root');
|
||||
fs.mkdirSync(rootDir);
|
||||
|
||||
@@ -701,6 +704,30 @@ function doIt() {
|
||||
};
|
||||
expect(tool.validateToolParams(params)).toBeNull();
|
||||
});
|
||||
|
||||
it('should sanitize null bytes in absolute path during validation', () => {
|
||||
const badPath = path.resolve(rootDir, 'test\0.txt');
|
||||
const params: EditToolParams = {
|
||||
file_path: badPath,
|
||||
instruction: 'An instruction',
|
||||
old_string: 'old',
|
||||
new_string: 'new',
|
||||
};
|
||||
expect(tool.validateToolParams(params)).toBeNull();
|
||||
});
|
||||
|
||||
it('should sanitize null bytes in absolute path during invocation setup', () => {
|
||||
const badPath = path.resolve(rootDir, 'test\0.txt');
|
||||
const invocation = tool.build({
|
||||
file_path: badPath,
|
||||
instruction: 'test',
|
||||
old_string: 'old',
|
||||
new_string: 'new',
|
||||
});
|
||||
expect((invocation as any).resolvedPath).toBe(
|
||||
path.resolve(rootDir, 'test.txt'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('execute', () => {
|
||||
|
||||
Reference in New Issue
Block a user