code wiki / _hdl_build / nx_cwe_scan.nx
nx_cwe_scan.nx
buildroot/runtime/_hdl_build/nx_cwe_scan.nx
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
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
structs
| none |
consts
| 20 | const CW_MAGIC_1024: i64 = 1024 |
| 21 | const CW_MAGIC_65536: i64 = 65536 |
| 22 | const CW_MAGIC_3900: i64 = 3900 |
| 23 | const CW_MAGIC_131072: i64 = 131072 |
| 24 | const CW_MAGIC_1200: i64 = 1200 |
| 25 | const CW_MAGIC_4096: i64 = 4096 |
| 26 | const CW_MAGIC_262144: i64 = 262144 |
| 28 | const CW_PLANE: *u8 = "knowledge/store/cwerules-" |
| 29 | const CW_LOG: *u8 = "knowledge/status/cwe_scan.log" |
| 30 | const CW_CAP: i64 = 1048576 |
| 31 | const CW_FILECAP: i64 = 262144 // declared: bytes read per organ |
| 32 | const CW_WINDOW: i64 = 420 // declared: forward window for a guard, in bytes |
| 33 | const CW_MAXHIT: i64 = 10 // declared: offender examples retained |
| 39 | const CW_RATCHET: *u8 = "knowledge/store/cweratchet-" |
| 132 | const CW_NRULES: i64 = 5 |
functions
| 41 | func 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 } |
| 42 | func cw_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 43 | func 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 } |
| 44 | func 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 } |
| 45 | func cw_catn(o: *u8, at: i64, v: i64) -> i64 |
| 56 | func cw_within(buf: *u8, n: i64, from: i64, win: i64, needle: *u8) -> i64 |
| 71 | func cw_inline(buf: *u8, ls: i64, le: i64, needle: *u8) -> i64 |
| 84 | func cw_digits(buf: *u8, p: i64, le: i64) -> i64 called by 1: cw_capshape |
| 101 | func cw_capshape(buf: *u8, ls: i64, le: i64) -> i64 |
| 121 | func 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 |
| 122 | func 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 |
| 133 | func cw_rule_id(idx: i64) -> *u8 called by 1: cw_detector_for |
| 142 | func cw_id_match(pb: *u8, off: i64, len: i64, id: *u8) -> i64 |
| 150 | func cw_detector_for(pb: *u8, off: i64, len: i64) -> i64 |
| 161 | func cw_is_test(path: *u8, pathlen: i64) -> i64 called by 1: cw_scan_file |
| 181 | func cw_keyidx(buf: *u8, ls: i64, le: i64, nm: *u8) -> i64 |
| 196 | func cw_keyname(buf: *u8, ls: i64, le: i64) -> i64 |
| 206 | func cw_ratchet_for(rb: *u8, rn: i64, pb: *u8, off: i64, len: i64) -> i64 called by 1: main |
| 240 | func cw_scan_file(path: *u8, pathlen: i64, fbuf: *u8, hits: *i64, ex: *u8, exo: *i64, exn: *i64) -> i64 |
| 336 | func cw_walk(p: *u8, pn: i64, depth: i64, maxf: i64, fbuf: *u8, hits: *i64, ex: *u8, exo: *i64, exn: *i64, fseen: *i64) -> i64 called by 2: cw_walkmain calls 11: sys_openat_rdsys_mmapsys_getdents64dirent_typedirent_namecw_isdotdot+5 |
| 371 | func main(argc: i64, argv: *i64) -> i64 |