diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01c6b5e9..08331123 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi RuleID: "beamer-api-token", // Regex capture group for the actual secret - + // Regex used for detecting secrets. See regex section below for more details @@ -95,7 +95,7 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi the `rules.Beamer(),` in `main()`. Try and keep this alphabetically pretty please. -1. Run `go generate ./...` +1. Run `make config/gitleaks.toml` 1. Check out your new rules in `config/gitleaks.toml` and see if everything looks good. diff --git a/Makefile b/Makefile index 81afc119..3f06d461 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,16 @@ test-cover: format: go fmt ./... -test: format +test: config/gitleaks.toml format go test -v ./... --race $(PKG) -build: format +build: config/gitleaks.toml format go mod tidy go build $(LDFLAGS) clean: find . -type f -name '*.got.*' -delete find . -type f -name '*.out' -delete + +config/gitleaks.toml: $(wildcard cmd/generate/config/**/*) + go generate ./... diff --git a/cmd/diagnostics.go b/cmd/diagnostics.go index 64eacd13..f8474c63 100644 --- a/cmd/diagnostics.go +++ b/cmd/diagnostics.go @@ -125,7 +125,7 @@ func (dm *DiagnosticsManager) StartCPUProfile() error { } if err := pprof.StartCPUProfile(f); err != nil { - f.Close() + _ = f.Close() return fmt.Errorf("could not start CPU profile: %w", err) } @@ -188,7 +188,7 @@ func (dm *DiagnosticsManager) StartTraceProfile() error { } if err := trace.Start(f); err != nil { - f.Close() + _ = f.Close() return fmt.Errorf("could not start trace profile: %w", err) } diff --git a/cmd/generate/config/rules/aws.go b/cmd/generate/config/rules/aws.go index 44717e3a..6a27669b 100644 --- a/cmd/generate/config/rules/aws.go +++ b/cmd/generate/config/rules/aws.go @@ -12,7 +12,7 @@ func AWS() *config.Rule { r := config.Rule{ RuleID: "aws-access-token", Description: "Identified a pattern that may indicate AWS credentials, risking unauthorized cloud resource access and data breaches on AWS platforms.", - Regex: regexp.MustCompile(`\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16})\b`), + Regex: regexp.MustCompile(`\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\b`), Entropy: 3, Keywords: []string{ // https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids diff --git a/config/gitleaks.toml b/config/gitleaks.toml index 92a06a31..274bfdcc 100644 --- a/config/gitleaks.toml +++ b/config/gitleaks.toml @@ -167,7 +167,7 @@ keywords = [ [[rules]] id = "aws-access-token" description = "Identified a pattern that may indicate AWS credentials, risking unauthorized cloud resource access and data breaches on AWS platforms." -regex = '''\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16})\b''' +regex = '''\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\b''' entropy = 3 keywords = [ "a3t",