rule.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package config
  2. import (
  3. "regexp"
  4. )
  5. // Rules contain information that define details on how to detect secrets
  6. type Rule struct {
  7. // Description is the description of the rule.
  8. Description string
  9. // RuleID is a unique identifier for this rule
  10. RuleID string
  11. // Entropy is a float representing the minimum shannon
  12. // entropy a regex group must have to be considered a secret.
  13. Entropy float64
  14. // SecretGroup is an int used to extract secret from regex
  15. // match and used as the group that will have its entropy
  16. // checked if `entropy` is set.
  17. SecretGroup int
  18. // Regex is a golang regular expression used to detect secrets.
  19. Regex *regexp.Regexp
  20. // Path is a golang regular expression used to
  21. // filter secrets by path
  22. Path *regexp.Regexp
  23. // Tags is an array of strings used for metadata
  24. // and reporting purposes.
  25. Tags []string
  26. // Keywords are used for pre-regex check filtering. Rules that contain
  27. // keywords will perform a quick string compare check to make sure the
  28. // keyword(s) are in the content being scanned.
  29. Keywords []string
  30. // Allowlist allows a rule to be ignored for specific
  31. // regexes, paths, and/or commits
  32. Allowlist Allowlist
  33. }