pypi.go 816 B

12345678910111213141516171819202122232425
  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. "github.com/zricethezav/gitleaks/v8/regexp"
  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(`pypi-AgEIcHlwaS5vcmc[\w-]{50,1000}`),
  14. Entropy: 3,
  15. Keywords: []string{
  16. "pypi-AgEIcHlwaS5vcmc",
  17. },
  18. }
  19. // validate
  20. tps := utils.GenerateSampleSecrets("pypi", "pypi-AgEIcHlwaS5vcmc"+secrets.NewSecret(utils.Hex("32"))+secrets.NewSecret(utils.Hex("32")))
  21. return utils.Validate(r, tps, nil)
  22. }