-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: merge project permissions.allow into tag mode --allowedTools #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,34 @@ async function run() { | |
| } | ||
| if (restoreBase) { | ||
| restoreConfigFromBase(restoreBase); | ||
|
|
||
| // After restore, .claude/settings.json is the trusted base-branch version. | ||
| // For tag mode, merge its permissions.allow entries into claudeArgs so that | ||
| // project-approved tools (e.g. Bash(pnpm test:*)) are not silently denied. | ||
| // PR #1002 hardened tag mode with an explicit --allowedTools allowlist, which | ||
| // inadvertently stopped respecting project settings entirely. | ||
| if (modeName === "tag") { | ||
| try { | ||
| const settingsPath = ".claude/settings.json"; | ||
| if (existsSync(settingsPath)) { | ||
| const settings = JSON.parse(readFileSync(settingsPath, "utf-8")); | ||
| const projectAllow: unknown = settings?.permissions?.allow; | ||
| if (Array.isArray(projectAllow) && projectAllow.length > 0) { | ||
| const projectTools = projectAllow.filter( | ||
| (t): t is string => typeof t === "string" && t.length > 0, | ||
| ); | ||
| if (projectTools.length > 0) { | ||
| prepareResult.claudeArgs += ` --allowedTools "${projectTools.join(",")}"`; | ||
|
||
| console.log( | ||
| `Merged ${projectTools.length} project permission(s) from .claude/settings.json into tag mode tools`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } catch { | ||
| // Malformed settings.json — proceed with hardcoded tool list only. | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only runs when
restoreBaseis set (PR-triggered tag mode). Issue-triggered tag mode also has the #1002 hardening but no restore, so projectpermissions.allowstays ignored there. The settings file is equally trusted in that case (default branch checkout). Suggest moving this block to just after theif (restoreBase) { ... }closes, still gated onmodeName === "tag".