config.tmpl 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # This file has been auto-generated. Do not edit manually.
  2. # If you would like to contribute new rules, please use
  3. # cmd/generate/config/main.go and follow the contributing guidelines
  4. # at https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md
  5. # This is the default gitleaks configuration file.
  6. # Rules and allowlists are defined within this file.
  7. # Rules instruct gitleaks on what should be considered a secret.
  8. # Allowlists instruct gitleaks on what is allowed, i.e. not a secret.
  9. title = "{{.Title}}"
  10. [allowlist]
  11. description = "{{.Allowlist.Description}}"
  12. {{- with .Allowlist.RegexTarget }}
  13. regexTarget = "{{ . }}"{{ end -}}
  14. {{- with .Allowlist.Regexes }}
  15. regexes = [{{ range $i, $regex := . }}
  16. '''{{ $regex }}''',{{ end }}
  17. ]{{ end }}
  18. {{- with .Allowlist.Paths }}
  19. paths = [{{ range $i, $path := . }}
  20. '''{{ $path }}''',{{ end }}
  21. ]{{ end }}
  22. {{ range $i, $rule := .Rules }}[[rules]]
  23. id = "{{$rule.RuleID}}"
  24. description = "{{$rule.Description}}"
  25. regex = '''{{$rule.Regex}}'''
  26. {{- with $rule.Path }}
  27. path = '''{{ . }}'''{{ end -}}
  28. {{- with $rule.SecretGroup }}
  29. secretGroup = {{ . }}{{ end -}}
  30. {{- with $rule.Entropy }}
  31. entropy = {{ . }}{{ end -}}
  32. {{- with $rule.Keywords }}
  33. {{- if gt (len .) 1}}
  34. keywords = [{{ range $j, $keyword := . }}
  35. "{{ $keyword }}",{{ end }}
  36. ]{{else}}
  37. keywords = [{{ range $j, $keyword := . }}"{{ $keyword }}"{{ end }}]{{end}}{{ end }}
  38. {{- with $rule.Tags }}
  39. tags = [
  40. {{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
  41. ]{{ end }}
  42. {{- /*
  43. * Use [rules.allowlist] for a while, allow people to catch up with the new syntax.
  44. * TODO: Remove this a few major versions after 8.21.0
  45. * https://github.com/gitleaks/gitleaks/issues/1571
  46. */}}
  47. {{- if eq (len $rule.Allowlists) 1 }}{{ with index $rule.Allowlists 0}}{{ if or .Regexes .Paths .Commits .StopWords }}
  48. # NOTE: Gitleaks >= v8.21.0 should use [[rules.allowlists] instead.
  49. [rules.allowlist]
  50. {{ with .MatchCondition }}condition = "{{ . }}"
  51. {{ end -}}
  52. {{- with .Commits }}commits = [
  53. {{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
  54. ]{{ end }}
  55. {{- with .Paths }}paths = [
  56. {{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
  57. ]{{ end }}
  58. {{- with .RegexTarget }}regexTarget = "{{ . }}"
  59. {{ end -}}
  60. {{- with .Regexes }}regexes = [{{ range $i, $regex := . }}
  61. '''{{ $regex }}''',{{ end }}
  62. ]{{ end }}
  63. {{- with .StopWords }}stopwords = [{{ range $j, $stopword := . }}
  64. "{{ $stopword }}",{{ end }}
  65. ]{{ end }}{{ end }}{{ end }}
  66. {{ else }}
  67. {{ with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}
  68. [[rules.allowlists]]
  69. {{ with $allowlist.MatchCondition }}condition = "{{ .String }}"
  70. {{ end -}}
  71. {{- with $allowlist.Commits }}commits = [
  72. {{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
  73. ]{{ end }}
  74. {{- with $allowlist.Paths }}paths = [
  75. {{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
  76. ]{{ end }}
  77. {{- with $allowlist.RegexTarget }}regexTarget = "{{ . }}"
  78. {{ end -}}
  79. {{- with $allowlist.Regexes }}regexes = [{{ range $i, $regex := . }}
  80. '''{{ $regex }}''',{{ end }}
  81. ]{{ end }}
  82. {{- with $allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }}
  83. "{{ $stopword }}",{{ end }}
  84. ]{{ end }}{{ end }}{{ end }}
  85. {{ end }}{{ end }}
  86. {{ end -}}