From e78a22e19c9e19a0ae0875a0fb7937f3f9a84a0b Mon Sep 17 00:00:00 2001 From: Zachary Rice Date: Mon, 27 Jun 2022 18:49:32 -0500 Subject: [PATCH] Fix Plaid, add Plaid access token (#903) * adding airtable and adafruit * Fix plaid, add plaid-access-token --- cmd/generate/config/main.go | 1 + cmd/generate/config/rules/plaid.go | 28 +++++++++++++++++++++++++--- config/gitleaks.toml | 13 +++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/cmd/generate/config/main.go b/cmd/generate/config/main.go index 8fec9675..5ae62ecc 100644 --- a/cmd/generate/config/main.go +++ b/cmd/generate/config/main.go @@ -103,6 +103,7 @@ func main() { configRules = append(configRules, rules.NPM()) configRules = append(configRules, rules.NytimesAccessToken()) configRules = append(configRules, rules.PlaidAccessID()) + configRules = append(configRules, rules.PlaidSecretKey()) configRules = append(configRules, rules.PlaidAccessToken()) configRules = append(configRules, rules.PlanetScalePassword()) configRules = append(configRules, rules.PlanetScaleAPIToken()) diff --git a/cmd/generate/config/rules/plaid.go b/cmd/generate/config/rules/plaid.go index d93e7ed3..8cfc16d0 100644 --- a/cmd/generate/config/rules/plaid.go +++ b/cmd/generate/config/rules/plaid.go @@ -1,6 +1,8 @@ package rules import ( + "fmt" + "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/config" ) @@ -24,11 +26,11 @@ func PlaidAccessID() *config.Rule { return validate(r, tps, nil) } -func PlaidAccessToken() *config.Rule { +func PlaidSecretKey() *config.Rule { // define rule r := config.Rule{ - RuleID: "plaid-api-secret", - Description: "Plaid API Secret", + RuleID: "plaid-secret-key", + Description: "Plaid Secret key", Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30")), SecretGroup: 1, Keywords: []string{ @@ -42,3 +44,23 @@ func PlaidAccessToken() *config.Rule { } return validate(r, tps, nil) } + +func PlaidAccessToken() *config.Rule { + // define rule + r := config.Rule{ + RuleID: "plaid-api-token", + Description: "Plaid API Token", + Regex: generateSemiGenericRegex([]string{"plaid"}, + fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12())), + SecretGroup: 1, + Keywords: []string{ + "plaid", + }, + } + + // validate + tps := []string{ + generateSampleSecret("plaid", secrets.NewSecret(fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12()))), + } + return validate(r, tps, nil) +} diff --git a/config/gitleaks.toml b/config/gitleaks.toml index 4e75c7c9..5c088fe3 100644 --- a/config/gitleaks.toml +++ b/config/gitleaks.toml @@ -761,14 +761,23 @@ keywords = [ ] [[rules]] -description = "Plaid API Secret" -id = "plaid-api-secret" +description = "Plaid Secret key" +id = "plaid-secret-key" regex = '''(?i)(?:plaid)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}([a-z0-9]{30})(?:['|\"|\n|\r|\s|\x60]|$)''' secretGroup = 1 keywords = [ "plaid", ] +[[rules]] +description = "Plaid API Token" +id = "plaid-api-token" +regex = '''(?i)(?:plaid)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}(access-(?:sandbox|development|production)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:['|\"|\n|\r|\s|\x60]|$)''' +secretGroup = 1 +keywords = [ + "plaid", +] + [[rules]] description = "PlanetScale password" id = "planetscale-password"