From 5cd2ba750b2c0f2dbd8f22ef26e1208d1c2e699a Mon Sep 17 00:00:00 2001 From: Haewon Kam Date: Tue, 3 Nov 2026 14:24:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20watchdog=20=EA=B2=8C=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=20=ED=9B=85=20=ED=8C=90=EC=A0=95=EC=9D=84=20=EC=9B=90=EB=AC=B8?= =?UTF-8?q?=20FIX=20=EA=B2=80=EC=82=AC,=20=EB=A7=88=EC=A7=80=EB=A7=89=20=20=EB=B8=94=EB=A1=9D,=20=EB=81=9D=EC=97=90=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95=ED=95=9C=20=ED=95=98=EB=84=A4=EC=8A=A4=20=EA=BC=AC?= =?UTF-8?q?=EB=A6=AC=20=EC=A0=9C=EA=B1=B0=EB=A1=9C=20=EC=A2=81=ED=9E=8C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 보안 리뷰 지적 반영. 꼬리(·agentId)를 문자열 어디서든 지우면 본문 속 FIX 가 함께 사라질 수 있었다. Co-Authored-By: Claude Opus 5.5 --- .claude/hooks/watchdog_gate.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.claude/hooks/watchdog_gate.py b/.claude/hooks/watchdog_gate.py index 61e5c1f..3c3c3d5 100644 --- a/.claude/hooks/watchdog_gate.py +++ b/.claude/hooks/watchdog_gate.py @@ -41,16 +41,20 @@ def verdict(text): # 판정은 결과의 마지막 비어 있지 않은 줄이 정확히 "WATCHDOG: PASS" 일 때만 인정한다 (본문 중간 인용·FIX 혼재 차단) # 백그라운드 알림은 뒤에 · 이 붙으므로 본문만 본다 text = text.replace("\\n", "\n") - m = re.search(r"(.*?)", text, re.S) - if m: - text = m.group(1) - # 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄, …)가 붙는다. 꼬리만 떼고 마지막 줄 규칙은 그대로 둔다 - text = re.sub(r".*?", "", text, flags=re.S) - lines = [l.strip() for l in text.splitlines() if l.strip() and not l.strip().startswith("agentId:")] + # FIX 가 원문 어디에든 있으면 통과시키지 않는다 (꼬리 제거· 추출 전에 검사) + if "WATCHDOG: FIX" in text: + return False + # 백그라운드 알림은 마지막 블록만 본다 + blocks = re.findall(r"(.*?)", text, re.S) + if blocks: + text = blocks[-1] + # 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄 + …)가 붙는다. 문자열 끝에 붙은 꼬리만 뗀다 + text = re.sub(r"\n\s*agentId:[^\n]*\s*(.*?)?\s*$", "", text, flags=re.S) + lines = [l.strip() for l in text.splitlines() if l.strip()] if not lines: return False last = re.sub(r"[`*_<>/]|result", "", lines[-1]).strip() - return last == "WATCHDOG: PASS" and "WATCHDOG: FIX" not in text + return last == "WATCHDOG: PASS" def main():