Просмотр исходного кода

fix(vault-service-token): ensure that TPS contains digits (#1614)

* fix(vault-service-token): ensure that TPS contains digits

Chances of randomly generating a 24 letter string without digits:
P = ( (26+26) / (26+26+10) ) ^ 24 = 1.46 %

* fixt

---------

Co-authored-by: Zachary Rice <zricer@protonmail.com>
Co-authored-by: Zachary Rice <zachary.rice@trufflesec.com>
Ben-grmbl 1 год назад
Родитель
Сommit
81f0002845
1 измененных файлов с 8 добавлено и 9 удалено
  1. 8 9
      cmd/generate/config/rules/hashicorp_vault.go

+ 8 - 9
cmd/generate/config/rules/hashicorp_vault.go

@@ -1,10 +1,11 @@
 package rules
 
 import (
+	"regexp"
+
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
-	"regexp"
 )
 
 func VaultServiceToken() *config.Rule {
@@ -26,16 +27,14 @@ func VaultServiceToken() *config.Rule {
 	}
 
 	// validate
-	// Old
-	tps := utils.GenerateSampleSecrets("vault", "s."+secrets.NewSecret(`s\.[a-zA-Z0-9]{24}`))
-	tps = append(tps,
+	tps := []string{
+		// Old
+		utils.GenerateSampleSecret("vault", secrets.NewSecret(`s\.[0-9][a-zA-Z0-9]{23}`)),
 		`token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`,
-	)
-	// New
-	tps = append(tps, utils.GenerateSampleSecrets("vault", secrets.NewSecret(`hvs\.[\w\-]{90}`))...)
-	tps = append(tps,
+		// New
+		utils.GenerateSampleSecret("vault", secrets.NewSecret(`hvs\.[0-9][\w\-]{89}`)),
 		`-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars
-	)
+	}
 
 	fps := []string{
 		// Old