yandex.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func YandexAWSAccessToken() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. RuleID: "yandex-aws-access-token",
  11. Description: "Uncovered a Yandex AWS Access Token, potentially compromising cloud resource access and data security on Yandex Cloud.",
  12. Regex: utils.GenerateSemiGenericRegex([]string{"yandex"},
  13. `YC[a-zA-Z0-9_\-]{38}`, true),
  14. Keywords: []string{
  15. "yandex",
  16. },
  17. }
  18. // validate
  19. tps := []string{
  20. utils.GenerateSampleSecret("yandex",
  21. secrets.NewSecret(`YC[a-zA-Z0-9_\-]{38}`)),
  22. }
  23. return utils.Validate(r, tps, nil)
  24. }
  25. func YandexAPIKey() *config.Rule {
  26. // define rule
  27. r := config.Rule{
  28. RuleID: "yandex-api-key",
  29. Description: "Discovered a Yandex API Key, which could lead to unauthorized access to Yandex services and data manipulation.",
  30. Regex: utils.GenerateSemiGenericRegex([]string{"yandex"},
  31. `AQVN[A-Za-z0-9_\-]{35,38}`, true),
  32. Keywords: []string{
  33. "yandex",
  34. },
  35. }
  36. // validate
  37. tps := []string{
  38. utils.GenerateSampleSecret("yandex",
  39. secrets.NewSecret(`AQVN[A-Za-z0-9_\-]{35,38}`)),
  40. }
  41. return utils.Validate(r, tps, nil)
  42. }
  43. func YandexAccessToken() *config.Rule {
  44. // define rule
  45. r := config.Rule{
  46. RuleID: "yandex-access-token",
  47. Description: "Found a Yandex Access Token, posing a risk to Yandex service integrations and user data privacy.",
  48. Regex: utils.GenerateSemiGenericRegex([]string{"yandex"},
  49. `t1\.[A-Z0-9a-z_-]+[=]{0,2}\.[A-Z0-9a-z_-]{86}[=]{0,2}`, true),
  50. Keywords: []string{
  51. "yandex",
  52. },
  53. }
  54. // validate
  55. tps := []string{
  56. utils.GenerateSampleSecret("yandex",
  57. secrets.NewSecret(`t1\.[A-Z0-9a-z_-]+[=]{0,2}\.[A-Z0-9a-z_-]{86}[=]{0,2}`)),
  58. }
  59. return utils.Validate(r, tps, nil)
  60. }