diff --git a/hooks/leo21c-write-guard.sh b/hooks/leo21c-write-guard.sh index 8d74d53..55a7f97 100755 --- a/hooks/leo21c-write-guard.sh +++ b/hooks/leo21c-write-guard.sh @@ -46,16 +46,34 @@ if printf '%s' "$cmd" | grep -q 'leo21c-write-guard'; then exit 0 fi -# leo21c 的三個座標(帳號 id/namespace/worker 網域) -if ! printf '%s' "$cmd" | grep -qE 'leo21c|51a01bfa2665bd7bc3fd080dc40cf3e1|bfezv28v'; then - exit 0 +# ── 判準:這個指令會不會真的把東西寫到那台?──────────────────────────────── +# 🔴 2026-08-20 第三次誤攔後收斂(前兩次:git commit 訊息、修閘自己)。 +# 舊判準是「文字裡有沒有出現座標」+「有沒有寫入動詞」,於是 +# `curl -X PATCH .../api/v1/repos/inkstone/Arcrun/issues/145 -d '{"state":"closed"}'` +# **只因為票的內文提到那個帳號就被擋**——而那是打 Gitea,跟 CF 一點關係都沒有。 +# ⇒ 只認**兩種真的會寫到那台的形狀**,其餘一律不管文字寫了什麼: +# ① 寫入請求打到 `*.leo21c.workers.dev` +# ② 用它的 CF 帳號 id 去跑 wrangler/acr +# leo 2026-08-17:「紅線寫得越細,命中關鍵字的機率越高 ⇒ 那些閘在懲罰謹慎。」 + +hit=0 + +# ① 寫入請求打到那台 worker +if printf '%s' "$cmd" | grep -qiE 'https?://[^[:space:]"'"'"']*leo21c\.workers\.dev'; then + if printf '%s' "$cmd" | grep -qE -- '-X *(POST|PUT|PATCH|DELETE)|--data|--data-raw|-d[[:space:]]|/trigger'; then + hit=1 + fi fi -# 寫入動作的形狀 -if ! printf '%s' "$cmd" | grep -qE -- '-X *(POST|PUT|PATCH|DELETE)|--data|--data-raw|-d ["'"'"'{]|wrangler +(deploy|publish|kv|d1|secret)|acr +(update|deploy|push)|/trigger|ingest|kbdb_create|kbdb_update'; then - exit 0 +# ② 拿它的 CF 帳號去部署 +if printf '%s' "$cmd" | grep -qE 'CLOUDFLARE_ACCOUNT_ID=51a01bfa2665bd7bc3fd080dc40cf3e1'; then + if printf '%s' "$cmd" | grep -qE 'wrangler|acr |node .*index\.js'; then + hit=1 + fi fi +[ "$hit" = "1" ] || exit 0 + cat >&2 <<'MSG' 🚫 不准寫 leo 的個人帳號 leo21c(leo 2026-08-20 立)