fix: watchdog 게이트 훅 판정을 원문 FIX 검사, 마지막 <result> 블록, 끝에 고정한 하네스 꼬리 제거로 좁힌다
보안 리뷰 지적 반영. 꼬리(<usage>·agentId)를 문자열 어디서든 지우면 본문 속 FIX 가 함께 사라질 수 있었다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d212038ce2
commit
5cd2ba750b
1 file changed
+11
-7
@@ -41,16 +41,20 @@ def verdict(text):
|
|||||||
# 판정은 결과의 마지막 비어 있지 않은 줄이 정확히 "WATCHDOG: PASS" 일 때만 인정한다 (본문 중간 인용·FIX 혼재 차단)
|
# 판정은 결과의 마지막 비어 있지 않은 줄이 정확히 "WATCHDOG: PASS" 일 때만 인정한다 (본문 중간 인용·FIX 혼재 차단)
|
||||||
# 백그라운드 알림은 <result> 뒤에 <usage>·</task-notification> 이 붙으므로 <result> 본문만 본다
|
# 백그라운드 알림은 <result> 뒤에 <usage>·</task-notification> 이 붙으므로 <result> 본문만 본다
|
||||||
text = text.replace("\\n", "\n")
|
text = text.replace("\\n", "\n")
|
||||||
m = re.search(r"<result>(.*?)</result>", text, re.S)
|
# FIX 가 원문 어디에든 있으면 통과시키지 않는다 (꼬리 제거·<result> 추출 전에 검사)
|
||||||
if m:
|
if "WATCHDOG: FIX" in text:
|
||||||
text = m.group(1)
|
return False
|
||||||
# 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄, <usage>…</usage>)가 붙는다. 꼬리만 떼고 마지막 줄 규칙은 그대로 둔다
|
# 백그라운드 알림은 마지막 <result> 블록만 본다
|
||||||
text = re.sub(r"<usage>.*?</usage>", "", text, flags=re.S)
|
blocks = re.findall(r"<result>(.*?)</result>", text, re.S)
|
||||||
lines = [l.strip() for l in text.splitlines() if l.strip() and not l.strip().startswith("agentId:")]
|
if blocks:
|
||||||
|
text = blocks[-1]
|
||||||
|
# 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄 + <usage>…</usage>)가 붙는다. 문자열 끝에 붙은 꼬리만 뗀다
|
||||||
|
text = re.sub(r"\n\s*agentId:[^\n]*\s*(<usage>.*?</usage>)?\s*$", "", text, flags=re.S)
|
||||||
|
lines = [l.strip() for l in text.splitlines() if l.strip()]
|
||||||
if not lines:
|
if not lines:
|
||||||
return False
|
return False
|
||||||
last = re.sub(r"[`*_<>/]|result", "", lines[-1]).strip()
|
last = re.sub(r"[`*_<>/]|result", "", lines[-1]).strip()
|
||||||
return last == "WATCHDOG: PASS" and "WATCHDOG: FIX" not in text
|
return last == "WATCHDOG: PASS"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in new issue
Block a user