code wiki / _hdl_build / nx_secret_scan.nx
nx_secret_scan.nx
buildroot/runtime/_hdl_build/nx_secret_scan.nx
about
nx_secret_scan.nx -- the team's PLAINTEXT-CREDENTIAL scanner (Sentinel lane; the DETECT half
of secret self-management -- nx_secret_cli is the STORE half, nx_security_sentinel ESCALATES).
What it does, every run:
1. Walks a DATA-DRIVEN root table (repo root depth-1, bench/ops, runtime/_hdl_build, _offc).
2. For each regular TEXT file (binary = NUL byte in first 512B -> skipped; >4MiB capped),
counts occurrences of a DATA-DRIVEN credential-pattern table. The quote-bearing patterns
are ASSEMBLED AT RUNTIME (byte append) so this source never matches itself; files whose
NAME contains "secret_scan" are skipped for the same reason.
3. Each finding -> one line to stdout + one ISSUE line with marker PLAINTEXT-SECRET appended
to knowledge/status/issues_durable.log (the signal stream nx_security_sentinel watches --
its PLAINTEXT-SECRET row escalates to PM; resolve via SENTINEL-RESOLVE after migration).
4. Appends one SECRET-SCAN verdict line to knowledge/status/secret_scan.log.
Exit 0 = clean, 1 = findings (re-runnable gate: clean tree MUST exit 0).
Adding coverage = adding a pattern row or a root row (build intelligence, never strip).
The FIX for a finding is never "delete the script" -- it is migration to the vault path:
_offc/nx_secret_cli.elf get <name> -> /tmp/nxsecret.out (see _nx_vault_ssh.sh for the shape).
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const SCAN_MAGIC_4096: i64 = 4096 |
| 23 | const SCAN_FILE_MAX: i64 = 4194304 // 4 MiB read cap per file |
| 24 | const SCAN_DIRBUF: i64 = 1048576 |
| 25 | const SCAN_ROOTS: i64 = 4 |
| 26 | const SCAN_PATS: i64 = 6 |
functions
| 28 | func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 29 | func _fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 30 | func _fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 31 | func ss_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 32 | func ss_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } |
| 35 | func ss_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 54 | func ss_count(buf: *u8, n: i64, pat: *u8, qch: i64) -> i64 |
| 77 | func ss_has_sub(name: *u8, sub: *u8) -> i64 |
| 83 | func ss_is_binary(buf: *u8, n: i64) -> i64 called by 1: ss_scan_file |
| 96 | func ss_scan_file(path: *u8, fbuf: *u8, tabs: *i64, ifd: i64) -> i64 |
| 123 | func ss_walk_root(root: *u8, fbuf: *u8, tabs: *i64, ifd: i64, files_out: *i64) -> i64 called by 1: main calls 10: sys_openat_rdsys_mmapsys_getdents64dirent_reclendirent_namedirent_type+4 |
| 170 | func main(argc: i64, argv: *i64) -> i64 |