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 4113fc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions checksums/checksums.go
Original file line number Diff line number Diff line change
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
8 changes: 8 additions & 0 deletions paths/paths.go
Original file line number Diff line number Diff line change
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 4113fc7

Please sign in to comment.