gitleaks/gitleaks

Creating Composite Rule Errors

Open

#1932 opened on Aug 18, 2025

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Go (26,970 stars) (2,048 forks)batch import
bugenhancementhelp wanted

Description

Describe the bug

I tried to define a new composite rule using code but the gitleaks generator always throws the following error:

4:02PM ERR required rule not found in config path= rule-id=anthropic-api-key

I can add any rule in ruleId and get the same result so i tried it with a rule that is initialized before the aws one.

To Reproduce Steps to reproduce the behavior:

	// define 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-Z2-7]{16})\b`),
		Entropy:     3,
		RequiredRules: []*config.Required{
			{RuleID: "anthropic-api-key", WithinLines: &maxLines},
		},
		Keywords: []string{
			// https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids
			"A3T",  // todo: might not be a valid AWS token
			"AKIA", // Access key
			"ASIA", // Temporary (AWS STS) access key
			"ABIA", // AWS STS service bearer token
			"ACCA", // Context-specific credential
		},
		Allowlists: []*config.Allowlist{
			{
				Regexes: []*regexp.Regexp{
					regexp.MustCompile(`.+EXAMPLE$`),
				},
				StopWords: []string{
					"AKIAIOSFODNN7EXAMPLE",
					"AKIA222222222EXAMPLE",
				},
			},
		},
	}

Expected behavior A Composite Rule gets created

Screenshots

Additional context Add any other context about the problem here.

cc @zricethezav

Contributor guide