Skip to content

Commit 05358cd

Browse files
committed
- Replace --dangerously-skip-permissions with --allowedTools whitelist
(Bash pnpm/git only, Read, Write, Edit, Glob, Grep) - Switch to --model haiku (cheapest, sufficient for dependency updates) - Add --max-turns 25 to prevent runaway loops - Fix SFW_BIN: use PATH wrapper instead of alias (propagates to subprocesses) - Add post-agent diff validation (block unexpected file modifications) - Gate push/PR on validation passing - Reduce timeout-minutes from 30 to 15
1 parent 165cee8 commit 05358cd

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

.github/workflows/weekly-update.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,31 @@ jobs:
6767

6868
- name: Run updating skill with Claude Code
6969
id: claude
70-
timeout-minutes: 30
70+
timeout-minutes: 15
7171
shell: bash
7272
env:
7373
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
7474
GITHUB_ACTIONS: 'true'
7575
run: |
76-
alias pnpm="$SFW_BIN pnpm"
76+
# Wrap pnpm through Socket firewall for all subprocesses (not just this shell).
77+
if [ -n "$SFW_BIN" ]; then
78+
mkdir -p /tmp/sfw-bin
79+
printf '#!/bin/bash\nexec "%s" pnpm "$@"\n' "$SFW_BIN" > /tmp/sfw-bin/pnpm
80+
chmod +x /tmp/sfw-bin/pnpm
81+
export PATH="/tmp/sfw-bin:$PATH"
82+
fi
83+
7784
if [ -z "$ANTHROPIC_API_KEY" ]; then
7885
echo "ANTHROPIC_API_KEY not set - skipping automated update"
7986
echo "success=false" >> $GITHUB_OUTPUT
8087
exit 0
8188
fi
8289
8390
set +e
84-
claude --print --dangerously-skip-permissions \
85-
--model sonnet \
91+
claude --print \
92+
--model haiku \
93+
--max-turns 25 \
94+
--allowedTools "Bash(pnpm:*)" "Bash(git:*)" "Read" "Write" "Edit" "Glob" "Grep" \
8695
"$(cat <<'PROMPT'
8796
/updating
8897
@@ -115,6 +124,25 @@ jobs:
115124
echo "success=false" >> $GITHUB_OUTPUT
116125
fi
117126
127+
- name: Validate changes
128+
id: validate
129+
if: steps.claude.outputs.success == 'true'
130+
run: |
131+
# Only allow changes to dependency-related files.
132+
UNEXPECTED=""
133+
for file in $(git diff --name-only origin/main..HEAD); do
134+
case "$file" in
135+
package.json|*/package.json|pnpm-lock.yaml|*/pnpm-lock.yaml|.npmrc|pnpm-workspace.yaml) ;;
136+
*) UNEXPECTED="$UNEXPECTED $file" ;;
137+
esac
138+
done
139+
if [ -n "$UNEXPECTED" ]; then
140+
echo "::error::Unexpected files modified by Claude:$UNEXPECTED"
141+
echo "valid=false" >> $GITHUB_OUTPUT
142+
else
143+
echo "valid=true" >> $GITHUB_OUTPUT
144+
fi
145+
118146
- name: Check for changes
119147
id: changes
120148
run: |
@@ -125,13 +153,13 @@ jobs:
125153
fi
126154
127155
- name: Push branch
128-
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
156+
if: steps.claude.outputs.success == 'true' && steps.validate.outputs.valid == 'true' && steps.changes.outputs.has-changes == 'true'
129157
env:
130158
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
131159
run: git push origin "$BRANCH_NAME"
132160

133161
- name: Create Pull Request
134-
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
162+
if: steps.claude.outputs.success == 'true' && steps.validate.outputs.valid == 'true' && steps.changes.outputs.has-changes == 'true'
135163
env:
136164
GH_TOKEN: ${{ github.token }}
137165
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
@@ -160,7 +188,7 @@ jobs:
160188
--base main
161189
162190
- name: Add job summary
163-
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
191+
if: steps.claude.outputs.success == 'true' && steps.validate.outputs.valid == 'true' && steps.changes.outputs.has-changes == 'true'
164192
env:
165193
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
166194
run: |

0 commit comments

Comments
 (0)