Skip to content

Commit

Permalink
add real (test) standard and restricted keys (#11)
Browse files Browse the repository at this point in the history
### Description:
I just generated keys from Stripe and adjusted the rule.

### Checklist:

* [x] Does your PR pass tests?
* [x] Have you written new tests for your changes?
* [x] Have you lint your code locally prior to submission?

Original: gitleaks#1375
  • Loading branch information
baruchiro committed Mar 28, 2024
1 parent 33e0634 commit b30d2e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions cmd/generate/config/rules/stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ func StripeAccessToken() *config.Rule {
r := config.Rule{
Description: "Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data.",
RuleID: "stripe-access-token",
Regex: generateUniqueTokenRegex(`(sk)_(test|live)_[0-9a-z]{10,32}`, true),
Regex: generateUniqueTokenRegex(`(sk|rk)_(test|live|prod)_[0-9a-z]{10,99}`, true),
Keywords: []string{
"sk_test",
"sk_live",
"sk_prod",
"rk_test",
"rk_live",
"rk_prod",
},
SecretGroup: 1,
}

// validate
tps := []string{"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
tps := []string{
"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\"",
"sk_test_51OuEMLAlTWGaDypq4P5cuDHbuKeG4tAGPYHJpEXQ7zE8mKK3jkhTFPvCxnSSK5zB5EQZrJsYdsatNmAHGgb0vSKD00GTMSWRHs", // gitleaks:allow
"rk_prod_51OuEMLAlTWGaDypquDn9aZigaJOsa9NR1w1BxZXs9JlYsVVkv5XDu6aLmAxwt5Tgun5WcSwQMKzQyqV16c9iD4sx00BRijuoon", // gitleaks:allow
}
fps := []string{"nonMatchingToken := \"task_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
return validate(r, tps, fps)
}
4 changes: 2 additions & 2 deletions config/gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2729,10 +2729,10 @@ keywords = [
[[rules]]
id = "stripe-access-token"
description = "Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data."
regex = '''(?i)\b((sk)_(test|live)_[0-9a-z]{10,32})(?:['\"\\\n\r\s\x60;<]|$)'''
regex = '''(?i)\b((sk|rk)_(test|live|prod)_[0-9a-z]{10,99})(?:['\"\\\n\r\s\x60;<]|$)'''
secretGroup = 1
keywords = [
"sk_test","sk_live",
"sk_test","sk_live","sk_prod","rk_test","rk_live","rk_prod",
]

[[rules]]
Expand Down

0 comments on commit b30d2e6

Please sign in to comment.