config.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package base
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/config"
  4. "regexp"
  5. )
  6. func CreateGlobalConfig() config.Config {
  7. return config.Config{
  8. Title: "gitleaks config",
  9. Allowlist: config.Allowlist{
  10. Description: "global allow lists",
  11. Regexes: []*regexp.Regexp{
  12. // ----------- General placeholders -----------
  13. regexp.MustCompile(`(?i)^true|false|null$`),
  14. // ----------- Interpolated Variables -----------
  15. // Ansible (https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html)
  16. regexp.MustCompile(`^\{\{[ \t]*[\w ().|]+[ \t]*}}$`),
  17. // GitHub Actions
  18. // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
  19. // https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
  20. regexp.MustCompile(`^\$\{\{[ \t]*((env|github|secrets|vars)(\.[A-Za-z]\w+)+[\w "'&./=|]*)[ \t]*}}$`),
  21. // NuGet (https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#using-environment-variables)
  22. regexp.MustCompile(`^%([A-Z_]+|[a-z_]+)%$`),
  23. // Urban Code Deploy (https://www.ibm.com/support/pages/replace-token-step-replaces-replacement-values-windows-variables)
  24. regexp.MustCompile(`^@([A-Z_]+|[a-z_]+)@$`),
  25. // ----------- Environment Variables -----------
  26. regexp.MustCompile(`^\$(\d+|{\d+})$`),
  27. regexp.MustCompile(`^\$([A-Z_]+|[a-z_]+)$`),
  28. regexp.MustCompile(`^\${([A-Z_]+|[a-z_]+)}$`),
  29. },
  30. Paths: []*regexp.Regexp{
  31. regexp.MustCompile(`^gitleaks\.toml$`),
  32. // ----------- Documents and media -----------
  33. regexp.MustCompile(`(?i)\.(bmp|gif|jpe?g|svg|tiff?)$`),
  34. regexp.MustCompile(`(.*?)(doc|docx|zip|xls|pdf|bin|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf)$`),
  35. // ----------- Golang files -----------
  36. regexp.MustCompile(`go\.(mod|sum|work(\.sum)?)$`),
  37. regexp.MustCompile(`(^|/)vendor/modules\.txt$`),
  38. regexp.MustCompile(`(^|/)vendor/(github\.com|golang\.org/x|google\.golang\.org|gopkg\.in|istio\.io|k8s\.io|sigs\.k8s\.io)/.*$`),
  39. // ----------- Java files -----------
  40. // Gradle
  41. regexp.MustCompile(`(^|/)gradlew(\.bat)?$`),
  42. regexp.MustCompile(`(^|/)gradle\.lockfile$`),
  43. regexp.MustCompile(`(^|/)mvnw(\.cmd)?$`),
  44. regexp.MustCompile(`(^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
  45. // ----------- Node.js files -----------
  46. // Dependencies and lock files.
  47. regexp.MustCompile(`(^|/)node_modules/.*?$`),
  48. regexp.MustCompile(`(^|/)package-lock\.json$`),
  49. regexp.MustCompile(`(^|/)yarn\.lock$`),
  50. regexp.MustCompile(`(^|/)pnpm-lock\.yaml$`),
  51. regexp.MustCompile(`(^|/)npm-shrinkwrap\.json$`),
  52. regexp.MustCompile(`(^|/)bower_components/.*?$`),
  53. // ----------- Python files -----------
  54. // Dependencies and lock files.
  55. regexp.MustCompile(`(^|/)Pipfile\.lock$`),
  56. regexp.MustCompile(`(^|/)poetry\.lock$`),
  57. // Virtual environments
  58. // env/lib/python3.7/site-packages/urllib3/util/url.py
  59. regexp.MustCompile(`(?i)/?(v?env|virtualenv)/lib/.+$`),
  60. // /python/3.7.4/Lib/site-packages/dask/bytes/tests/test_bytes_utils.py
  61. // python/3.7.4/Lib/site-packages/fsspec/utils.py
  62. // python/2.7.16.32/Lib/bsddb/test/test_dbenv.py
  63. regexp.MustCompile(`(?i)/?python/[23](\.\d{1,2})+/lib/.+$`),
  64. // python/lib/python3.8/site-packages/boto3/data/ec2/2016-04-01/resources-1.json
  65. // python/lib/python3.8/site-packages/botocore/data/alexaforbusiness/2017-11-09/service-2.json
  66. regexp.MustCompile(`(?i)/?python/lib/python[23](\.\d{1,2})+/.+$`),
  67. // dist-info directory (https://py-pkgs.org/04-package-structure.html#building-sdists-and-wheels)
  68. regexp.MustCompile(`(?i)(^|/)[a-z0-9_.]+-[0-9.]+\.dist-info/.+$`),
  69. // ----------- Ruby files -----------
  70. regexp.MustCompile(`(^|/)vendor/(bundle|ruby)/.*?$`),
  71. regexp.MustCompile(`\.gem$`), // tar archive
  72. // Misc
  73. regexp.MustCompile(`verification-metadata.xml`),
  74. regexp.MustCompile(`Database.refactorlog`),
  75. //regexp.MustCompile(`vendor`),
  76. },
  77. },
  78. }
  79. }