code wiki / _hdl_build / nx_secret_scan.nx

nx_secret_scan.nx

buildroot/runtime/_hdl_build/nx_secret_scan.nx

11256 B250 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic secret
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_secret_scan.nx

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

main _p sys_write sys_mmap ss_cat sys_openat_append sys_exit ss_walk_root sys_openat_rd sys_mmap ↻ sys_getdents64 dirent_reclen dirent_name dirent_type ss_has_sub ss_slen ss_count ss_slen ↻ ss_cat ↻ ss_scan_file ss_read sys_openat_rd ↻ sys_read sys_close ss_is_binary ss_count ↻ _p ↻ _fn sys_mmap ↻ sys_write ↻ _fp sys_write ↻ sys_close ↻ sys_close ↻ _fp ↻ _fn ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real

structs

none

consts

21const SCAN_MAGIC_4096: i64 = 4096
23const SCAN_FILE_MAX: i64 = 4194304 // 4 MiB read cap per file
24const SCAN_DIRBUF: i64 = 1048576
25const SCAN_ROOTS: i64 = 4
26const SCAN_PATS: i64 = 6

functions

28func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: ss_scan_filemain calls 1: sys_write
29func _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 }
called by 2: ss_scan_filemain calls 1: sys_write
30func _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 }
called by 2: ss_scan_filemain calls 2: sys_mmapsys_write
31func ss_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: ss_countss_has_sub
32func 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 }
called by 2: ss_walk_rootmain
35func ss_read(path: *u8, buf: *u8, cap: i64) -> i64
54func ss_count(buf: *u8, n: i64, pat: *u8, qch: i64) -> i64
called by 2: ss_has_subss_scan_file calls 1: ss_slen
77func ss_has_sub(name: *u8, sub: *u8) -> i64
called by 1: ss_walk_root calls 2: ss_slenss_count
83func ss_is_binary(buf: *u8, n: i64) -> i64
called by 1: ss_scan_file
96func ss_scan_file(path: *u8, fbuf: *u8, tabs: *i64, ifd: i64) -> i64
123func ss_walk_root(root: *u8, fbuf: *u8, tabs: *i64, ifd: i64, files_out: *i64) -> i64
170func main(argc: i64, argv: *i64) -> i64