[go-fan] Go Module Review: securego/gosec #23848
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Go Fan. A newer discussion is available at Discussion #24035. |
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
github.com/securego/gosec/v2is the Go security static analysis tool that scans Go AST and SSA code for security vulnerabilities. It's a cornerstone of the security posture here — run daily in CI and available locally viamake security-gosec. Version v2.25.0 was released on 2026-03-19, making it the most recently updated direct dependency and today's review target.Module Overview
gosec inspects Go source for issues across seven rule families:
Current Usage in gh-aw
gosec is integrated as a CLI tool dependency via the Go tools pattern (
tools.goblank import with//go:build tools), tracked at v2.25.0 ingo.mod.make security-gosec(JSON output) and daily GitHub Actions (SARIF → GitHub Security)G101, G115, G204, G602, G301, G302, G304, G306//nolint:gosec // G101annotations across workflow compiler filesResearch Findings
Recent Updates (v2.22.11 → v2.25.0)
The CI workflow currently installs v2.22.11 and the Makefile installs v2.23.0 — both behind the v2.25.0 tracked in
go.mod. Notable changes in the gap:text/template--exclude-rulespath-based exclusion CLI flag addedBest Practices
//gosec:disable G101 -- justificationis the preferred suppression format; justification text is captured in SARIF output when using-track-suppressionsgosec.json) can centralize all exclusions, reducing drift across multiple invocation points--exclude-rulessupports path-specific rule exclusions natively, no need to maintain parallel lists in golangci-lintImprovement Opportunities
🚨 Critical Fix
Version mismatch across all three invocation points:
go.modMakefile(security-gosec).github/workflows/security-scan.ymlDevelopers running
make security-gosecand CI are scanning with different rules than what's tracked. The new G124/G708/G709 rules and G118 false-positive fixes are absent in both environments. Fix: update both pinned versions tov2.25.0.🏃 Quick Wins
//nolint:gosecannotations are ineffective for direct gosec runs.The project uses
//nolint:gosec // G101: False positive...in 5 places (checkout_manager.go ×3, compiler_safe_outputs_steps.go, safe_outputs_config_helpers.go). Since gosec is disabled in golangci-lint and run directly,//nolint:gosechas no effect on the direct binary — it's a golangci-lint directive. G101 is currently covered by the global-exclude=G101flag, but if that exclusion is ever tightened, these inline suppressions silently won't work.Switch to gosec's native format so suppressions are tracked in SARIF:
✨ Feature Opportunities
Centralize exclusions with a gosec config file.
The exclusion list is duplicated in three places with a fragile "keep in sync" comment:
.golangci.ymllinters-settings.gosec.excludeMakefile-exclude=G101,G115,G204,G602,G301,G302,G304,G306.github/workflows/security-scan.ymlsame-exclude=listUse a
gosec.jsonconfig file and pass-conf gosec.jsonin both invocations. Theexclude-rulesblock in that config can also replace the 20+ individual path-specific exclusion entries currently in.golangci.yml.Use path-based exclusions for test file patterns.
The new
--exclude-rulesfeature (or config equivalent) can replace repetitive patterns like:{ "exclude-rules": [ { "path": ".*_test\\.go", "rules": ["G104", "G306"] }, { "path": "pkg/cli/actionlint\\.go", "rules": ["G204"] }, { "path": "pkg/cli/logs_download\\.go", "rules": ["G305", "G110"] } ] }📐 Best Practice Alignment
Review new G7xx taint analysis coverage.
v2.25.0 brings G124, G708, G709 which aren't in the current global exclusion list. The daily CI scan will now produce findings for these rules. Worth auditing the SARIF results to determine whether any are real issues (HTTP cookies, template injection, unsafe deserialization) or if they need path-specific suppression.
Consider
-testsflag.Currently gosec doesn't scan test files (
-testsis not passed). The.golangci.ymlhas many test-file gosec exclusions, but these only apply to the golangci-lint path (where gosec is disabled). Enabling-testsin direct gosec runs with appropriate path exclusions would give full coverage.Recommendations
gosec@v2.25.0to match go.mod//nolint:gosecwith//gosec:disable G101 -- justificationfor the 5 inline suppressionsgosec.jsonconfig file and consolidate the three exclusion lists into one-testsflag with path-based test exclusions for full coverageNext Steps
Module summary saved to:
scratchpad/mods/gosec.mdReferences:
Beta Was this translation helpful? Give feedback.
All reactions