security(coding-agent): sanitized artifact names and wrapped extension and MCP tools
- Sanitized artifact filenames by normalizing tool names before composing spill paths. - Applied `wrapToolWithMetaNotice` to custom tool adapters and RPC-host tools in agent-session setup. - Wrapped SDK-registered extension/custom tools with the same meta-notice adapter during session creation.
This commit is contained in:
@@ -250,7 +250,7 @@ import {
|
||||
} from "../tool-discovery/tool-index";
|
||||
import { assertEditableFile } from "../tools/auto-generated-guard";
|
||||
import type { CheckpointState } from "../tools/checkpoint";
|
||||
import { outputMeta } from "../tools/output-meta";
|
||||
import { outputMeta, wrapToolWithMetaNotice } from "../tools/output-meta";
|
||||
import { normalizeLocalScheme, resolveToCwd } from "../tools/path-utils";
|
||||
import { isAutoQaEnabled } from "../tools/report-tool-issue";
|
||||
import { getLatestTodoPhasesFromEntries, type TodoItem, type TodoPhase } from "../tools/todo";
|
||||
@@ -4611,7 +4611,7 @@ export class AgentSession {
|
||||
});
|
||||
|
||||
for (const customTool of mcpTools) {
|
||||
const wrapped = CustomToolAdapter.wrap(customTool, getCustomToolContext) as AgentTool;
|
||||
const wrapped = wrapToolWithMetaNotice(CustomToolAdapter.wrap(customTool, getCustomToolContext) as AgentTool);
|
||||
const finalTool = (
|
||||
this.#extensionRunner ? new ExtensionToolWrapper(wrapped, this.#extensionRunner) : wrapped
|
||||
) as AgentTool;
|
||||
@@ -4671,8 +4671,9 @@ export class AgentSession {
|
||||
this.#rpcHostToolNames.clear();
|
||||
|
||||
for (const tool of rpcTools) {
|
||||
const metaWrapped = wrapToolWithMetaNotice(tool);
|
||||
const finalTool = (
|
||||
this.#extensionRunner ? new ExtensionToolWrapper(tool, this.#extensionRunner) : tool
|
||||
this.#extensionRunner ? new ExtensionToolWrapper(metaWrapped, this.#extensionRunner) : metaWrapped
|
||||
) as AgentTool;
|
||||
this.#toolRegistry.set(finalTool.name, finalTool);
|
||||
this.#rpcHostToolNames.add(finalTool.name);
|
||||
|
||||
Reference in New Issue
Block a user