Skip to content

Commit 1b7ce78

Browse files
committed
Restore static analysis hygiene gates
1 parent 01ee2e7 commit 1b7ce78

21 files changed

Lines changed: 879 additions & 382 deletions

File tree

.agents/sow/done/SOW-0010-20260602-static-analysis-finding-cleanup.md

Lines changed: 161 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
Status: completed
66

7-
Sub-state: Codacy Cloud remaining findings were fixed locally and scanner
8-
validation passed.
7+
Sub-state: Completed after restoring the approved hygiene checks and validating
8+
the scanner/test matrix.
99

1010
## Requirements
1111

@@ -189,6 +189,10 @@ Open decisions:
189189
- 2026-06-02: The user decided that active scanner findings must be fixed or the
190190
rule must be removed/tuned. Keeping a rule while hiding its output from one UI
191191
is not acceptable.
192+
- 2026-06-03: The user approved restoring all recommended hygiene checks:
193+
staticcheck as a hard gate, Codacy Local as a hard gate, selected CodeQL
194+
hygiene/security query IDs, and selected gosec rules for unchecked errors,
195+
integer conversions, file permissions, path traversal, and unsafe usage.
192196

193197
## Plan
194198

@@ -234,20 +238,51 @@ Open decisions:
234238
disabled, 7 tools reconfigured, 2,727 patterns enabled, and reanalysis
235239
requested.
236240

241+
### 2026-06-03
242+
243+
- Recorded the user decision to restore all recommended hygiene checks.
244+
- Made `staticcheck` a hard gate in `.github/workflows/static-analysis.yml`.
245+
- Made Codacy Local Analysis fail the workflow when the Codacy Analysis CLI
246+
reports a non-zero status.
247+
- Restored selected CodeQL hygiene/security query IDs by removing their
248+
`query-filters` exclusions.
249+
- Restored gosec rules `G103`, `G104`, `G115`, `G304`, `G306`, and `G703`;
250+
only `G404` remains excluded because the approved restore list did not include
251+
insecure random findings.
252+
- Fixed production Go integer-conversion findings in protocol and raw service
253+
code with checked conversions.
254+
- Converted unchecked cleanup calls to explicit ignored cleanup results, and
255+
added narrow `#nosec` comments only for intentional mmap, futex, syscall, and
256+
fixture path patterns.
257+
- Fixed fixture and benchmark findings from restored gosec rules.
258+
- Removed Codacy Revive from local Codacy configuration after direct Revive
259+
execution passed but the Codacy adapter failed with `findings is not
260+
iterable`.
261+
- Added Semgrep-only excludes for parser-incompatible Windows C fixtures and
262+
two scripts that are still covered by ShellCheck, cppcheck, CodeQL, or the
263+
dedicated static workflow.
264+
- Changed the production C SHM path format string to avoid a Semgrep parser
265+
failure on the `PRIx64` macro while preserving the same hexadecimal session
266+
ID output.
267+
237268
## Validation
238269

239270
Acceptance criteria evidence:
240271

241-
- Current enabled Codacy local rules produce zero findings with 7 enabled tools
242-
and 2,727 enabled patterns.
243-
- Current GitHub Code Scanning result-bearing CodeQL query IDs are excluded via
244-
`.github/codeql.yml` `query-filters`.
245-
- Current GitHub gosec result-bearing rule IDs are excluded in
246-
`.github/workflows/static-analysis.yml`, while gosec remains active for all
247-
other rules and will fail the job if future enabled findings appear.
248-
- Semgrep OSS now scans secrets only in
249-
`.github/workflows/supply-chain-security.yml`; Codacy Semgrep/Opengrep
250-
remains active for the tuned zero-current-finding pattern set.
272+
- Codacy local analysis now produces zero findings and zero tool errors with
273+
6 enabled tools and 2,706 enabled patterns.
274+
- `.github/codeql.yml` restores the approved CodeQL hygiene/security query IDs.
275+
The remaining excluded query IDs are `cpp/poorly-documented-function`,
276+
`cpp/redundant-null-check-simple`, and `rust/unused-variable`.
277+
- `.github/workflows/static-analysis.yml` restores gosec rules
278+
`G103`, `G104`, `G115`, `G304`, `G306`, and `G703`; only `G404` remains
279+
excluded.
280+
- `staticcheck` is a hard gate in `.github/workflows/static-analysis.yml`.
281+
- `.github/workflows/codacy-analysis.yml` now fails when the Codacy Analysis
282+
CLI reports a non-zero status.
283+
- Codacy Semgrep/Opengrep remains active; only parser-incompatible Windows C
284+
fixtures and two scripts are excluded for Semgrep, while other scanners still
285+
cover them.
251286
- Scorecard is no longer uploaded as Code Scanning SARIF; it remains available
252287
as a JSON posture artifact.
253288

@@ -259,15 +294,14 @@ Tests or equivalent validation:
259294
`.github/workflows/static-analysis.yml`, and
260295
`.github/workflows/supply-chain-security.yml`.
261296
- `actionlint` passed.
262-
- `codacy-analysis analyze . --inspect --output-format json --output /tmp/plugin-ipc-codacy-inspect-sow0010-after.json`
263-
reported 7 ready tools and zero unavailable tools.
264-
- `codacy-analysis analyze . --output-format sarif --output /tmp/plugin-ipc-codacy-sow0010-after.sarif --parallel-tools 2 --tool-timeout 900000`
265-
reported zero issues. The CLI logged 15 non-fatal tool errors: 14 Semgrep
266-
and 1 Revive parser/runtime errors.
297+
- `codacy-analysis analyze . --install-dependencies --output-format json --output /tmp/plugin-ipc-codacy.json --parallel-tools 2 --tool-timeout 900000`
298+
reported zero issues and zero tool errors.
299+
- `codacy-analysis analyze . --install-dependencies --output-format sarif --output /tmp/plugin-ipc-codacy.sarif --parallel-tools 2 --tool-timeout 900000`
300+
reported zero SARIF results.
267301
- `semgrep scan --metrics=off --config p/secrets --sarif --output /tmp/plugin-ipc-semgrep-secrets.sarif .`
268302
completed with zero findings.
269-
- Local gosec with `-exclude=G103,G104,G115,G304,G306,G404,G703` exited with
270-
status 0 in `src/go`, `tests/fixtures/go`, and `bench/drivers/go`.
303+
- Local gosec with only `-exclude=G404` exited with status 0 in `src/go`,
304+
`tests/fixtures/go`, and `bench/drivers/go`.
271305
- `git diff --check` passed.
272306

273307
Real-use evidence:
@@ -342,24 +376,23 @@ Lessons:
342376

343377
Follow-up mapping:
344378

345-
- No deferred item remains. Current result-bearing rules were either removed
346-
from the active scanner set or kept with zero local findings. Re-enabling
347-
removed broad rules would be a new cleanup/hardening SOW, not unfinished work
348-
in this SOW.
379+
- No deferred item remains. Approved hygiene rules were restored and cleaned.
380+
Remaining disabled broad debt rules were outside the approved restoration set
381+
and would require a new cleanup/hardening SOW before they can be enabled as
382+
hard gates.
349383

350384
## Outcome
351385

352386
Completed.
353387

354-
- Codacy local analysis now runs 7 enabled tools and 2,727 enabled patterns
355-
with zero findings.
388+
- Codacy local analysis now runs 6 enabled tools and 2,706 enabled patterns
389+
with zero findings and zero tool errors.
356390
- Codacy Cloud accepted the tuned config import: 4 tools disabled, 7 tools
357391
reconfigured, and repository reanalysis requested.
358-
- GitHub Code Scanning producers were tuned so current result-bearing rules are
359-
removed from active upload paths instead of hidden in GitHub only.
360-
- Go staticcheck annotations from the previous commit were fixed by preserving
361-
overflow checks in lookup offset calculations and removing an unused POSIX
362-
UDS helper.
392+
- GitHub Code Scanning producers were tuned so approved gosec and CodeQL
393+
hygiene rules are active again instead of hidden in GitHub only.
394+
- Go scanner findings from the restored rules were fixed or narrowly
395+
suppressed with justification.
363396
- No protocol behavior, public docs, or public integration skills changed.
364397

365398
## Lessons Extracted
@@ -372,7 +405,7 @@ Completed.
372405

373406
## Followup
374407

375-
None yet.
408+
None.
376409

377410
## Regression Log
378411

@@ -484,3 +517,100 @@ Artifact updates:
484517
- Specs: no protocol/API behavior changed.
485518
- Runtime project skills: no project runtime skill update was needed.
486519
- End-user/operator docs and skills: no public SDK workflow changed.
520+
521+
## Regression - 2026-06-03 Hygiene Check Restoration
522+
523+
What broke:
524+
525+
- The previous zero-finding baseline intentionally weakened useful hygiene
526+
checks. The user accepted the recommendation to restore them so scanner
527+
cleanliness does not come from disabling valuable checks.
528+
529+
Evidence:
530+
531+
- `staticcheck` is still configured with `continue-on-error: true` in
532+
`.github/workflows/static-analysis.yml`, so it annotates but does not hard
533+
fail.
534+
- `.github/workflows/codacy-analysis.yml` records the Codacy Analysis CLI
535+
status but the reporting step does not fail on non-zero status.
536+
- `.github/codeql.yml` excludes hygiene/security query IDs that should be
537+
restored for this SDK: `cpp/constant-comparison`,
538+
`cpp/toctou-race-condition`, `cpp/unused-local-variable`,
539+
`cpp/unused-static-function`, `go/incorrect-integer-conversion`,
540+
`go/unhandled-writable-file-close`, and `go/useless-assignment-to-local`.
541+
- `.github/workflows/static-analysis.yml` excludes gosec rules that should be
542+
restored or path-scoped: `G103`, `G104`, `G115`, `G304`, `G306`, and `G703`.
543+
- Official CodeQL documentation confirms query suite filters remove or keep
544+
queries by stable query metadata such as `id`.
545+
- Staticcheck documentation identifies the `SA` checks as correctness checks.
546+
- gosec documents the relevant rule IDs as security checks for unsafe use,
547+
unchecked errors, integer conversion, file path/path traversal, and file
548+
permissions.
549+
550+
Why previous validation missed it:
551+
552+
- The prior cleanup optimized for a zero-current-finding baseline after a large
553+
scanner rollout. That was useful to stop existing debt from blocking every
554+
change, but it left valuable hygiene rules weaker than the project should
555+
keep long term.
556+
557+
Repair plan:
558+
559+
- Make `staticcheck` a hard gate.
560+
- Make Codacy Local Analysis fail the workflow when the CLI reports findings.
561+
- Restore the selected CodeQL query IDs listed above.
562+
- Restore gosec `G104`, `G115`, and `G306` globally.
563+
- Restore or path-scope gosec `G103`, `G304`, and `G703`; production code should
564+
be scanned, while intentional fixture/test patterns may receive narrow
565+
suppressions with justification.
566+
- Run restored checks locally, then fix true positives or add narrow justified
567+
suppressions where the pattern is intentional and test-only.
568+
569+
Validation:
570+
571+
- `cd src/go && go test ./...` passed.
572+
- `cd tests/fixtures/go && go test ./...` passed.
573+
- `cd bench/drivers/go && go test ./...` passed.
574+
- `cd src/go && go vet ./... && "$(go env GOPATH)/bin/govulncheck" ./...`
575+
passed with no vulnerabilities found.
576+
- `cd tests/fixtures/go && go vet ./... && "$(go env GOPATH)/bin/govulncheck" ./...`
577+
passed with no vulnerabilities found.
578+
- `cd bench/drivers/go && go vet ./... && "$(go env GOPATH)/bin/govulncheck" ./...`
579+
passed with no vulnerabilities found.
580+
- `cd src/go && "$(go env GOPATH)/bin/staticcheck" ./...` passed.
581+
- `cd tests/fixtures/go && "$(go env GOPATH)/bin/staticcheck" ./...`
582+
passed.
583+
- `cd bench/drivers/go && "$(go env GOPATH)/bin/staticcheck" ./...`
584+
passed.
585+
- `actionlint` passed.
586+
- `cd src/go && "$(go env GOPATH)/bin/gosec" -quiet -fmt json -out /tmp/plugin-ipc-gosec-src-go-after.json -exclude=G404 ./...`
587+
exited 0 and produced no findings.
588+
- `cd tests/fixtures/go && "$(go env GOPATH)/bin/gosec" -quiet -fmt json -out /tmp/plugin-ipc-gosec-fixtures-go-after.json -exclude=G404 ./...`
589+
exited 0 and produced no findings.
590+
- `cd bench/drivers/go && "$(go env GOPATH)/bin/gosec" -quiet -fmt json -out /tmp/plugin-ipc-gosec-bench-go-after.json -exclude=G404 ./...`
591+
exited 0 and produced no findings.
592+
- `codacy-analysis analyze . --install-dependencies --output-format json --output /tmp/plugin-ipc-codacy.json --parallel-tools 2 --tool-timeout 900000`
593+
exited 0 with 0 issues and 0 tool errors across 6 tools: Checkov,
594+
Semgrep/Opengrep, Trivy, cppcheck, ShellCheck, and Spectral.
595+
- `codacy-analysis analyze . --install-dependencies --output-format sarif --output /tmp/plugin-ipc-codacy.sarif --parallel-tools 2 --tool-timeout 900000`
596+
exited 0 and generated SARIF with 0 results.
597+
- `make` passed and rebuilt the changed C SHM source plus Go benchmark binary.
598+
- `/usr/bin/ctest --test-dir build --output-on-failure` passed all 46 tests.
599+
The default `ctest` command on this workstation resolves to a broken
600+
Python wrapper at `~/.local/bin/ctest`; the system CTest binary was used
601+
directly.
602+
603+
Artifact updates:
604+
605+
- AGENTS.md: no update needed; existing project scanner and validation commands
606+
remain accurate.
607+
- Runtime project skills: no update needed; there are still no runtime
608+
project-specific skills and no reusable workflow was missing from AGENTS.md.
609+
- Specs: no protocol/API behavior changed. The production C format string still
610+
writes the same 16-character lowercase hexadecimal session ID.
611+
- End-user/operator docs: no update needed; no public SDK behavior or operator
612+
workflow changed.
613+
- End-user/operator skills: `docs/netipc-integrator-skill.md` is unaffected
614+
because public integration guidance did not change.
615+
- SOW lifecycle: this reopened regression is completed and the SOW will be
616+
moved back to `done/` in the same commit as the restored scanner changes.

.codacy/codacy.config.json

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,74 +4105,6 @@
41054105
}
41064106
]
41074107
},
4108-
{
4109-
"toolId": "Revive",
4110-
"patterns": [
4111-
{
4112-
"patternId": "Revive_blank-imports"
4113-
},
4114-
{
4115-
"patternId": "Revive_context-as-argument"
4116-
},
4117-
{
4118-
"patternId": "Revive_context-keys-type"
4119-
},
4120-
{
4121-
"patternId": "Revive_datarace"
4122-
},
4123-
{
4124-
"patternId": "Revive_dot-imports"
4125-
},
4126-
{
4127-
"patternId": "Revive_error-naming"
4128-
},
4129-
{
4130-
"patternId": "Revive_error-return"
4131-
},
4132-
{
4133-
"patternId": "Revive_errorf"
4134-
},
4135-
{
4136-
"patternId": "Revive_imports-blocklist"
4137-
},
4138-
{
4139-
"patternId": "Revive_increment-decrement"
4140-
},
4141-
{
4142-
"patternId": "Revive_indent-error-flow"
4143-
},
4144-
{
4145-
"patternId": "Revive_range"
4146-
},
4147-
{
4148-
"patternId": "Revive_receiver-naming"
4149-
},
4150-
{
4151-
"patternId": "Revive_superfluous-else"
4152-
},
4153-
{
4154-
"patternId": "Revive_time-naming"
4155-
},
4156-
{
4157-
"patternId": "Revive_unchecked-type-assertion"
4158-
},
4159-
{
4160-
"patternId": "Revive_unconditional-recursion"
4161-
},
4162-
{
4163-
"patternId": "Revive_unexported-return"
4164-
},
4165-
{
4166-
"patternId": "Revive_unreachable-code"
4167-
},
4168-
{
4169-
"patternId": "Revive_unsecure-url-scheme"
4170-
},
4171-
{
4172-
"patternId": "Revive_var-declaration"
4173-
}
4174-
]
4175-
},
41764108
{
41774109
"toolId": "Semgrep",
41784110
"patterns": [
@@ -7218,6 +7150,13 @@
72187150
{
72197151
"patternId": "Semgrep_yaml_spring_rule-SpringActuatorFullyEnabled"
72207152
}
7153+
],
7154+
"exclude": [
7155+
"bench/drivers/c/bench_windows.c",
7156+
"tests/fixtures/c/*win*.c",
7157+
"tests/fixtures/c/test_named_pipe.c",
7158+
"tests/run-windows-bench.sh",
7159+
"vendor-to-netdata.sh"
72217160
]
72227161
},
72237162
{

.github/codeql.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ query-filters:
1111
# no current alerts for them, or when the query is fixed in the same change.
1212
- exclude:
1313
id:
14-
- cpp/constant-comparison
1514
- cpp/poorly-documented-function
1615
- cpp/redundant-null-check-simple
17-
- cpp/toctou-race-condition
18-
- cpp/unused-local-variable
19-
- cpp/unused-static-function
20-
- go/incorrect-integer-conversion
21-
- go/unhandled-writable-file-close
22-
- go/useless-assignment-to-local
2316
- rust/unused-variable
2417

2518
paths:

.github/workflows/codacy-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,4 @@ jobs:
131131
CODACY_STATUS: ${{ steps.codacy.outputs.status }}
132132
run: |
133133
echo "Codacy local analysis reported findings or non-fatal tool results with status ${CODACY_STATUS}; SARIF was generated for review." >&2
134+
exit 1

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ jobs:
151151
go vet ./...
152152
153153
- name: Run Staticcheck
154-
continue-on-error: true
155154
working-directory: ${{ matrix.module }}
156155
run: '"$(go env GOPATH)/bin/staticcheck" ./...'
157156

@@ -168,7 +167,7 @@ jobs:
168167
-quiet \
169168
-fmt sarif \
170169
-out gosec.sarif \
171-
-exclude=G103,G104,G115,G304,G306,G404,G703 \
170+
-exclude=G404 \
172171
./...
173172
status=$?
174173
echo "status=$status" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)