refactor: fix gosec lint issues#1586
Merged
alexandear merged 2 commits intomgechev:masterfrom Nov 22, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables the gosec security linter and addresses various security-related code issues it identified, focusing on proper error handling and secure file permissions.
Key changes:
- Added error checking for previously ignored function returns across test files and formatters
- Updated file and directory permissions to more restrictive values (0o750 for directories, 0o600 for files)
- Added appropriate
//nolint:gosecsuppressions for intentional use of MD5 (for non-cryptographic hashing) - Configured
.golangci.ymlto exclude gosec checks from rule files where TypeCheck() error handling is deferred
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/utils_test.go | Changed assertSuccess/assertFailures to use t.Errorf instead of returning errors; updated .git directory permissions to 0o750 |
| test/golint_test.go | Removed error handling wrapper since assertFailures no longer returns an error |
| test/file_filter_test.go | Added error checking for cfg.Initialize() calls |
| rule/time_equal.go | Removed unused TypeCheck() error check (gosec excluded via config) |
| rule/epoch_naming.go | Added proper TypeCheck() error handling with internal failure reporting |
| logging/logger_test.go | Added error checking in cleanup functions for os.Remove() |
| lint/linter_test.go | Updated directory permissions to 0o750 and file permissions to 0o600 |
| internal/astutils/ast_utils.go | Added gosec suppressions for MD5 usage and ignored Fprint error (writes to buffer) |
| formatter/sarif.go | Added error handling for PrettyWrite() |
| formatter/friendly.go | Explicitly ignored errors from tabwriter operations (writes to buffer) |
| cli/main_test.go | Added error checking for MkdirAll and WriteFile operations |
| .golangci.yml | Enabled gosec linter with exclusions for rule files and G304 (file inclusion) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f3e205a to
bbd6f64
Compare
ccoVeille
reviewed
Nov 20, 2025
bbd6f64 to
0158306
Compare
ccoVeille
approved these changes
Nov 22, 2025
Collaborator
Author
|
@ccoVeille thank you for review. |
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.
This PR enables the
goseclinter and fixes lint issues.The issue about adding an error check to
file.Pkg.TypeCheck()is disabled for now. Because it's not easy to fix and should be done carefully. See #1277 and #1310.Full list of gosec issues