jfrog.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package rules
  2. import (
  3. "fmt"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  5. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  6. "github.com/zricethezav/gitleaks/v8/config"
  7. )
  8. func JFrogAPIKey() *config.Rule {
  9. keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
  10. // Define Rule
  11. r := config.Rule{
  12. // Human readable description of the rule
  13. Description: "Found a JFrog API Key, posing a risk of unauthorized access to software artifact repositories and build pipelines.",
  14. // Unique ID for the rule
  15. RuleID: "jfrog-api-key",
  16. // Regex capture group for the actual secret
  17. // Regex used for detecting secrets. See regex section below for more details
  18. Regex: utils.GenerateSemiGenericRegex(keywords, utils.AlphaNumeric("73"), true),
  19. // Keywords used for string matching on fragments (think of this as a prefilter)
  20. Keywords: keywords,
  21. }
  22. // validate
  23. tps := []string{
  24. fmt.Sprintf("--set imagePullSecretJfrog.password=%s", secrets.NewSecret(utils.AlphaNumeric("73"))),
  25. }
  26. return utils.Validate(r, tps, nil)
  27. }
  28. func JFrogIdentityToken() *config.Rule {
  29. keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
  30. // Define Rule
  31. r := config.Rule{
  32. // Human readable description of the rule
  33. Description: "Discovered a JFrog Identity Token, potentially compromising access to JFrog services and sensitive software artifacts.",
  34. // Unique ID for the rule
  35. RuleID: "jfrog-identity-token",
  36. // Regex capture group for the actual secret
  37. // Regex used for detecting secrets. See regex section below for more details
  38. Regex: utils.GenerateSemiGenericRegex(keywords, utils.AlphaNumeric("64"), true),
  39. // Keywords used for string matching on fragments (think of this as a prefilter)
  40. Keywords: keywords,
  41. }
  42. // validate
  43. tps := utils.GenerateSampleSecrets("jfrog", secrets.NewSecret(utils.AlphaNumeric("64")))
  44. tps = append(tps, utils.GenerateSampleSecrets("artifactory", secrets.NewSecret(utils.AlphaNumeric("64")))...)
  45. tps = append(tps, utils.GenerateSampleSecrets("bintray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
  46. tps = append(tps, utils.GenerateSampleSecrets("xray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
  47. tps = append(tps, fmt.Sprintf("\"artifactory\", \"%s\"", secrets.NewSecret(utils.AlphaNumeric("64"))))
  48. return utils.Validate(r, tps, nil)
  49. }