gitleaks / gitleaks/gitleaks

Creating Composite Rule Errors

Open
#1,932 2 comments 0 reactions 0 assignees View on GitHub
bug enhancement help wanted
Dominant language
Go
Stars
29.3k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

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

```bash
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:

```go
// 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.