From 23e65b25202040829873e6dcbef3abcb0dc7ac0e Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Tue, 9 Nov 2021 06:37:52 -0600 Subject: [PATCH 1/2] 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/go-lockss#97 refs golangci/golangci-lint#2299 --- internal/lockss/load.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/lockss/load.go b/internal/lockss/load.go index 4940842..7e7503f 100644 --- a/internal/lockss/load.go +++ b/internal/lockss/load.go @@ -78,6 +78,10 @@ func (c *Config) loadFromPropsFile(filename string) (*Config, error) { if err != nil { return nil, fmt.Errorf("error occurred opening file: %w", 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 { logger.Printf( @@ -287,6 +291,10 @@ func getLocalDaemonConfig(filename string, ignorePrefix string) (daemonConfig, e 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 From dd697e00841e0b7d4705ea5d427237b0eff1ca66 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Tue, 9 Nov 2021 06:39:20 -0600 Subject: [PATCH 2/2] Ignore gocritic `regexp.Compile()` linting error I am already checking for the regex compile error and immediately returning the error if it occurs. I expect that the error wrapping I am providing will be more readable to users than an intentional panic induced stack trace would be. refs GH-96 --- internal/lockss/peers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/lockss/peers.go b/internal/lockss/peers.go index 821f916..53f9d15 100644 --- a/internal/lockss/peers.go +++ b/internal/lockss/peers.go @@ -79,6 +79,9 @@ func (l IDInitialV3Peers) List() ([]V3Peer, error) { ) } + // nolint:gocritic + // refs https://github.com/atc0005/go-lockss/issues/96 + // refs https://github.com/go-critic/go-critic/issues/209 re, regExCompileErr := regexp.Compile(v3PeerRegex) if regExCompileErr != nil { return nil, fmt.Errorf("error compiling regex: %w", regExCompileErr)