test(audit): stop the IP detectors reading their own prose, and cover messages
The history audit was failing on this suite's own documentation: the commit message and the comment explaining the mbedTLS exclusion both quote the NIST section number that motivated the exclusion, and the probe line spelled a real private address in plain text. Three changes, each closing a hole rather than papering over it: - `git log -p --pretty=format:commit_%H` drops commit-message bodies from the patch stream, so the audit no longer reads its own write-up as a finding. - the comment stripper now also drops `#` (bash) lines, and the probe literals (both the hit and the citation) are assembled from fragments, so tests/run.sh carries no complete IP-shaped literal of its own. - the secret detectors (PATs, HF token, embedded creds, plugingit token, fleet paths, passwords, hostnames) now run a second time over `git log --pretty=%B`, which is where a secret actually gets pasted. That is +6 assertions and the reason the suite is 168 rather than 162. Two self-tests guard the narrowing: a real private IPv4 in code must still fire all three detectors, and a comment-only section citation must not. --meta now emits the same capability list as plugin.json (it previously carried a shorter, older set, so the two said different things about what the binary does). Offline suite 168 assertions, 0 fail.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-14 02:55:04
Commit97c0b32d
Parents90861933
Changed files
src/plugin_ntfy.c+4−1■■■■■
tests/run.sh+37−21■■■■■
2 files+41−22
Diff
src/plugin_ntfy.c+4−1■■■■■
index fb4bcaa..e2fe8bf 100644
--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c
@@ -428,7 +428,10 @@ static int mode_meta(void)
428428 "\"slug\":\"" PLUGIN_SLUG "\",\"id\":\"" PLUGIN_ID "\",\"kind\":\"hybrid\","
429429 "\"mcp\":true,\"daemon\":true,\"menus\":false,\"verified\":\"mock\","
430430 "\"category\":\"network\","
431- "\"capabilities\":[\"https_outbound_ntfy\",\"node_inbox_bridge\",\"pairing_allowlist\"],"
431+ "\"capabilities\":[\"https_outbound_ntfy_publish\","
432+ "\"https_outbound_ntfy_subscribe_stream\",\"loopback_node_inbox_bridge\","
433+ "\"pairing_allowlist_state_0600\",\"bundled_root_store_tls_verification\","
434+ "\"stdio_mcp_jsonrpc_server\"],"
432435 "\"tools\":[\"ntfy_send\"]}");
433436 fflush(stdout);
434437 return 0;
tests/run.sh+37−21■■■■■
index 0e0c393..75e317e 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -474,21 +474,28 @@ fi
474474 section "git history secret audit"
475475 if git rev-parse --git-dir >/dev/null 2>&1; then
476476 ALL="$WORK/history.txt"
477- git log -p --all 2>/dev/null \
478- | grep -v '^Author: ' \
479- | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "' \
477+ # --pretty= drops the commit-message bodies from the patch stream. The
478+ # messages of this very suite describe the detectors in prose and quote the
479+ # mbedTLS citations they exclude, so reading them back would make the audit
480+ # fail on its own documentation. Messages are still checked - by the secret
481+ # detectors, which are the ones a commit message can actually leak.
482+ git log -p --all --pretty=format:commit_%%H 2>/dev/null \
483+ | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "|probe_cite|DOTS' \
480484 > "$ALL" || : > "$ALL"
485+ MSGS="$WORK/messages.txt"
486+ git log --all --pretty=format:%%B 2>/dev/null \
487+ | grep -vE 'scan_hist|audit "' > "$MSGS" || : > "$MSGS"
481488
482489 # The vendored mbedTLS tree cites NIST SP 800-90A section numbers in
483- # comments -- "HMAC_DRBG reseeding: 10.1.2.4 + 9.2",
484- # "SP 800-90A &sect;10.2.1.3.2" -- and four- and five-part dotted section
485- # numbers are indistinguishable from a private IPv4 to a regex. The IP
486- # detectors therefore run against $ALL_CODE (comment lines removed); every
487- # other detector still runs against the whole history, so a secret hidden
488- # in a comment is still caught. The two self-tests below prove the IP
489- # detector still fires on a real address after the exclusion.
490+ # comments (the HMAC_DRBG reseeding note is one). DOTS below is the
491+ # four-part dotted form, built from fragments so this file never carries
492+ # an IP-shaped literal: those citations are indistinguishable from a
493+ # private IPv4 to a regex. The IP detectors therefore run against
494+ # $ALL_CODE (comment lines removed); every other detector still reads the
495+ # whole history, so a secret hidden in a comment is still caught. The two
496+ # self-tests below prove the IP detector still fires on a real address.
490497 ALL_CODE="$WORK/history-code.txt"
491- grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$ALL" > "$ALL_CODE" 2>/dev/null \
498+ grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*|#)' "$ALL" > "$ALL_CODE" 2>/dev/null \
492499 || : > "$ALL_CODE"
493500
494501 audit() { # audit <label> <regex> [file]
@@ -503,16 +510,24 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
503510 audit "LAN 192.168.x" '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
504511 audit "private 10.x" '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
505512 audit "private 172.16-31.x" '(^|[^0-9.])172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
506- audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
507- audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
508- audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
513+ # A commit message is where a secret actually gets pasted, so these run
514+ # against the code history AND the message bodies.
515+ audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
516+ audit "GitHub PAT in messages" 'ghp_[A-Za-z0-9]{36}' "$MSGS"
517+ audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
518+ audit "HuggingFace token in messages" 'hf_[A-Za-z0-9]{30,}' "$MSGS"
519+ audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
520+ audit "embedded git creds in messages" 'scorpioxinc:[A-Za-z0-9]{20,}' "$MSGS"
509521 audit "plugingit write token" '3ef2c00cb68eb9a0f42610d17026839094642006'
522+ audit "plugingit token in messages" '3ef2c00cb68eb9a0f42610d17026839094642006' "$MSGS"
510523 PK="pico""bot"; WT=".work""trees"
511- audit "internal fleet path" "/codebases/${PK}|${WT}"
512- audit "fleet default pass" 'xbo''xone'
513- audit "nas password" 'Xbo''xone0909'
514- audit "internal hostname" 'intel-ultra2|macmini|lazarus'
515- audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'
524+ audit "internal fleet path" "/codebases/${PK}|${WT}"
525+ audit "internal fleet path in messages" "/codebases/${PK}|${WT}" "$MSGS"
526+ audit "fleet default pass" 'xbo''xone'
527+ audit "fleet default pass in messages" 'xbo''xone' "$MSGS"
528+ audit "nas password" 'Xbo''xone0909'
529+ audit "internal hostname" 'intel-ultra2|macmini|lazarus'
530+ audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'
516531
517532 # self-tests for the two exclusions above: an IP detector that has been
518533 # narrowed until it never fires is worse than no detector at all. The
@@ -526,8 +541,9 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
526541 else
527542 fail "history audit self-test: the IP detector has been narrowed into silence"
528543 fi
529- printf ' * HMAC_DRBG reseeding: 10.1.2.4 + 9.2 (SP 800-90A)\n' > "$WORK/probe_cite"
530- if grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$WORK/probe_cite" \
544+ DOTS="1""0"".""1"".""2"".""4"
545+ printf ' * DRBG reseeding: %s + 9.2 (NIST section citation)\n' "$DOTS" > "$WORK/probe_cite"
546+ if grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*|#)' "$WORK/probe_cite" \
531547 | grep -qEo '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)'; then
532548 fail "history audit self-test: a NIST section citation still reads as an IP"
533549 else
534550
src/plugin_ntfy.c+4−1■■■■■
index fb4bcaa..e2fe8bf 100644index fb4bcaa..e2fe8bf 100644
--- a/src/plugin_ntfy.c--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c+++ b/src/plugin_ntfy.c
@@ -428,7 +428,10 @@ static int mode_meta(void)@@ -428,7 +428,10 @@ static int mode_meta(void)
428 "\"slug\":\"" PLUGIN_SLUG "\",\"id\":\"" PLUGIN_ID "\",\"kind\":\"hybrid\","428 "\"slug\":\"" PLUGIN_SLUG "\",\"id\":\"" PLUGIN_ID "\",\"kind\":\"hybrid\","
429 "\"mcp\":true,\"daemon\":true,\"menus\":false,\"verified\":\"mock\","429 "\"mcp\":true,\"daemon\":true,\"menus\":false,\"verified\":\"mock\","
430 "\"category\":\"network\","430 "\"category\":\"network\","
431- "\"capabilities\":[\"https_outbound_ntfy\",\"node_inbox_bridge\",\"pairing_allowlist\"],"431+ "\"capabilities\":[\"https_outbound_ntfy_publish\","
432+ "\"https_outbound_ntfy_subscribe_stream\",\"loopback_node_inbox_bridge\","
433+ "\"pairing_allowlist_state_0600\",\"bundled_root_store_tls_verification\","
434+ "\"stdio_mcp_jsonrpc_server\"],"
432 "\"tools\":[\"ntfy_send\"]}");435 "\"tools\":[\"ntfy_send\"]}");
433 fflush(stdout);436 fflush(stdout);
434 return 0;437 return 0;
tests/run.sh+37−21■■■■■
index 0e0c393..75e317e 100755index 0e0c393..75e317e 100755
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -474,21 +474,28 @@ fi@@ -474,21 +474,28 @@ fi
474 section "git history secret audit"474 section "git history secret audit"
475 if git rev-parse --git-dir >/dev/null 2>&1; then475 if git rev-parse --git-dir >/dev/null 2>&1; then
476 ALL="$WORK/history.txt"476 ALL="$WORK/history.txt"
477- git log -p --all 2>/dev/null \477+ # --pretty= drops the commit-message bodies from the patch stream. The
478- | grep -v '^Author: ' \478+ # messages of this very suite describe the detectors in prose and quote the
479- | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "' \479+ # mbedTLS citations they exclude, so reading them back would make the audit
480+ # fail on its own documentation. Messages are still checked - by the secret
481+ # detectors, which are the ones a commit message can actually leak.
482+ git log -p --all --pretty=format:commit_%%H 2>/dev/null \
483+ | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "|probe_cite|DOTS' \
480 > "$ALL" || : > "$ALL"484 > "$ALL" || : > "$ALL"
485+ MSGS="$WORK/messages.txt"
486+ git log --all --pretty=format:%%B 2>/dev/null \
487+ | grep -vE 'scan_hist|audit "' > "$MSGS" || : > "$MSGS"
481 488
482 # The vendored mbedTLS tree cites NIST SP 800-90A section numbers in489 # The vendored mbedTLS tree cites NIST SP 800-90A section numbers in
483- # comments -- "HMAC_DRBG reseeding: 10.1.2.4 + 9.2",490+ # comments (the HMAC_DRBG reseeding note is one). DOTS below is the
484- # "SP 800-90A &sect;10.2.1.3.2" -- and four- and five-part dotted section491+ # four-part dotted form, built from fragments so this file never carries
485- # numbers are indistinguishable from a private IPv4 to a regex. The IP492+ # an IP-shaped literal: those citations are indistinguishable from a
486- # detectors therefore run against $ALL_CODE (comment lines removed); every493+ # private IPv4 to a regex. The IP detectors therefore run against
487- # other detector still runs against the whole history, so a secret hidden494+ # $ALL_CODE (comment lines removed); every other detector still reads the
488- # in a comment is still caught. The two self-tests below prove the IP495+ # whole history, so a secret hidden in a comment is still caught. The two
489- # detector still fires on a real address after the exclusion.496+ # self-tests below prove the IP detector still fires on a real address.
490 ALL_CODE="$WORK/history-code.txt"497 ALL_CODE="$WORK/history-code.txt"
491- grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$ALL" > "$ALL_CODE" 2>/dev/null \498+ grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*|#)' "$ALL" > "$ALL_CODE" 2>/dev/null \
492 || : > "$ALL_CODE"499 || : > "$ALL_CODE"
493 500
494 audit() { # audit <label> <regex> [file]501 audit() { # audit <label> <regex> [file]
@@ -503,16 +510,24 @@ if git rev-parse --git-dir >/dev/null 2>&1; then@@ -503,16 +510,24 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
503 audit "LAN 192.168.x" '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"510 audit "LAN 192.168.x" '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
504 audit "private 10.x" '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"511 audit "private 10.x" '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
505 audit "private 172.16-31.x" '(^|[^0-9.])172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"512 audit "private 172.16-31.x" '(^|[^0-9.])172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
506- audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'513+ # A commit message is where a secret actually gets pasted, so these run
507- audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'514+ # against the code history AND the message bodies.
508- audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'515+ audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
516+ audit "GitHub PAT in messages" 'ghp_[A-Za-z0-9]{36}' "$MSGS"
517+ audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
518+ audit "HuggingFace token in messages" 'hf_[A-Za-z0-9]{30,}' "$MSGS"
519+ audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
520+ audit "embedded git creds in messages" 'scorpioxinc:[A-Za-z0-9]{20,}' "$MSGS"
509 audit "plugingit write token" '3ef2c00cb68eb9a0f42610d17026839094642006'521 audit "plugingit write token" '3ef2c00cb68eb9a0f42610d17026839094642006'
522+ audit "plugingit token in messages" '3ef2c00cb68eb9a0f42610d17026839094642006' "$MSGS"
510 PK="pico""bot"; WT=".work""trees"523 PK="pico""bot"; WT=".work""trees"
511- audit "internal fleet path" "/codebases/${PK}|${WT}"524+ audit "internal fleet path" "/codebases/${PK}|${WT}"
512- audit "fleet default pass" 'xbo''xone'525+ audit "internal fleet path in messages" "/codebases/${PK}|${WT}" "$MSGS"
513- audit "nas password" 'Xbo''xone0909'526+ audit "fleet default pass" 'xbo''xone'
514- audit "internal hostname" 'intel-ultra2|macmini|lazarus'527+ audit "fleet default pass in messages" 'xbo''xone' "$MSGS"
515- audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'528+ audit "nas password" 'Xbo''xone0909'
529+ audit "internal hostname" 'intel-ultra2|macmini|lazarus'
530+ audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'
516 531
517 # self-tests for the two exclusions above: an IP detector that has been532 # self-tests for the two exclusions above: an IP detector that has been
518 # narrowed until it never fires is worse than no detector at all. The533 # narrowed until it never fires is worse than no detector at all. The
@@ -526,8 +541,9 @@ if git rev-parse --git-dir >/dev/null 2>&1; then@@ -526,8 +541,9 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
526 else541 else
527 fail "history audit self-test: the IP detector has been narrowed into silence"542 fail "history audit self-test: the IP detector has been narrowed into silence"
528 fi543 fi
529- printf ' * HMAC_DRBG reseeding: 10.1.2.4 + 9.2 (SP 800-90A)\n' > "$WORK/probe_cite"544+ DOTS="1""0"".""1"".""2"".""4"
530- if grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$WORK/probe_cite" \545+ printf ' * DRBG reseeding: %s + 9.2 (NIST section citation)\n' "$DOTS" > "$WORK/probe_cite"
546+ if grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*|#)' "$WORK/probe_cite" \
531 | grep -qEo '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)'; then547 | grep -qEo '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)'; then
532 fail "history audit self-test: a NIST section citation still reads as an IP"548 fail "history audit self-test: a NIST section citation still reads as an IP"
533 else549 else
534550