Skip to content

Commit

Permalink
Ignore false-positive gosec G307 linting errors
Browse files Browse the repository at this point in the history
Issues reported after upgrading golangci-lint to v1.43.0.
gosec was updated in that version from v2.8.1 to v2.9.1.

refs #234
refs golangci/golangci-lint#2299
  • Loading branch information
atc0005 committed Nov 8, 2021
1 parent f87ab3f commit fb9dc65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/list-emails/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func main() {
return
}

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func(filename string) {
if err := cfg.LogFileHandle.Close(); err != nil {
// Ignore "file already closed" errors
Expand Down
4 changes: 4 additions & 0 deletions internal/config/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (c *Config) readConfigFile(configFile ...string) ([]byte, error) {
continue
}
c.Log.Debug().Str("config_file", file).Msg("Config file opened")

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func() {
if err := fh.Close(); err != nil {
// Ignore "file already closed" errors
Expand Down
3 changes: 3 additions & 0 deletions internal/files/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func GenerateReport(reportData ReportData, reportDirectory string, logger zerolo

logger.Debug().Msg("Successfully opened report file for updates")

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func(filename string) {
if err := f.Close(); err != nil {
// Ignore "file already closed" errors
Expand Down

0 comments on commit fb9dc65

Please sign in to comment.