finding.go 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package report
  2. import (
  3. "strings"
  4. )
  5. // Finding contains information about strings that
  6. // have been captured by a tree-sitter query.
  7. type Finding struct {
  8. Description string
  9. StartLine int
  10. EndLine int
  11. StartColumn int
  12. EndColumn int
  13. Line string `json:"-"`
  14. Match string
  15. // Secret contains the full content of what is matched in
  16. // the tree-sitter query.
  17. Secret string
  18. // File is the name of the file containing the finding
  19. File string
  20. SymlinkFile string
  21. Commit string
  22. // Entropy is the shannon entropy of Value
  23. Entropy float32
  24. Author string
  25. Email string
  26. Date string
  27. Message string
  28. Tags []string
  29. // Rule is the name of the rule that was matched
  30. RuleID string
  31. // unique identifer
  32. Fingerprint string
  33. }
  34. // Redact removes sensitive information from a finding.
  35. func (f *Finding) Redact() {
  36. f.Line = strings.Replace(f.Line, f.Secret, "REDACTED", -1)
  37. f.Match = strings.Replace(f.Match, f.Secret, "REDACTED", -1)
  38. f.Secret = "REDACTED"
  39. }