config.tmpl 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. {{- with .Allowlist.StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
  23. "{{ $stopword }}",{{ end }}
  24. ]{{ end }}
  25. {{ range $i, $rule := .Rules }}[[rules]]
  26. id = "{{$rule.RuleID}}"
  27. description = "{{$rule.Description}}"
  28. regex = '''{{$rule.Regex}}'''
  29. {{- with $rule.Path }}
  30. path = '''{{ . }}'''{{ end -}}
  31. {{- with $rule.SecretGroup }}
  32. secretGroup = {{ . }}{{ end -}}
  33. {{- with $rule.Entropy }}
  34. entropy = {{ . }}{{ end -}}
  35. {{- with $rule.Keywords }}
  36. {{- if gt (len .) 1}}
  37. keywords = [{{ range $j, $keyword := . }}
  38. "{{ $keyword }}",{{ end }}
  39. ]{{else}}
  40. keywords = [{{ range $j, $keyword := . }}"{{ $keyword }}"{{ end }}]{{end}}{{ end }}
  41. {{- with $rule.Tags }}
  42. tags = [
  43. {{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
  44. ]{{ end }}
  45. {{- /*
  46. * Use [rules.allowlist] for a while, allow people to catch up with the new syntax.
  47. * TODO: Remove this a few major versions after 8.21.0
  48. * https://github.com/gitleaks/gitleaks/issues/1571
  49. */}}
  50. {{- if eq (len $rule.Allowlists) 1 }}{{ with index $rule.Allowlists 0}}{{ if or .Regexes .Paths .Commits .StopWords }}
  51. # NOTE: Gitleaks >= v8.21.0 should use [[rules.allowlists] instead.
  52. [rules.allowlist]
  53. {{- with .MatchCondition }}{{println}}condition = "{{ .MatchCondition.String }}"{{ end }}
  54. {{- with .Commits -}}{{println}}commits = [
  55. {{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
  56. ]{{ end }}
  57. {{- with .Paths }}{{println}}paths = [
  58. {{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
  59. ]{{ end }}
  60. {{- if and .RegexTarget .Regexes }}{{println}}regexTarget = "{{ .RegexTarget }}"{{ end -}}
  61. {{- with .Regexes }}{{println}}regexes = [{{ range $i, $regex := . }}
  62. '''{{ $regex }}''',{{ end }}
  63. ]{{ end }}
  64. {{- with .StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
  65. "{{ $stopword }}",{{ end }}
  66. ]{{ end }}{{ end }}{{ end }}
  67. {{ else }}
  68. {{ with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}
  69. [[rules.allowlists]]
  70. {{ with $allowlist.MatchCondition }}condition = "{{ .String }}"
  71. {{ end -}}
  72. {{- with $allowlist.Commits }}commits = [
  73. {{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
  74. ]{{ end }}
  75. {{- with $allowlist.Paths }}paths = [
  76. {{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
  77. ]{{ end }}
  78. {{- with $allowlist.RegexTarget }}regexTarget = "{{ . }}"
  79. {{ end -}}
  80. {{- with $allowlist.Regexes }}regexes = [{{ range $i, $regex := . }}
  81. '''{{ $regex }}''',{{ end }}
  82. ]{{ end }}
  83. {{ with $allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }}
  84. "{{ $stopword }}",{{ end }}
  85. ]{{ end }}{{ end }}{{ end }}
  86. {{ end }}{{ end }}
  87. {{ end -}}