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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user