mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
feat: Hashicorp Terraform fields for password (#1237)
* Hashicorp Terraform fields for password Fixes #1236 * fix duplicate description * set caseInsensitive
This commit is contained in:
1 parent
b49667786e
commit
20fcf5009f
3 files changed
+33
No files matched your search
@@ -87,6 +87,7 @@ func main() {
|
||||
configRules = append(configRules, rules.GrafanaCloudApiToken())
|
||||
configRules = append(configRules, rules.GrafanaServiceAccountToken())
|
||||
configRules = append(configRules, rules.Hashicorp())
|
||||
configRules = append(configRules, rules.HashicorpField())
|
||||
configRules = append(configRules, rules.Heroku())
|
||||
configRules = append(configRules, rules.HubSpot())
|
||||
configRules = append(configRules, rules.HuggingFaceAccessToken())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -22,3 +23,26 @@ func Hashicorp() *config.Rule {
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func HashicorpField() *config.Rule {
|
||||
keywords := []string{"administrator_login_password", "password"}
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
Description: "HashiCorp Terraform password field",
|
||||
RuleID: "hashicorp-tf-password",
|
||||
Regex: generateSemiGenericRegex(keywords, fmt.Sprintf(`"%s"`, alphaNumericExtended("8,20")), true),
|
||||
Keywords: keywords,
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
// Example from: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server.html
|
||||
"administrator_login_password = " + `"thisIsDog11"`,
|
||||
// https://registry.terraform.io/providers/petoju/mysql/latest/docs
|
||||
"password = " + `"rootpasswd"`,
|
||||
}
|
||||
fps := []string{
|
||||
"administrator_login_password = var.db_password",
|
||||
`password = "${aws_db_instance.default.password}"`,
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
}
|
||||
Reference in new issue
Block a user