[go-fan] Go Module Review: securego/gosec #21925
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-03-21T07:23:23.800Z.
|
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.
-
🐹 Go Fan Report: securego/gosec
Hot off the press!
gosec/v2released v2.25.0 yesterday (2026-03-19) — and this project is running three different versions across go.mod, the Makefile, and CI. Time to dig in!Module Overview
gosec is a Go security scanner that inspects source code by analyzing the Go AST and SSA code representation. It detects common security vulnerabilities across categories: hardcoded credentials, injection risks, file handling, crypto weaknesses, blocklisted imports, Go-specific correctness checks, and taint analysis for SQL/command/path/SSRF/XSS vulnerabilities.
Current Usage in gh-aw
tools.govia blank import for go.mod pinningmake security-gosecand.github/workflows/security-scan.ymlgosec-report.json) locally, SARIF (gosec-results.sarif) uploaded to GitHub code scanningCLI invocation:
Suppression Annotations (46 total in non-test files)
isPathWithinDir()exec.LookPath+ separate args$\{\{ }}templates)filepath.Clean+ prefix checkAnnotation Style Mix
The codebase uses two different suppression styles:
//nolint:gosec(golangci-lint style) — in 2 workflow compiler files#nosec G304 -- justification(native gosec style) — in ~25 filesSince gosec is disabled in golangci-lint (due to config bugs),
//nolint:gosecannotations have no effect on the actual gosec scanner. Only#nosecannotations are respected by the standalonegosectool.Research Findings
🚨 Version Inconsistency — Three Different Versions!
go.modMakefile(security-gosectarget).github/workflows/security-scan.ymlThe CI security scan is running
v2.22.11— two minor versions behind go.mod. This means 18+ months of bug fixes, false-positive reductions, and new rules are being missed in the security scan that uploads SARIF to GitHub code scanning.New in v2.25.0 (vs v2.24.7 in go.mod)
text/template(new)grpcdependency bumped 1.75.0 → 1.79.3Improvement Opportunities
🏃 Quick Wins
1. Unify gosec version across go.mod, Makefile, and CI
The Makefile installs
gosec@v2.23.0and CI installs@v2.22.11, but go.mod pinsv2.24.7. This defeats the purpose of pinning tools in go.mod. Fix: usego install github.com/securego/gosec/v2/cmd/gosec@$(go list -m -f '\{\{.Version}}' github.com/securego/gosec/v2)or simply drop the hardcoded version sogo installrespects the module graph.2. Upgrade to v2.25.0
New false-positive fixes for G115 (guarded int64-to-byte conversions) could reduce some of the 6 existing G115
#nosecannotations. Also fixes taint analysis panics which could affect scan stability.3. Remove redundant
//nolint:gosecannotationsIn
pkg/workflow/safe_outputs_config_helpers.goandpkg/workflow/compiler_safe_outputs_steps.go,//nolint:gosecannotations are present but gosec is disabled in golangci-lint — these annotations do nothing. They should either be converted to#nosec(for the standalone scanner) or removed.4. Remove redundant G101
#nosecannotationsG101 is globally excluded via
-exclude=G101, so the 6#nosec G101annotations incopilot_engine_execution.goare redundant. They can be removed or kept for documentation clarity.✨ Feature Opportunities
5. Evaluate new rules G124, G708, G709
The project uses HTTP handlers and YAML/template processing. These new rules deserve evaluation:
HttpOnly/Secureflags set?text/templatewith user-controlled templates? (Risk of SSTI)gob,encoding/xml)?These rules are not yet excluded globally, so they'll start firing on the first v2.25.0 scan.
6. Path-based exclusions for targeted suppression
gosec v2 supports
--exclude-rules="path_regex:G204,G304"and a config file format. Instead of globally excluding G204 and G304 for the entire codebase, these could be scoped to specific files where they're legitimately needed (pkg/parser/remote_fetch.go,pkg/cli/*.go).7. AI-assisted fix suggestions
gosec now supports
claude-sonnet-4-0via-ai-api-providerflag for generating AI-assisted security fix suggestions. This could be integrated into a daily security workflow to auto-suggest fixes for any new findings.📐 Best Practice Alignment
8. Standardize suppression annotation style
Use
#nosec GRule -- justification(native gosec format) consistently. The//nolint:gosecstyle works only when gosec runs through golangci-lint (which it doesn't here). The project mostly already follows#nosec— just 2 files need updating.9. gosec re-enablement in golangci-lint
The
.golangci.ymlcomment says gosec was disabled due to "configuration bugs in v2". With v2.25.0, many configuration issues have been fixed. It may be worth re-testing gosec as a golangci-lint linter with thelinters-settings.gosec.excludeconfig to unify tooling.Recommendations (Prioritized)
security-scan.ymlto use go.mod's gosec version — currently v2.22.11 in CI vs v2.24.7 in go.mod means CI misses 1.5 years of improvements//nolint:gosecannotations to#nosecin workflow compiler files#nosec G101annotations (already globally excluded)Next Steps
text/templatewith user-controlled input (G708 relevance)Module summary saved to:
scratchpad/mods/gosec.mdReferences: §23332930451
Beta Was this translation helpful? Give feedback.
All reactions