[go-fan] Go Module Review: securego/gosec #17858
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-02-24T07:28:58.145Z.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Today's module review:
github.com/securego/gosec/v2 v2.23.0— selected because it was pushed to GitHub just today (2026-02-23), making it the most recently active direct dependency in the project's go.mod.gosec is the Go security static analysis tool used in gh-aw to scan for security vulnerabilities in source code. It was updated significantly in v2.23.0 with a new taint analysis engine and performance improvements.
Current Usage in gh-aw
gosec is used exclusively as a CLI tool, not as a library API. The dependency in
go.modexists to pin the version for reproducibility._ "github.com/securego/gosec/v2/cmd/gosec"in tools.go)make security-gosecand daily CI scan via.github/workflows/security-scan.yml//nolint:gosecannotations in non-test production codeCurrent gosec invocation flags
Research Findings
Recent Updates (v2.23.0)
The headline feature in v2.23.0 is the taint analysis engine — a significant advancement that tracks user-controlled data flowing through the program to dangerous sinks:
filepath.Walk/WalkDirsymlink TOCTOU race riskstls.VerifyPeerCertificateresumption bypass riskPerformance improvements also landed:
sync.Poolcaching inGetCallInfosync.Oncefor Go version cachingNotable bug fixes:
New CLI feature:
--exclude-rulesflag for fine-grained path-based rule exclusions.Best Practices
--exclude-generatedto skip auto-generated files (already done ✅)--track-suppressionsto include suppressed items in SARIF (already done ✅)Improvement Opportunities
🏃 Quick Wins
1. Fix CI version mismatch (actionable)
.github/workflows/security-scan.ymlinstallsgosec@v2.22.11whilego.modandMakefileboth referencev2.23.0. This means:2. Add G104 path exclusions to reduce inline annotations
logger/logger.goandparser/schedule_fuzzy_scatter.goboth checkhash.Hash.Writeerrors to satisfy G104. The.golangci.ymlexcludes G104 only in_test.gofiles. These two production files could be added as path-based G104 exclusions (aligning with existing pattern), removing the need for inline//nolint:goseccomments.✨ Feature Opportunities
3. Enable taint analysis for exec.Command flows
The codebase has ~20+
exec.Command/exec.CommandContextcalls acrosspkg/cli/andpkg/workflow/. Many are excluded with broad G204 suppression. The new taint analysis engine in v2.23.0 could be used specifically for G703/G705 to check if user-controlled input flows to dangerous sinks — a more precise approach than broad exclusions.4. Leverage
--exclude-rulesflag for precisionThe new
--exclude-rulesflag enables path-based rule exclusions directly in the gosec CLI invocation. Currently the project uses global-exclude=G204which suppresses subprocess checks entirely. Example of more targeted approach:This would catch new G204/G304 violations in new code while still suppressing known-safe ones.
📐 Best Practice Alignment
5. Consolidate exclusion documentation
The project has excellent exclusion docs in
scratchpad/gosec.mdand.golangci.yml, but the actual gosec invocations in Makefile and CI use command-line-excludeflags. Since gosec v2.23.0 supports configuration files (gosec.toml), a config file could centralize all exclusions so Makefile and CI both usegosec -conf gosec.toml— eliminating the drift between them (which this review found).🔧 General Improvements
6. The
.golangci.ymlgosec section is orphanedThe file has extensive
exclude-rulesfor gosec (30+ entries) but gosec is disabled in golangci-lint. This means those exclusion rules in.golangci.ymlare documentation-only and have no runtime effect. A comment noting this explicitly (or a link to where the rules are applied) would help future maintainers avoid confusion.Recommendations
security-scan.ymlto installgosec@v2.23.0logger.go/schedule_fuzzy_scatter.go--exclude-rulesfor path-based G204 precisiongosec.tomlconfig file for centralized exclusion managementNext Steps
security-scan.ymlline 29:gosec@v2.22.11→gosec@v2.23.0.golangci.ymlgosec section and add a note clarifying they are reference-onlymake security-gosecModule summary saved to:
scratchpad/mods/gosec.mdReferences:
Beta Was this translation helpful? Give feedback.
All reactions