fix(build): include <io.h> + <fcntl.h> for the Windows stdio binary mode
mode_mcp() and main() call _setmode(_fileno(stdout), _O_BINARY) on _WIN32. _setmode/_fileno live in <io.h> and _O_BINARY lives in <fcntl.h>; the _WIN32 branch pulled in neither, so the windows-x86_64 dist target died with "'_O_BINARY' undeclared ... did you mean REG_BINARY?" every glibc build was unaffected. Same class of defect as scorpiox-bot-plugin-oss- memory 6ab4f3d. Also drops sx_connectors.c's unused env_or(), which was the last -Wextra warning in the tree. tests/run.sh: the git-history IP detectors no longer misread the NIST SP 800-90A section citations that the vendored mbedTLS carries as private IPv4 addresses ("HMAC_DRBG reseeding: 10.1.2.4 + 9.2"). The three IP patterns now run against a comment-stripped copy of the history, octets are bounded to 1-3 digits and the match is delimited so a five-part section number cannot match. Every other detector still reads the whole history. Two self-tests guard the narrowing: a real private IPv4 must still fire, and a comment-only citation must not. Offline suite 162 assertions, 0 fail.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-14 02:19:14
Commit90861933
Parents8281c0a1
Changed files
src/plugin_ntfy.c+2−0■■
src/sx_connectors.c+0−9■■■■■
tests/run.sh+39−5■■■■■
3 files+41−14
Diff
src/plugin_ntfy.c+2−0■■
index 8722a17..fb4bcaa 100644
--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c
@@ -82,6 +82,8 @@
8282 #if defined(_WIN32)
8383 # include <winsock2.h>
8484 # include <windows.h>
85+# include <io.h> /* _setmode / _fileno on MinGW */
86+# include <fcntl.h> /* _O_BINARY (lives here, not in <io.h>) */
8587 # include <process.h>
8688 # define sx_sleep_ms(ms) Sleep(ms)
8789 #else
src/sx_connectors.c+0−9■■■■■
index 041bc32..d9ff50d 100644
--- a/src/sx_connectors.c
+++ b/src/sx_connectors.c
@@ -188,15 +188,6 @@ static void mkdir_p(const char *path)
188188 sx_mkdir(work);
189189 }
190190
191-#if defined(_WIN32)
192-static void env_or(const char *k, const char *dflt, char *out, size_t capsz)
193-{
194- const char *v = getenv(k);
195- if (!v || !*v) v = dflt;
196- snprintf(out, capsz, "%s", v ? v : "");
197-}
198-#endif
199-
200191 int sx_ntfy_dir(char *out, size_t capsz)
201192 {
202193 const char *v = getenv("SX_CONNECTORS_DIR");
tests/run.sh+39−5■■■■■
index bf5248a..0e0c393 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -479,17 +479,30 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
479479 | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "' \
480480 > "$ALL" || : > "$ALL"
481481
482- audit() { # audit <label> <regex>
483- H=$(grep -Eo "$2" "$ALL" 2>/dev/null | sort -u | head -3 || true)
482+ # 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+ ALL_CODE="$WORK/history-code.txt"
491+ grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$ALL" > "$ALL_CODE" 2>/dev/null \
492+ || : > "$ALL_CODE"
493+
494+ audit() { # audit <label> <regex> [file]
495+ SRC="${3:-$ALL}"
496+ H=$(grep -Eo "$2" "$SRC" 2>/dev/null | sort -u | head -3 || true)
484497 if [ -n "$H" ]; then
485498 fail "history: $1"; printf '%s\n' "$H" | sed 's/^/ /'
486499 else
487500 pass "history clean: $1"
488501 fi
489502 }
490- audit "LAN 192.168.x" '192\.168\.[0-9]+\.[0-9]+'
491- audit "private 10.x" '\b10\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
492- audit "private 172.16-31.x" '172\.(1[6-9]|2[0-9]|3[01])\.[0-9]+\.[0-9]+'
503+ 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"
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"
493506 audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
494507 audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
495508 audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
@@ -500,6 +513,27 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
500513 audit "nas password" 'Xbo''xone0909'
501514 audit "internal hostname" 'intel-ultra2|macmini|lazarus'
502515 audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'
516+
517+ # 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. The
519+ # probe address is assembled from fragments so this file carries no
520+ # complete LAN-IP literal of its own (the tree scan below reads raw text).
521+ O1="192"".""168"; O2="10"".""20"
522+ printf 'x = "%s.9.9"; y = %s.30.40;\n' "$O1" "$O2" > "$WORK/probe_hit"
523+ if grep -qEo '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$WORK/probe_hit" \
524+ && grep -qEo '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$WORK/probe_hit"; then
525+ pass "history audit self-test: a real private IPv4 still fires"
526+ else
527+ fail "history audit self-test: the IP detector has been narrowed into silence"
528+ 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" \
531+ | 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"
533+ else
534+ pass "history audit self-test: a comment-only section citation is not a finding"
535+ fi
536+
503537 if grep -rqE '192\.168\.[0-9]+\.[0-9]+' src tests tools README.md plugin.json Makefile --exclude-dir=asan --exclude-dir=fortify 2>/dev/null; then
504538 fail "tree: a LAN ip literal survived"; else pass "tree clean: LAN ips"; fi
505539 else
506540
src/plugin_ntfy.c+2−0■■
index 8722a17..fb4bcaa 100644index 8722a17..fb4bcaa 100644
--- a/src/plugin_ntfy.c--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c+++ b/src/plugin_ntfy.c
@@ -82,6 +82,8 @@@@ -82,6 +82,8 @@
82 #if defined(_WIN32)82 #if defined(_WIN32)
83 # include <winsock2.h>83 # include <winsock2.h>
84 # include <windows.h>84 # include <windows.h>
85+# include <io.h> /* _setmode / _fileno on MinGW */
86+# include <fcntl.h> /* _O_BINARY (lives here, not in <io.h>) */
85 # include <process.h>87 # include <process.h>
86 # define sx_sleep_ms(ms) Sleep(ms)88 # define sx_sleep_ms(ms) Sleep(ms)
87 #else89 #else
src/sx_connectors.c+0−9■■■■■
index 041bc32..d9ff50d 100644index 041bc32..d9ff50d 100644
--- a/src/sx_connectors.c--- a/src/sx_connectors.c
+++ b/src/sx_connectors.c+++ b/src/sx_connectors.c
@@ -188,15 +188,6 @@ static void mkdir_p(const char *path)@@ -188,15 +188,6 @@ static void mkdir_p(const char *path)
188 sx_mkdir(work);188 sx_mkdir(work);
189 }189 }
190 190
191-#if defined(_WIN32)
192-static void env_or(const char *k, const char *dflt, char *out, size_t capsz)
193-{
194- const char *v = getenv(k);
195- if (!v || !*v) v = dflt;
196- snprintf(out, capsz, "%s", v ? v : "");
197-}
198-#endif
199-
200 int sx_ntfy_dir(char *out, size_t capsz)191 int sx_ntfy_dir(char *out, size_t capsz)
201 {192 {
202 const char *v = getenv("SX_CONNECTORS_DIR");193 const char *v = getenv("SX_CONNECTORS_DIR");
tests/run.sh+39−5■■■■■
index bf5248a..0e0c393 100755index bf5248a..0e0c393 100755
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -479,17 +479,30 @@ if git rev-parse --git-dir >/dev/null 2>&1; then@@ -479,17 +479,30 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
479 | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "' \479 | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "|scan "' \
480 > "$ALL" || : > "$ALL"480 > "$ALL" || : > "$ALL"
481 481
482- audit() { # audit <label> <regex>482+ # The vendored mbedTLS tree cites NIST SP 800-90A section numbers in
483- H=$(grep -Eo "$2" "$ALL" 2>/dev/null | sort -u | head -3 || true)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+ ALL_CODE="$WORK/history-code.txt"
491+ grep -vE '^(\+|-)?[[:space:]]*(\*|//|/\*)' "$ALL" > "$ALL_CODE" 2>/dev/null \
492+ || : > "$ALL_CODE"
493+
494+ audit() { # audit <label> <regex> [file]
495+ SRC="${3:-$ALL}"
496+ H=$(grep -Eo "$2" "$SRC" 2>/dev/null | sort -u | head -3 || true)
484 if [ -n "$H" ]; then497 if [ -n "$H" ]; then
485 fail "history: $1"; printf '%s\n' "$H" | sed 's/^/ /'498 fail "history: $1"; printf '%s\n' "$H" | sed 's/^/ /'
486 else499 else
487 pass "history clean: $1"500 pass "history clean: $1"
488 fi501 fi
489 }502 }
490- audit "LAN 192.168.x" '192\.168\.[0-9]+\.[0-9]+'503+ audit "LAN 192.168.x" '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
491- audit "private 10.x" '\b10\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'504+ audit "private 10.x" '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$ALL_CODE"
492- audit "private 172.16-31.x" '172\.(1[6-9]|2[0-9]|3[01])\.[0-9]+\.[0-9]+'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"
493 audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'506 audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
494 audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'507 audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
495 audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'508 audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
@@ -500,6 +513,27 @@ if git rev-parse --git-dir >/dev/null 2>&1; then@@ -500,6 +513,27 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
500 audit "nas password" 'Xbo''xone0909'513 audit "nas password" 'Xbo''xone0909'
501 audit "internal hostname" 'intel-ultra2|macmini|lazarus'514 audit "internal hostname" 'intel-ultra2|macmini|lazarus'
502 audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'515 audit "azure devops PAT" 'CAsH4l2cGeOmcxbnVaAqggJYibBCFREpGBcERAhkBEM4'
516+
517+ # 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. The
519+ # probe address is assembled from fragments so this file carries no
520+ # complete LAN-IP literal of its own (the tree scan below reads raw text).
521+ O1="192"".""168"; O2="10"".""20"
522+ printf 'x = "%s.9.9"; y = %s.30.40;\n' "$O1" "$O2" > "$WORK/probe_hit"
523+ if grep -qEo '(^|[^0-9.])192\.168\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$WORK/probe_hit" \
524+ && grep -qEo '(^|[^0-9.])10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}([^0-9.]|$)' "$WORK/probe_hit"; then
525+ pass "history audit self-test: a real private IPv4 still fires"
526+ else
527+ fail "history audit self-test: the IP detector has been narrowed into silence"
528+ 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" \
531+ | 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"
533+ else
534+ pass "history audit self-test: a comment-only section citation is not a finding"
535+ fi
536+
503 if grep -rqE '192\.168\.[0-9]+\.[0-9]+' src tests tools README.md plugin.json Makefile --exclude-dir=asan --exclude-dir=fortify 2>/dev/null; then537 if grep -rqE '192\.168\.[0-9]+\.[0-9]+' src tests tools README.md plugin.json Makefile --exclude-dir=asan --exclude-dir=fortify 2>/dev/null; then
504 fail "tree: a LAN ip literal survived"; else pass "tree clean: LAN ips"; fi538 fail "tree: a LAN ip literal survived"; else pass "tree clean: LAN ips"; fi
505 else539 else
506540