gitleaks/gitleaks

Creating Composite Rule Errors

開放

#1,932 建立於 2025年8月18日

 (2 則留言) (0 個反應) (0 位負責人)Go (2,048 個分叉)batch import
bugenhancementhelp wanted

倉庫指標

星標
 (26,970 顆星)
PR 合併指標
 (平均合併 8天 17小時) (30 天內合併 2 個 PR)

描述

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

貢獻者指南