feat: allow user override of hardcoded disallowed tools (#71)

* feat: allow user override of hardcoded disallowed tools

Allow users to override hardcoded disallowed tools (WebSearch, WebFetch) by including them in their allowed_tools configuration. This provides users with the ability to control tool access based on their security requirements.

Changes:
- Modified buildDisallowedToolsString() to accept allowedTools parameter
- Added logic to filter out hardcoded disallowed tools if present in allowed tools
- Updated function call site to pass allowedTools
- Added comprehensive test coverage for override behavior
- Maintains backward compatibility

Resolves #49

Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>

* prettier

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>
This commit is contained in:
Ashwin Bhat
2025-05-29 09:40:32 -07:00
committed by GitHub
parent 9c9859aff1
commit 37c3c29341
2 changed files with 67 additions and 2 deletions

View File

@@ -58,10 +58,27 @@ export function buildAllowedToolsString(
export function buildDisallowedToolsString(
customDisallowedTools?: string,
allowedTools?: string,
): string {
let allDisallowedTools = DISALLOWED_TOOLS.join(",");
let disallowedTools = [...DISALLOWED_TOOLS];
// If user has explicitly allowed some hardcoded disallowed tools, remove them from disallowed list
if (allowedTools) {
const allowedToolsArray = allowedTools
.split(",")
.map((tool) => tool.trim());
disallowedTools = disallowedTools.filter(
(tool) => !allowedToolsArray.includes(tool),
);
}
let allDisallowedTools = disallowedTools.join(",");
if (customDisallowedTools) {
allDisallowedTools = `${allDisallowedTools},${customDisallowedTools}`;
if (allDisallowedTools) {
allDisallowedTools = `${allDisallowedTools},${customDisallowedTools}`;
} else {
allDisallowedTools = customDisallowedTools;
}
}
return allDisallowedTools;
}
@@ -648,6 +665,7 @@ export async function createPrompt(
);
const allDisallowedTools = buildDisallowedToolsString(
preparedContext.disallowedTools,
preparedContext.allowedTools,
);
core.exportVariable("ALLOWED_TOOLS", allAllowedTools);