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 #362
refs golangci/golangci-lint#2299
  • Loading branch information
atc0005 committed Nov 10, 2021
1 parent 8824ea3 commit 71c244c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func NewConfig(appVersion string) (*Config, error) {
if err != nil {
return nil, fmt.Errorf("unable to open config file: %v", err)
}

// #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
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func TestLoadConfigFileTemplate(t *testing.T) {
} else {
t.Log("Successfully opened config file", exampleConfigFile)
}

// #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

0 comments on commit 71c244c

Please sign in to comment.