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>
This commit is contained in:
authored and GitHub committed 2024-10-30 15:49:06 -05:00
1 parent c11adc91ad
commit 81f0002845
1 file changed
+6 -7
+6 -7
View File
@@ -1,10 +1,11 @@
package rules package rules
import ( import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
"regexp"
) )
func VaultServiceToken() *config.Rule { func VaultServiceToken() *config.Rule {
@@ -26,16 +27,14 @@ func VaultServiceToken() *config.Rule {
} }
// validate // validate
tps := []string{
// Old // Old
tps := utils.GenerateSampleSecrets("vault", "s."+secrets.NewSecret(`s\.[a-zA-Z0-9]{24}`)) utils.GenerateSampleSecret("vault", secrets.NewSecret(`s\.[0-9][a-zA-Z0-9]{23}`)),
tps = append(tps,
`token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`, `token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`,
)
// New // New
tps = append(tps, utils.GenerateSampleSecrets("vault", secrets.NewSecret(`hvs\.[\w\-]{90}`))...) utils.GenerateSampleSecret("vault", secrets.NewSecret(`hvs\.[0-9][\w\-]{89}`)),
tps = append(tps,
`-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars `-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars
) }
fps := []string{ fps := []string{
// Old // Old