mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Limit hashicorp-tf-password to .tf/.hcl files (#1420)
* Limit hashicorp-tf-password to .tf/.hcl files * fix tests --------- Co-authored-by: Becojo <Becojo@users.noreply.github.com>
This commit is contained in:
1 parent
07e1c30592
commit
02808f45d0
3 files changed
+39
-7
No files matched your search
@@ -32,17 +32,20 @@ func HashicorpField() *config.Rule {
|
||||
RuleID: "hashicorp-tf-password",
|
||||
Regex: generateSemiGenericRegex(keywords, fmt.Sprintf(`"%s"`, alphaNumericExtended("8,20")), true),
|
||||
Keywords: keywords,
|
||||
Path: regexp.MustCompile(`\.(tf|hcl)$`),
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
tps := map[string]string{
|
||||
// Example from: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server.html
|
||||
"administrator_login_password = " + `"thisIsDog11"`,
|
||||
"file.tf": "administrator_login_password = " + `"thisIsDog11"`,
|
||||
// https://registry.terraform.io/providers/petoju/mysql/latest/docs
|
||||
"password = " + `"rootpasswd"`,
|
||||
"file.hcl": "password = " + `"rootpasswd"`,
|
||||
}
|
||||
fps := []string{
|
||||
"administrator_login_password = var.db_password",
|
||||
`password = "${aws_db_instance.default.password}"`,
|
||||
fps := map[string]string{
|
||||
"file.tf": "administrator_login_password = var.db_password",
|
||||
"file.hcl": `password = "${aws_db_instance.default.password}"`,
|
||||
"unrelated.js": "password = " + `"rootpasswd"`,
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
|
||||
return validateWithPaths(r, tps, fps)
|
||||
}
|
||||
Reference in new issue
Block a user