Files
gitleaks/cmd/generate/config/rules
Richard Gomez 3fa5a3a954 Minor false positive improvements (#1758)
* feat(generic): add 'keypress' to allowlist

* feat(privatekey): ignore empty/impossible matches

* feat(config): ignore 'secrets' that are file paths

* fix(sentry): handle special character at end
Prevent common test error of 'Failed to Validate. True positive was not detected by regex.' because the generated value didn't play nicely with word boundary.
2025-02-19 07:46:09 -06: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

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)
}