Files
gitleaks/cmd/generate/config/rules
bplaxco d29ee55171 Reduce aws-access-token false positives (#1876)
* Adjust aws-access-token regex

AWS Access Key IDs are [base32 encoded][1] so the numerical values here
will [only be 2-7][2]

[1]: https://medium.com/@TalBeerySec/a-short-note-on-aws-key-id-f88cc4317489
[2]: https://en.wikipedia.org/wiki/Base32#Base_32_Encoding_with_Extended_Hex_Alphabet_per_%C2%A77:~:text=It%20uses%20an%20alphabet%20of%20A%E2%80%93Z%2C%20followed%20by%202%E2%80%937

* Update config/gitleaks.toml during build and test

Summary:

- Add `config/gitleaks.toml` make target
- Make it a dep of `build` and `test`
- Update CONTRIBUTING.md to reference the new target

Reason: Makes dev easier because you can just tweak the code and run
`make test` without an extra step.

* Resolve lint issues in cmd/diagnostics.go

```
$ golangci-lint run cmd/
cmd/diagnostics.go:128:10: Error return value of `f.Close` is not checked (errcheck)
                f.Close()
                       ^
cmd/diagnostics.go:191:10: Error return value of `f.Close` is not checked (errcheck)
                f.Close()
                       ^
2 issues:
* errcheck: 2
```
2025-05-27 09:37:52 -05:00
..
2024-10-04 19:39:53 -05:00
2025-01-22 19:15:25 -06:00
2024-10-22 08:23:47 -05:00
2024-10-06 07:28:47 -05:00
2025-02-19 08:02:35 -06:00

package rules

import (
	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
	"github.com/zricethezav/gitleaks/v8/config"
)

func ReadMe() *config.Rule {
	// define rule
	r := config.Rule{
		RuleID:      "readme-api-token",
		Description: "Detected a Readme API token, risking unauthorized documentation management and content exposure.",
		Regex:       utils.GenerateUniqueTokenRegex(`rdme_[a-z0-9]{70}`, false),
		Entropy:     2,
		Keywords: []string{
			"rdme_",
		},
	}

	// validate
	tps := utils.GenerateSampleSecrets("api-token", "rdme_"+secrets.NewSecret(utils.AlphaNumeric("70")))

	fps := []string{
		`const API_KEY = 'rdme_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';`,
	}
	return utils.Validate(r, tps, fps)
}