From a1f1a1c699252393b7d48948f70c76585ad4583f Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Wed, 10 Nov 2021 05:07:16 -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/brick#261 refs golangci/golangci-lint#2299 --- internal/config/config.go | 4 ++++ internal/files/process.go | 4 ++++ internal/fileutils/contains.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index cfa8a56a..7791a147 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -246,6 +246,10 @@ func NewConfig() (*Config, error) { 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 diff --git a/internal/files/process.go b/internal/files/process.go index 1f3a76b4..8615ec2f 100644 --- a/internal/files/process.go +++ b/internal/files/process.go @@ -593,6 +593,10 @@ func appendToFile(entry fileEntry, tmpl *template.Template, filename string, per opErr, ) } + + // #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 diff --git a/internal/fileutils/contains.go b/internal/fileutils/contains.go index 0f493937..16b2162b 100644 --- a/internal/fileutils/contains.go +++ b/internal/fileutils/contains.go @@ -53,6 +53,10 @@ func HasLine(searchTerm string, ignorePrefix string, filename string) (bool, err err, ) } + + // #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 { // Ignore "file already closed" errors