mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
feat(policy): explicitly allow web_fetch in plan mode with ask_user (#24456)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -123,6 +123,7 @@ These are the only allowed tools:
|
|||||||
[`glob`](../tools/file-system.md#4-glob-findfiles)
|
[`glob`](../tools/file-system.md#4-glob-findfiles)
|
||||||
- **Search:** [`grep_search`](../tools/file-system.md#5-grep_search-searchtext),
|
- **Search:** [`grep_search`](../tools/file-system.md#5-grep_search-searchtext),
|
||||||
[`google_web_search`](../tools/web-search.md),
|
[`google_web_search`](../tools/web-search.md),
|
||||||
|
[`web_fetch`](../tools/web-fetch.md) (requires explicit confirmation),
|
||||||
[`get_internal_docs`](../tools/internal-docs.md)
|
[`get_internal_docs`](../tools/internal-docs.md)
|
||||||
- **Research Subagents:**
|
- **Research Subagents:**
|
||||||
[`codebase_investigator`](../core/subagents.md#codebase-investigator),
|
[`codebase_investigator`](../core/subagents.md#codebase-investigator),
|
||||||
|
|||||||
@@ -115,10 +115,10 @@ each tool.
|
|||||||
|
|
||||||
### Web
|
### Web
|
||||||
|
|
||||||
| Tool | Kind | Description |
|
| Tool | Kind | Description |
|
||||||
| :-------------------------------------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :-------------------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [`google_web_search`](../tools/web-search.md) | `Search` | Performs a Google Search to find up-to-date information. |
|
| [`google_web_search`](../tools/web-search.md) | `Search` | Performs a Google Search to find up-to-date information. |
|
||||||
| [`web_fetch`](../tools/web-fetch.md) | `Fetch` | Retrieves and processes content from specific URLs. **Warning:** This tool can access local and private network addresses (e.g., localhost), which may pose a security risk if used with untrusted prompts. |
|
| [`web_fetch`](../tools/web-fetch.md) | `Fetch` | Retrieves and processes content from specific URLs. **Warning:** This tool can access local and private network addresses (e.g., localhost), which may pose a security risk if used with untrusted prompts. In Plan Mode, this tool requires explicit user confirmation. |
|
||||||
|
|
||||||
## Under the hood
|
## Under the hood
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ specific operations like summarization or extraction.
|
|||||||
## Technical behavior
|
## Technical behavior
|
||||||
|
|
||||||
- **Confirmation:** Triggers a confirmation dialog showing the converted URLs.
|
- **Confirmation:** Triggers a confirmation dialog showing the converted URLs.
|
||||||
|
- **Plan Mode:** In [Plan Mode](../cli/plan-mode.md), `web_fetch` is available
|
||||||
|
but always requires explicit user confirmation (`ask_user`) due to security
|
||||||
|
implications of accessing external or private network addresses.
|
||||||
- **Processing:** Uses the Gemini API's `urlContext` for retrieval.
|
- **Processing:** Uses the Gemini API's `urlContext` for retrieval.
|
||||||
- **Fallback:** If API access fails, the tool attempts to fetch raw content
|
- **Fallback:** If API access fails, the tool attempts to fetch raw content
|
||||||
directly from your local machine.
|
directly from your local machine.
|
||||||
|
|||||||
@@ -121,14 +121,14 @@ priority = 70
|
|||||||
modes = ["plan"]
|
modes = ["plan"]
|
||||||
|
|
||||||
[[rule]]
|
[[rule]]
|
||||||
toolName = ["ask_user", "save_memory"]
|
toolName = ["ask_user", "save_memory", "web_fetch"]
|
||||||
decision = "ask_user"
|
decision = "ask_user"
|
||||||
priority = 70
|
priority = 70
|
||||||
modes = ["plan"]
|
modes = ["plan"]
|
||||||
interactive = true
|
interactive = true
|
||||||
|
|
||||||
[[rule]]
|
[[rule]]
|
||||||
toolName = ["ask_user", "save_memory"]
|
toolName = ["ask_user", "save_memory", "web_fetch"]
|
||||||
decision = "deny"
|
decision = "deny"
|
||||||
priority = 70
|
priority = 70
|
||||||
modes = ["plan"]
|
modes = ["plan"]
|
||||||
|
|||||||
@@ -2929,6 +2929,12 @@ describe('PolicyEngine', () => {
|
|||||||
priority: 70,
|
priority: 70,
|
||||||
modes: [ApprovalMode.PLAN],
|
modes: [ApprovalMode.PLAN],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
toolName: 'web_fetch',
|
||||||
|
decision: PolicyDecision.ASK_USER,
|
||||||
|
priority: 70,
|
||||||
|
modes: [ApprovalMode.PLAN],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
toolName: '*',
|
toolName: '*',
|
||||||
decision: PolicyDecision.DENY,
|
decision: PolicyDecision.DENY,
|
||||||
@@ -2972,7 +2978,6 @@ describe('PolicyEngine', () => {
|
|||||||
const excluded = engine.getExcludedTools(toolMetadata, allToolNames);
|
const excluded = engine.getExcludedTools(toolMetadata, allToolNames);
|
||||||
// These should be excluded (caught by catch-all DENY)
|
// These should be excluded (caught by catch-all DENY)
|
||||||
expect(excluded.has('shell')).toBe(true);
|
expect(excluded.has('shell')).toBe(true);
|
||||||
expect(excluded.has('web_fetch')).toBe(true);
|
|
||||||
expect(excluded.has('write_todos')).toBe(true);
|
expect(excluded.has('write_todos')).toBe(true);
|
||||||
expect(excluded.has('memory')).toBe(true);
|
expect(excluded.has('memory')).toBe(true);
|
||||||
// write_file and replace are excluded unless they have argsPattern rules
|
// write_file and replace are excluded unless they have argsPattern rules
|
||||||
@@ -2988,6 +2993,7 @@ describe('PolicyEngine', () => {
|
|||||||
expect(excluded.has('list_directory')).toBe(false);
|
expect(excluded.has('list_directory')).toBe(false);
|
||||||
expect(excluded.has('google_web_search')).toBe(false);
|
expect(excluded.has('google_web_search')).toBe(false);
|
||||||
expect(excluded.has('activate_skill')).toBe(false);
|
expect(excluded.has('activate_skill')).toBe(false);
|
||||||
|
expect(excluded.has('web_fetch')).toBe(false);
|
||||||
expect(excluded.has('ask_user')).toBe(false);
|
expect(excluded.has('ask_user')).toBe(false);
|
||||||
expect(excluded.has('exit_plan_mode')).toBe(false);
|
expect(excluded.has('exit_plan_mode')).toBe(false);
|
||||||
expect(excluded.has('save_memory')).toBe(false);
|
expect(excluded.has('save_memory')).toBe(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user