fix(data-exfil-warning): 補上 pre-bash hook 偵測(前一 commit Edit 失敗漏掉)

前一 commit message 提及 hook 但實際因 Edit old_string 不匹配未寫入。本 commit 補上:
- pre-bash-guard 偵測 acr push / acr recipe push 無 --confirm-exposure/--suppress-warning → exit 2
- 精準排除 acr creds push(上傳加密 cred 是保護非暴露)、acr run/list 不誤擋
- 驗證:push/recipe push 無旗標=2、帶旗標=0、creds push/run/list=0

e2e(wrangler dev --local)三態全綠:webhook 無consent→403 / 帶consent→201 /
同wf再部署→201(首次問記住);recipe push 無consent→403 + 保護入口訊息。
tasks V3/V4/V6 標記。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 15:08:07 +08:00
parent 5165884b40
commit f9071d153b
2 changed files with 26 additions and 3 deletions
+23
View File
@@ -78,4 +78,27 @@ if echo "$CMD" | grep -qE "git[[:space:]]+push.*--force.*(main|master)"; then
"用 feature branch,或和 richblack 確認後手動操作"
fi
# ─────────────────────────────────────────────────────────────────────────────
# 資料外流警示(data-exfil-warning SDD R2):AI 動手把資料變成可被外部呼叫前先擋
# `acr push`(部署 webhook/ `acr recipe push`(定義資料去向)= 暴露面動作。
# 不含 `acr creds push`(上傳加密 credential 是保護,非暴露)。
# 已帶 --confirm-exposure / --suppress-warning(人類已明示)→ 放行。
# ─────────────────────────────────────────────────────────────────────────────
if echo "$CMD" | grep -qE "\bacr[[:space:]]+(recipe[[:space:]]+)?push\b" \
&& ! echo "$CMD" | grep -qE "\bacr[[:space:]]+creds[[:space:]]+push\b"; then
if ! echo "$CMD" | grep -qE "\-\-(confirm-exposure|suppress-warning)"; then
cat >&2 <<'EOF'
❌ BLOCKED:資料外流警示(arcrun data-exfil-warning
原因:acr push / acr recipe push 會把資料/workflow 變成「可被外部呼叫」(暴露面)。
這種動作不該由 AI 自行執行——需人類明示知情同意(法律憑證)。
正確做法:
- 由人類在終端機親自執行(會跳互動警示、要你輸入資源名確認、並提供保護選項)
- 或人類確認後加 --confirm-exposure(你已知悉暴露風險)
- 確定要公開且不再提醒:--suppress-warning
參考:.agents/specs/data-exfil-warning/
EOF
exit 2
fi
fi
exit 0