notion.go 963 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func Notion() *config.Rule {
  7. // Define the identifiers that match the Keywords
  8. identifiers := []string{"ntn_"}
  9. // Define the regex pattern for Notion API token
  10. secretRegex := `ntn_[0-9]{11}[A-Za-z0-9]{32}[A-Za-z0-9]{3}`
  11. regex := utils.GenerateUniqueTokenRegex(secretRegex, false)
  12. r := config.Rule{
  13. Description: "Notion API token",
  14. RuleID: "notion-api-token",
  15. Regex: regex,
  16. Entropy: 4,
  17. Keywords: identifiers,
  18. }
  19. // validate
  20. tps := []string{
  21. "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",
  22. "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",
  23. "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",
  24. }
  25. fps := []string{
  26. "ntn_12345678901",
  27. "ntn_123456789012345678901234567890123456789012345678901234567890",
  28. "ntn_12345678901abc",
  29. }
  30. return utils.Validate(r, tps, fps)
  31. }