pypi.go 772 B

123456789101112131415161718192021222324252627
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "regexp"
  5. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  6. "github.com/zricethezav/gitleaks/v8/config"
  7. )
  8. func PyPiUploadToken() *config.Rule {
  9. // define rule
  10. r := config.Rule{
  11. Description: "Discovered a PyPI upload token, potentially compromising Python package distribution and repository integrity.",
  12. RuleID: "pypi-upload-token",
  13. Regex: regexp.MustCompile(
  14. `pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,1000}`),
  15. Keywords: []string{
  16. "pypi-AgEIcHlwaS5vcmc",
  17. },
  18. }
  19. // validate
  20. tps := []string{"pypiToken := \"pypi-AgEIcHlwaS5vcmc" + secrets.NewSecret(utils.Hex("32")) +
  21. secrets.NewSecret(utils.Hex("32")) + "\""}
  22. return utils.Validate(r, tps, nil)
  23. }