hashicorp.go 631 B

123456789101112131415161718192021222324
  1. package rules
  2. import (
  3. "regexp"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func Hashicorp() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "HashiCorp Terraform user/org API token",
  11. RuleID: "hashicorp-tf-api-token",
  12. Regex: regexp.MustCompile(`(?i)[a-z0-9]{14}\.atlasv1\.[a-z0-9\-_=]{60,70}`),
  13. Keywords: []string{"atlasv1"},
  14. }
  15. // validate
  16. tps := []string{
  17. generateSampleSecret("hashicorpToken", secrets.NewSecret(hex("14"))+".atlasv1."+secrets.NewSecret(alphaNumericExtended("60,70"))),
  18. }
  19. return validate(r, tps, nil)
  20. }