Skip to content

Commit dc26839

Browse files
committed
fix: merge project permissions.allow into tag mode --allowedTools
Cherry-picked from anthropics#1173. Tag mode's hardcoded allowedTools filter blocks non-GitHub MCP tools. This reads permissions.allow from the trusted base-branch .claude/settings.json and appends them to the tag mode tool list.
1 parent c26cb64 commit dc26839

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/entrypoints/run.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,38 @@ async function run() {
254254
}
255255
}
256256

257+
// For tag mode, merge project permissions.allow into the allowed tool list.
258+
// .claude/settings.json is trusted at this point in both cases:
259+
// - PR events: restoreConfigFromBase replaced it with the base-branch version above.
260+
// - Issue events: the checkout is from the default branch (no untrusted PR code).
261+
// PR #1002 added an explicit --allowedTools list for security, which inadvertently
262+
// stopped the CLI from respecting project settings. This restores that behavior.
263+
if (modeName === "tag") {
264+
try {
265+
const settingsPath = ".claude/settings.json";
266+
if (existsSync(settingsPath)) {
267+
const settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
268+
const projectAllow: unknown = settings?.permissions?.allow;
269+
if (Array.isArray(projectAllow)) {
270+
const projectTools = projectAllow.filter(
271+
// Exclude entries that contain `"` — they would escape out of the
272+
// double-quoted --allowedTools shell argument and corrupt the args string.
273+
(t): t is string =>
274+
typeof t === "string" && t.length > 0 && !t.includes('"'),
275+
);
276+
if (projectTools.length > 0) {
277+
prepareResult.claudeArgs += ` --allowedTools "${projectTools.join(",")}"`;
278+
console.log(
279+
`Merged ${projectTools.length} project permission(s) from .claude/settings.json into tag mode tools`,
280+
);
281+
}
282+
}
283+
}
284+
} catch {
285+
// Malformed settings.json — proceed with hardcoded tool list only.
286+
}
287+
}
288+
257289
await setupClaudeCodeSettings(process.env.INPUT_SETTINGS);
258290

259291
await installPlugins(

0 commit comments

Comments
 (0)