diff --git a/.golangci.toml b/.golangci.toml index 6c81374..5cd887f 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -102,7 +102,16 @@ excludes = [ 'G304', 'G307', 'G702', - 'G706' + 'G706', +] +includes = [ + 'G501', # Import blocklist: crypto/md5 + 'G502', # Import blocklist: crypto/des + 'G503', # Import blocklist: crypto/rc4 + 'G504', # Import blocklist: net/http/cgi + 'G505', # Import blocklist: crypto/sha1 + 'G506', # Import blocklist: golang.org/x/crypto/md4 + 'G507', # Import blocklist: golang.org/x/crypto/ripemd160 ] [linters.settings.gosec.config] diff --git a/mage/main.go b/mage/main.go index 49df3d3..393f97d 100644 --- a/mage/main.go +++ b/mage/main.go @@ -3,7 +3,7 @@ package mage import ( "context" - "crypto/sha256" + "crypto/sha3" "errors" "flag" "fmt" @@ -682,13 +682,13 @@ func ExeName(goCmd, cacheDir string, files []string) (string, error) { } // hash the mainfile template to ensure if it gets updated, we make a new // binary. - hashes = append(hashes, fmt.Sprintf("%x", sha256.Sum256([]byte(mageMainfileTplString)))) + hashes = append(hashes, fmt.Sprintf("%x", sha3.Sum256([]byte(mageMainfileTplString)))) sort.Strings(hashes) ver, err := internal.OutputDebug(goCmd, "version") if err != nil { return "", err } - hash := sha256.Sum256([]byte(strings.Join(hashes, "") + magicRebuildKey + ver)) + hash := sha3.Sum256([]byte(strings.Join(hashes, "") + magicRebuildKey + ver)) filename := fmt.Sprintf("%x", hash) out := filepath.Join(cacheDir, filename) @@ -705,7 +705,7 @@ func hashFile(fn string) (string, error) { } defer f.Close() - h := sha256.New() + h := sha3.New256() if _, err := io.Copy(h, f); err != nil { return "", fmt.Errorf("can't write data to hash: %w", err) } diff --git a/mg/fn_test.go b/mg/fn_test.go index 95f2b58..697bf5c 100644 --- a/mg/fn_test.go +++ b/mg/fn_test.go @@ -52,7 +52,7 @@ func TestFuncCheck(t *testing.T) { t.Error("func is not on a namespace") } - hasContext, isNamespace, err = checkF(Foo.Bare, nil) + _, _, err = checkF(Foo.Bare, nil) if err != nil { t.Error(err) }