feat: Hashicorp Terraform fields for password (#1237)

* Hashicorp Terraform fields for password
Fixes #1236

* fix duplicate description

* set caseInsensitive
This commit is contained in:
Baruch Odem (Rothkoff) authored and GitHub committed 2023-11-09 14:31:16 -06:00
1 parent b49667786e
commit 20fcf5009f
3 files changed
+33

No files matched your search

+24
View File
@@ -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)
}