Skip to content

Add golangci-lint gate and expand audit tooling - #5633

Merged
norman-abramovitz merged 8 commits into
cloudfoundry:developfrom
nabramovitz:norm/chore/lint-tooling
Jul 12, 2026
Merged

Add golangci-lint gate and expand audit tooling#5633
norman-abramovitz merged 8 commits into
cloudfoundry:developfrom
nabramovitz:norm/chore/lint-tooling

Conversation

@nabramovitz

@nabramovitz nabramovitz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

  • make check lint (and the standalone lint verb) now run golangci-lint (errcheck, staticcheck, unused, ineffassign) over both Go modules — src/jetstream and the nested src/jetstream/api, which no scanner covered before.
  • Audit tooling updates:
    • trivy: replace the deprecated --security-checks vuln,config with --scanners vuln,misconfig
    • make audit backend also scans the api module (gosec + govulncheck)
    • new opt-in modes, deliberately off the default path: audit tests (gosec incl. test files + #nosec report), audit tree (trivy over the whole tree, covering the deploy/ Dockerfiles and helm chart), audit history (gitleaks over full git history), audit licenses (osv-scanner license report)
    • ZIZMOR_FLAGS passthrough for audit actions (e.g. --persona=auditor)
  • Docs refreshed: tool and command tables in docs/developer-environment.md and an explanation of why the new modes stay off the default path.
  • The new gate merges green: every golangci-lint finding in both modules is resolved.

Lint findings resolved

The uncapped baseline was 705 findings. Two policy exclusions are set in src/jetstream/.golangci.yml with reasons in the file: errcheck skips _test.go (teardown-call noise, 289 findings), and staticcheck's ST1005 error-string style rule is off (error text is user-facing API/log surface, 230 findings). The remaining 186 were fixed:

  • errcheck (74) — echo handler results returned to echo, logout/cleanup paths log-and-continue, setup prerequisites propagate, cleanup calls explicitly acknowledged.
  • staticcheck (66) — io/ioutil modernized, if/else chains to tagged switches, redundant conversions dropped. Two documented suppressions on the CFB cipher calls: persisted tokens and client secrets are CFB-encrypted, so changing modes needs a versioned re-encryption migration (possible follow-up), not a drop-in swap.
  • unused (33) — 32 dead symbols deleted (~213 lines), each verified by repo-wide search; one kept with a comment (referenced by the parked sonobuoy analyzer file).
  • ineffassign (15) — including three real bugs: shadowed errors in local-user INSERT/UPDATE made zero-row writes return success; metrics proxy handlers swallowed request-build errors and forwarded nil responses; a failed session creation still attempted the session save. Three test assertions that could never fail are also unmasked.

Verified with the full gate: frontend lint + 3094 unit tests + production build + all backend Go tests green.

check lint and the standalone lint verb now run golangci-lint
(errcheck, staticcheck, unused, ineffassign) over both Go modules,
with an upfront installed-tool check. The standalone verb reuses
the check.lint recipe instead of duplicating it.
- trivy: replace deprecated --security-checks vuln,config with
  --scanners vuln,misconfig
- audit backend now also scans the nested src/jetstream/api module
  (gosec + govulncheck)
- new opt-in modes kept off the default path: tests (gosec incl.
  _test.go + #nosec suppression report), tree (trivy full-tree incl.
  deploy/ Dockerfiles and helm chart), history (gitleaks full git
  history), licenses (osv-scanner license report)
- ZIZMOR_FLAGS passthrough for audit actions (e.g. --persona=auditor)

Bare 'make audit' still runs exactly the original five scanners.
Refresh the tool and command tables (zizmor, osv-scanner, gitleaks
were undocumented) and explain why the tests/tree/history/licenses
audit modes stay off the default path.
Resolve the errcheck findings surfaced by the new lint gate across
plugins, datastore, repositories, crypto, and the api module:
propagate where the enclosing function returns error, log where
aborting would change behavior (session affinity, streaming), and
explicitly acknowledge genuinely-ignorable cleanup calls. Also fixes
a latent bug where analysis dbStore.Save results were silently
dropped.
Two deliberate policy exclusions, both documented in the file:
errcheck skips _test.go (teardown-call noise), and staticcheck
ST1005 is off because jetstream error strings are user-facing
surface (API responses, logs) where mass-rewording is behavioral
churn. Everything else stays on.
Second errcheck sweep: echo handler results now returned to echo,
logout/cleanup paths log-and-continue instead of silently dropping
failures, setup prerequisites propagate, and remaining rows/Body
Close teardowns are explicitly acknowledged. errcheck is now clean
across both modules.
Replace deprecated io/ioutil calls, convert if/else chains to
tagged switches, drop redundant conversions and comparisons, and
make the CF auto-register error-discard explicit. The two CFB
cipher deprecation sites carry documented suppressions: persisted
tokens and client secrets are CFB-encrypted, so changing modes
needs a versioned re-encryption migration, not a drop-in swap.
unused: delete 32 unreferenced symbols (~213 lines) across both
modules, each verified by repo-wide search; popeyeConfig stays with
a documented suppression (referenced by the parked sonobuoy file).

ineffassign fixes include three real defects: shadowed errors in
local-user INSERT/UPDATE made zero-row writes return success,
metrics proxy handlers swallowed request-build errors and forwarded
nil responses, and a failed session creation still attempted the
session save. Also unmasks three test assertions that could never
fail.
@nabramovitz
nabramovitz marked this pull request as ready for review July 12, 2026 10:00

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz
norman-abramovitz merged commit 63fec3b into cloudfoundry:develop Jul 12, 2026
21 checks passed
@nabramovitz
nabramovitz deleted the norm/chore/lint-tooling branch July 12, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants