Skip to content

Commit

Permalink
feat(rules): Add detection for Scalingo API Token (#1262)
Browse files Browse the repository at this point in the history
* feat(rules): Add detection for Scalingo API Token

* fix(rules): Add boundary on both ends of Scalingo API Token regex to avoid falve positives
  • Loading branch information
brandon-welsch committed Sep 4, 2023
1 parent ed34259 commit d9f86d6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/generate/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func main() {
configRules = append(configRules, rules.RapidAPIAccessToken())
configRules = append(configRules, rules.ReadMe())
configRules = append(configRules, rules.RubyGemsAPIToken())
configRules = append(configRules, rules.ScalingoAPIToken())
configRules = append(configRules, rules.SendbirdAccessID())
configRules = append(configRules, rules.SendbirdAccessToken())
configRules = append(configRules, rules.SendGridAPIToken())
Expand Down
24 changes: 24 additions & 0 deletions cmd/generate/config/rules/scalingo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package rules

import (
"regexp"

"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)

func ScalingoAPIToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Scalingo API token",
RuleID: "scalingo-api-token",
Regex: regexp.MustCompile(`\btk-us-[a-zA-Z0-9-_]{48}\b`),
Keywords: []string{"tk-us-"},
}

// validate
tps := []string{
generateSampleSecret("scalingo", "tk-us-"+secrets.NewSecret(alphaNumericExtendedShort("48"))),
}
return validate(r, tps, nil)
}
8 changes: 8 additions & 0 deletions config/gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,14 @@ keywords = [
"rubygems_",
]

[[rules]]
id = "scalingo-api-token"
description = "Scalingo API token"
regex = '''\btk-us-[a-zA-Z0-9-_]{48}\b'''
keywords = [
"tk-us-",
]

[[rules]]
id = "sendbird-access-id"
description = "Sendbird Access ID"
Expand Down

0 comments on commit d9f86d6

Please sign in to comment.