|
@@ -1,6 +1,7 @@
|
|
|
package rules
|
|
package rules
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "fmt"
|
|
|
"regexp"
|
|
"regexp"
|
|
|
|
|
|
|
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
|
@@ -22,3 +23,26 @@ func Hashicorp() *config.Rule {
|
|
|
}
|
|
}
|
|
|
return validate(r, tps, nil)
|
|
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)
|
|
|
|
|
+}
|