fix(kvb-check-gate): escape control characters in the recorded lock holder

A busy message printed the holder line of a lock file raw, so a recorded command carrying terminal escapes or newlines could forge stderr lines or move the cursor in another agent's terminal. holder() now shows every non-printable character as its escape sequence and names no holder when the recorded pid is not a number.

🎯 Fix: 95 %
💥 Break: 2 %
💸 Tokens: 100 %
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 19:25:49 +00:00
1 parent 51c04da936
commit 3632086ea0
2 files changed
+16 -1

No files matched your search

+4 -1
View File
@@ -415,7 +415,10 @@ def holder(fd: int) -> str:
pid, _, command = os.pread(fd, HOLDER_BYTES, 0).decode("utf-8", "replace").strip().partition("\t")
except OSError:
pid, command = "", ""
return f"pid {pid}: {command}" if pid and command else "holder not recorded"
if not (pid.isdecimal() and command):
return "holder not recorded"
shown = "".join(char if char.isprintable() else repr(char)[1:-1] for char in command)
return f"pid {pid}: {shown}"
def shared(sync: TextIO, repo: Path, caught: list[int]) -> None: