code wiki / _hdl_build / nx_cwe_scan.nx

nx_cwe_scan.nx

buildroot/runtime/_hdl_build/nx_cwe_scan.nx

26612 B515 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_cwe_scan.nx -- SOVEREIGN CISQ / ISO-IEC-5055 STRUCTURAL WEAKNESS SCANNER (eats seq250, the biggest GAP in the industry battery). ISO/IEC 5055 grades software by COUNTING CWE structural weaknesses across four of the ISO-25010 characteristics -- Reliability, Security, Performance Efficiency, Maintainability. Until this existed, our SQALE rating was an A partly BECAUSE NOBODY WAS LOOKING: undetected weakness cannot enter the remediation numerator. This is the detector that makes the letter mean something. The CWE->factor mapping and severity weights live in the NATIVE PLANE knowledge/store/cwerules- (never a .tsv, per the law this session just gave a tooth). Detection is structural and must be code; the STANDARD's taxonomy is data. Fails closed: no rules plane -> RED, no grade without the standard. ★HONEST ENVELOPE, STATED IN THE OUTPUT ITSELF: this is bounded TEXTUAL/heuristic analysis, NOT interprocedural dataflow. It reports CANDIDATE weaknesses -- false positives are possible and expected, and crucially ABSENCE OF FINDINGS IS NOT PROOF OF ABSENCE. A scanner that claimed otherwise would be exactly the navel-gazing the scorecard exists to prevent. Every cap (files, bytes/file, guard window) is DECLARED. nx_cwe_scan [dir] [maxfiles] default dir=buildroot/runtime/_hdl_build, maxfiles=1200 license_tier: ORIGINAL expect_exit: 0

dependencies 3 imports · 0 importers

nx_store_seed_lib.nx nx_seg_store.nx nx_syscalls.nx nx_cwe_scan.nx

imports: nx_store_seed_lib.nxnx_seg_store.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap sts_load ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat sys_fstatat ssc_streq ss_open ss_open2 sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn ss_cat ↻ ss_loadfile sys_map_file ss_readall ss_load_aux2 sys_mmap ↻ ss_cat ↻ ss_loadfile ↻ ss_r32 sys_munmap ssl_total_keys ss_r32 ↻ ssl_pow2 ssl_build ss_r32 ↻ ssl_hash_entry ssl_key_eq ss_r32 ↻ ssl_lookup ssl_hash_entry ↻ ssl_key_eq ↻ ss_manifest_free sys_munmap ↻ sys_munmap ↻ ssc_retire_handle

structs

none

consts

20const CW_MAGIC_1024: i64 = 1024
21const CW_MAGIC_65536: i64 = 65536
22const CW_MAGIC_3900: i64 = 3900
23const CW_MAGIC_131072: i64 = 131072
24const CW_MAGIC_1200: i64 = 1200
25const CW_MAGIC_4096: i64 = 4096
26const CW_MAGIC_262144: i64 = 262144
28const CW_PLANE: *u8 = "knowledge/store/cwerules-"
29const CW_LOG: *u8 = "knowledge/status/cwe_scan.log"
30const CW_CAP: i64 = 1048576
31const CW_FILECAP: i64 = 262144 // declared: bytes read per organ
32const CW_WINDOW: i64 = 420 // declared: forward window for a guard, in bytes
33const CW_MAXHIT: i64 = 10 // declared: offender examples retained
39const CW_RATCHET: *u8 = "knowledge/store/cweratchet-"
132const CW_NRULES: i64 = 5

functions

41func cw_w(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 1: main calls 1: sys_write
42func cw_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
43func cw_cat(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a }
called by 2: cw_scan_filemain
44func cw_catf(o: *u8, at: i64, p: *u8, n: i64) -> i64 { var i: i64=0; var a: i64=at; while i<n { o[a]=p[i]; a=a+1; i=i+1 } return a }
called by 2: cw_scan_filemain
45func cw_catn(o: *u8, at: i64, v: i64) -> i64
called by 2: cw_scan_filemain calls 1: sys_mmap
56func cw_within(buf: *u8, n: i64, from: i64, win: i64, needle: *u8) -> i64
called by 1: cw_scan_file calls 1: cw_slen
71func cw_inline(buf: *u8, ls: i64, le: i64, needle: *u8) -> i64
called by 1: cw_scan_file calls 1: cw_slen
84func cw_digits(buf: *u8, p: i64, le: i64) -> i64
called by 1: cw_capshape
101func cw_capshape(buf: *u8, ls: i64, le: i64) -> i64
called by 1: cw_scan_file calls 1: cw_digits
121func cw_isdotdot(nm: *u8) -> i64 { if nm[0]==(46 as u8){ if nm[1]==(0 as u8){return 1} if nm[1]==(46 as u8){ if nm[2]==(0 as u8){return 1} } } return 0 }
called by 1: cw_walk
122func cw_join(buf: *u8, base_n: i64, name: *u8) -> i64 { buf[base_n]=47 as u8; var o: i64=base_n+1; var i: i64=0; while name[i]!=(0 as u8){buf[o]=name[i];o=o+1;i=i+1} return o }
called by 1: cw_walk
133func cw_rule_id(idx: i64) -> *u8
called by 1: cw_detector_for
142func cw_id_match(pb: *u8, off: i64, len: i64, id: *u8) -> i64
called by 1: cw_detector_for calls 1: cw_slen
150func cw_detector_for(pb: *u8, off: i64, len: i64) -> i64
called by 1: main calls 2: cw_id_matchcw_rule_id
161func cw_is_test(path: *u8, pathlen: i64) -> i64
called by 1: cw_scan_file
181func cw_keyidx(buf: *u8, ls: i64, le: i64, nm: *u8) -> i64
called by 1: cw_keyname calls 1: cw_slen
196func cw_keyname(buf: *u8, ls: i64, le: i64) -> i64
called by 1: cw_scan_file calls 1: cw_keyidx
206func cw_ratchet_for(rb: *u8, rn: i64, pb: *u8, off: i64, len: i64) -> i64
called by 1: main
240func cw_scan_file(path: *u8, pathlen: i64, fbuf: *u8, hits: *i64, ex: *u8, exo: *i64, exn: *i64) -> i64
336func cw_walk(p: *u8, pn: i64, depth: i64, maxf: i64, fbuf: *u8, hits: *i64, ex: *u8, exo: *i64, exn: *i64, fseen: *i64) -> i64
371func main(argc: i64, argv: *i64) -> i64