refactor(bindings): split newWafSymbols into a table and a loop (maat #6) #244
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 412 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #244"
general
weight: 0.35
eliottness
What and why
newWafSymbols(internal/bindings/libddwaf.go) had 20 copies of the same "resolve the symbol, return on error" block.maatreported 8 hits on it. This change replaces the 20 blocks with a table of 20{name, uintptr}rows ((wafSymbols).table) and 1 loop.No behavior change:
failed to resolve libddwaf symbol %q: %w) and same%wwrapping.newWafSymbols, soreturn syms, ...readssymsafter the loop filled it.newWafSymbols, thewafSymbolsstruct andwaf_dl.godo not change.Part of the
maatassessment (item #6). Linear: DD-34.The new file
internal/bindings/libddwaf_test.gohas the first tests of this code:TestWafSymbolsTablechecks the name, the order and the target field of each row against a list copied from the code onmain. It usesrequire.Samefor the pointers, becauserequire.Equalcompares the pointed values and all fields are 0.TestNewWafSymbolsMissingSymbolloads libc (linux) or libSystem (darwin), which has no libddwaf symbol. It checks the%wtype, the exact text (it names the first symbol of the table), and that the returnedsymsis zero.maatbefore / after (maat analyze ./... --output json --detail full,maat0.5.0)| Scope | Before | After |
|---|---|---|
| Overall | 90 (base 89.54) | 90 (base 89.64) |
|
internal/bindings| 94 (base 93.94) | 95 (base 95.01) ||
libddwaf.go| 84 | 100 ||
libddwaf_test.go(new) | none | 100 |No new hit. The 8 removed hits, all on
newWafSymbols:| Rule | Severity | Value |
|---|---|---|
| MAAT-CC-001 | error | cyclomatic complexity 22 |
| MAAT-CC-002 | warning | cognitive complexity 20 |
| MAAT-FUNC-002 | error | cyclomatic complexity 22 |
| MAAT-FUNC-003 | warning | 43 SLOC |
| MAAT-FUNC-006 | warning | 21 return statements |
| MAAT-HALSTEAD-001 | warning | Halstead volume 1381.3 |
| MAAT-MI-001 | error | maintainability index 39 |
| MAAT-SLOC-001 | warning | 43 SLOC |
Total hits: 199 → 191. The module hit MAAT-TEST-001 stays (16 → 18 test functions, 25% → 28%). The overall integer score stays at 90 (threshold 95).
Checks done locally
| Check | Result |
|---|---|
|
go vet ./...| exit 0 ||
go test -count=1 ./...(darwin/arm64) | pass ||
CGO_ENABLED=0 go test -count=1 -tags ci,appsec ./internal/bindings/(darwin/arm64) | pass ||
GOEXPERIMENT=cgocheck2 CGO_ENABLED=1 go test -race -count=1 -tags ci ./internal/bindings/(darwin/arm64) | pass ||
golang:1.27-bookworm(linux/arm64, glibc),CGO_ENABLED=0 -tags ci,appsec, thenCGO_ENABLED=1 -tags ci| pass, pass ||
golang:1.27-alpine(linux/arm64, musl),CGO_ENABLED=0 -tags ci,appsec| pass || Mutation 1: swap the pointers of 2 rows |
TestWafSymbolsTablefails at entry 1 || Mutation 2: swap the order of 2 rows |
TestWafSymbolsTablefails at entry 6 |Both mutations were reverted.
Order and mapping check against
main(the name → field pairs of the 20 oldifblocks vs. the new table, and vs. the golden list in the test): bothdiffcommands print nothing (exit 0).