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 #161
refs golangci/golangci-lint#2299
  • Loading branch information
atc0005 committed Nov 10, 2021
1 parent 0c72246 commit 3f4b259
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions checksums/checksums.go
Expand Up @@ -67,6 +67,10 @@ func GenerateCheckSum(file string) (SHA256Checksum, error) {
}

// Note the duplicate f.Close() call at end of function and why
//
// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func() {
if err := f.Close(); err != nil {
log.Printf(
Expand Down
5 changes: 5 additions & 0 deletions cmd/bridge/prune.go
Expand Up @@ -30,6 +30,11 @@ func pruneSubcommand(appConfig *config.Config) error {
if err != nil {
log.Fatal(err)
}

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
//
// NOTE: We're not manipulating contents for this file, so relying solely
// on a defer statement to close the file should be sufficient?
defer func() {
Expand Down
4 changes: 4 additions & 0 deletions matches/matches.go
Expand Up @@ -796,6 +796,10 @@ func (fi FileChecksumIndex) WriteFileMatchesCSV(filename string, blankLineBetwee
if err != nil {
return err
}

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func() {
if err := file.Close(); err != nil {
log.Printf(
Expand Down
8 changes: 8 additions & 0 deletions paths/paths.go
Expand Up @@ -204,6 +204,10 @@ func BackupFile(sourceFilename string, destinationDirectory string) error {
return fmt.Errorf("unable to create new backup file %q: %s",
destinationFile, err)
}

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func() {
if err := destinationFileHandle.Close(); err != nil {
log.Printf(
Expand Down Expand Up @@ -233,6 +237,10 @@ func BackupFile(sourceFilename string, destinationDirectory string) error {
return fmt.Errorf("unable to open source file %q in order to create backup copy: %s",
sourceFilename, err)
}

// #nosec G307
// Believed to be a false-positive from recent gosec release
// https://github.com/securego/gosec/issues/714
defer func() {
if err := sourceFileHandle.Close(); err != nil {
log.Printf(
Expand Down

0 comments on commit 3f4b259

Please sign in to comment.