Merge fix/kvb-check-security/file-level-fingerprint into master

🎯 Fix: 95 %
💥 Break: 2 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ✅ 90/5, cost and time <= 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-11 16:13:03 +00:00
commit 928d50f600
2 files changed
+24 -6

No files matched your search

+10 -6
View File
@@ -20,12 +20,13 @@ Scan:
Accepted:
One JSON row per reviewed false positive (id, rule, path, sha1 of the stripped
source line, reason, repo, date), appended by accept to
source line, or of the whole file for a finding without a line, reason, repo,
date), appended by accept to
<council root>/security-accepted.jsonl of the kvb-org-organize watch.py, whose
hook keeps the rows in ~/.local/state/agents-council/security-accepted.jsonl;
a scan reads both. A finding with that rule, path and line text is accepted and
leaves the score; an edit of the line brings it back. A row without rule, path
and sha1 is a usage error.
a scan reads both. A finding with that rule, path and text is accepted and
leaves the score; an edit of the line, or of the file, brings it back. A row
without rule, path and sha1 is a usage error.
Output:
`🛡️ security <n> % (medusa: <k> findings, <a> accepted in <m> files: <severity> <path>:<line>, ...)`,
@@ -116,10 +117,13 @@ def located(name: str, tree: Path) -> str:
def fingerprint(tree: Path, path: str, line: int | None) -> str | None:
try:
rows = (tree / path).read_text(encoding="utf-8", errors="replace").splitlines()
text = (tree / path).read_text(encoding="utf-8", errors="replace")
except OSError:
return None
if line is None or not 1 <= line <= len(rows):
if line is None:
return hashlib.sha1(text.encode()).hexdigest()
rows = text.splitlines()
if not 1 <= line <= len(rows):
return None
return hashlib.sha1(rows[line - 1].strip().encode()).hexdigest()