mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
Allow @-includes outside of workspaces (with permission) (#18470)
This commit is contained in:
committed by
GitHub
parent
e73288f25f
commit
262e8384d4
@@ -123,8 +123,10 @@ class GlobToolInvocation extends BaseToolInvocation<
|
||||
this.config.getTargetDir(),
|
||||
this.params.dir_path,
|
||||
);
|
||||
const validationError =
|
||||
this.config.validatePathAccess(searchDirAbsolute);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
searchDirAbsolute,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: validationError,
|
||||
@@ -318,7 +320,10 @@ export class GlobTool extends BaseDeclarativeTool<GlobToolParams, ToolResult> {
|
||||
params.dir_path || '.',
|
||||
);
|
||||
|
||||
const validationError = this.config.validatePathAccess(searchDirAbsolute);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
searchDirAbsolute,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return validationError;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
let searchDirAbs: string | null = null;
|
||||
if (pathParam) {
|
||||
searchDirAbs = path.resolve(this.config.getTargetDir(), pathParam);
|
||||
const validationError = this.config.validatePathAccess(searchDirAbs);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
searchDirAbs,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: validationError,
|
||||
@@ -623,7 +626,10 @@ export class GrepTool extends BaseDeclarativeTool<GrepToolParams, ToolResult> {
|
||||
this.config.getTargetDir(),
|
||||
params.dir_path,
|
||||
);
|
||||
const validationError = this.config.validatePathAccess(resolvedPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
resolvedPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return validationError;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,10 @@ class LSToolInvocation extends BaseToolInvocation<LSToolParams, ToolResult> {
|
||||
this.params.dir_path,
|
||||
);
|
||||
|
||||
const validationError = this.config.validatePathAccess(resolvedDirPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
resolvedDirPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: validationError,
|
||||
@@ -331,7 +334,7 @@ export class LSTool extends BaseDeclarativeTool<LSToolParams, ToolResult> {
|
||||
this.config.getTargetDir(),
|
||||
params.dir_path,
|
||||
);
|
||||
return this.config.validatePathAccess(resolvedPath);
|
||||
return this.config.validatePathAccess(resolvedPath, 'read');
|
||||
}
|
||||
|
||||
protected createInvocation(
|
||||
|
||||
@@ -76,7 +76,10 @@ class ReadFileToolInvocation extends BaseToolInvocation<
|
||||
}
|
||||
|
||||
async execute(): Promise<ToolResult> {
|
||||
const validationError = this.config.validatePathAccess(this.resolvedPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
this.resolvedPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: validationError,
|
||||
@@ -213,7 +216,10 @@ export class ReadFileTool extends BaseDeclarativeTool<
|
||||
params.file_path,
|
||||
);
|
||||
|
||||
const validationError = this.config.validatePathAccess(resolvedPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
resolvedPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return validationError;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,10 @@ ${finalExclusionPatternsForDescription
|
||||
|
||||
const fullPath = path.resolve(this.config.getTargetDir(), relativePath);
|
||||
|
||||
const validationError = this.config.validatePathAccess(fullPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
fullPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
skippedFiles.push({
|
||||
path: fullPath,
|
||||
|
||||
@@ -164,7 +164,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
const pathParam = this.params.dir_path || '.';
|
||||
|
||||
const searchDirAbs = path.resolve(this.config.getTargetDir(), pathParam);
|
||||
const validationError = this.config.validatePathAccess(searchDirAbs);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
searchDirAbs,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: validationError,
|
||||
@@ -582,7 +585,10 @@ export class RipGrepTool extends BaseDeclarativeTool<
|
||||
this.config.getTargetDir(),
|
||||
params.dir_path,
|
||||
);
|
||||
const validationError = this.config.validatePathAccess(resolvedPath);
|
||||
const validationError = this.config.validatePathAccess(
|
||||
resolvedPath,
|
||||
'read',
|
||||
);
|
||||
if (validationError) {
|
||||
return validationError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user