From 4113fc7c4b1dfa5d26055f2b7d88fce24c7e5973 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Wed, 10 Nov 2021 04:28:46 -0600 Subject: [PATCH] Ignore false-positive gosec G307 linting errors 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 atc0005/bridge#161 refs golangci/golangci-lint#2299 --- checksums/checksums.go | 4 ++++ paths/paths.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/checksums/checksums.go b/checksums/checksums.go index e131ebf..dd8c3e9 100644 --- a/checksums/checksums.go +++ b/checksums/checksums.go @@ -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( diff --git a/paths/paths.go b/paths/paths.go index 9963289..5d73958 100644 --- a/paths/paths.go +++ b/paths/paths.go @@ -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( @@ -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(