CI(lint): Add gosec exclusion rules to fix lint jobs#715
Merged
Conversation
Signed-off-by: vg006 <devvg006@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #715 +/- ##
=========================================
- Coverage 10.99% 7.24% -3.75%
=========================================
Files 173 260 +87
Lines 8671 12913 +4242
=========================================
- Hits 953 935 -18
- Misses 7612 11870 +4258
- Partials 106 108 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
qcserestipy
approved these changes
Feb 26, 2026
Collaborator
There was a problem hiding this comment.
Thank you for looking into it in so much detail! LGTM. I like the inline comments for ignoring gosec issues. I think it is better than passing it generally to gosec such as gosec -exclude=G115 ./... because it makes auditable where the issues are coming from.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #711
This PR aims to fix the failure of the
lintjob in the release pipeline with updatedgoseclinter rules.Problem
The
lintjob fails only because of issues identified by thegoseclinter, which updated its policies and checks strictly in the latest release last week.So it arises multiple issues, notably
G101: Look for hard coded credentialsG115: Potential integer overflow when converting between integer typesG117: Potential exposure of secrets in values marshaled by JSON/YAML/XML/TOMLG703: Path traversal via taint analysisHere, most of the issues are risk-free and false positives and can be ignored; the reason is explained below.
Solution
Note that the
golangci-lintusually packaged and released with the latest versions of multiple linters & formatters everytime.Similarly in its latest version
v2.10(changelog), it is packaged with the latest version ofgosec(changelog) which adds a few rules including the above listed. (ref)Also
golangci-lintdoesn't provide a way to pin particular version of a specific linter, which is neither a good thing too.So obviously, with the
golangci-lintof versionv2.10and above will continue to fail. As the failure is only due togosecand not because ofgolangci-lint, it is good to updategoseclinter rules as suggested above, rather than rolling back to or pinning to specific version ofgolangci-lint.I have tested the lint job with multiple versions of
golangci-lintusing dagger locally and here are the reports.Changes
.golangci-lint.yamlfile is updated with newgosecrules that exclude the running on test files (_test.goand files undertestdir), which eliminates numerousG101andG117issues.G703andG115issues, which are false positives, so they are ignored using thenosecinline rule.// #nosec <Rule> - <Justification>With this configuration, there are no issues from
gosecand thelintjob will pass. The results of the local tests can be seen hereConclusion
As the failure is only due to
gosecand not because ofgolangci-lint, it is good to updategoseclinter rules as suggested above, rather than rolling back to or pinning to specific version ofgolangci-lint.cc: @bupd @NucleoFusion @qcserestipy