mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-26 19:30:55 +01:00
* Start Files Source
* Keep cmd the same for now
* Get tests to pass
* s.MaxTargetMegaBytes -> s.MaxFileSize
* Tweak some log messages & use q semgroup for files
* Just call yield inside the semgroup
* Refactor a check and revert some log lines
* Move mg && misc tuning
* Add `make profile`
(Benchmark results are only added if tools are installed)
Example output:
```
========================================================================
generating profile data
------------------------------------------------------------------------
- mode: dir
benchmark:
tool: hyperfine
path: profile/1748019612/dir/benchmark.json
results:
mean: 1.12852930166
stddev: 0.12163775966037399
median: 1.07242928416
user: 3.9699382799999996
system: 0.04382341999999999
min: 1.03207673016
max: 1.3913475181600001
profile:
- mode: cpu
path: profile/1748019612/dir/cpu.pprof
view: go tool pprof -http=localhost: ./gitleaks profile/1748019612/dir/cpu.pprof
- mode: mem
path: profile/1748019612/dir/mem.pprof
view: go tool pprof -http=localhost: ./gitleaks profile/1748019612/dir/mem.pprof
- mode: trace
path: profile/1748019612/dir/trace.out
view: go tool trace profile/1748019612/dir/trace.out
- mode: git
...snip...
```
* Archive support for File based sources
* Move Git to Source interface
* Scan archives in git
* Misc linter fixes
* Exclude certain diffs: --diff-filter=tuxdb
* Add git archives tests
* Log error instead of fatal
* Fix spacing in test config
* Refine source comments/wording
* Make MB conversions more readable
* Format cmd
* Adjust DetectSource logging
* MiB -> MB in logs
* Add testdata/repos/archives/dotGit/refs/.gitkeep
Without it the refs folder gets deleted and the
and then it isn't detected as a git repo ¯\_(ツ)_/¯
So then the test starts scanning the whole gitleaks
repo instead :D
* Handle finding links for archives
* Working on archive depth
* Fixes from failfast test
* cmd max-archive-depth
* added comments, fixed warnings
* removed test print
* Update README.md
* Set archive depth for DetectFiles
* Tweak logs & pass max archive for readers
* Pass ctx to Fragments
* Add make lint target and address some issues
* Fix compat issue
* Report path in fragment errors
* Apply PR suggestions & misc changes
- Update blobReader.Close() to discard the buffer
- Misc logger issues & uses
- Tweak .golangci.yaml to default to none
- Discard remaining blobReader data on close
- Undo a De Morgan's Law suggestion (and disable QF1001)
* Add http mode for diagnostics
gitleaks --diagnostics=http ...
-----
From the net/http/pprof docs:
Use the pprof tool to look at the heap profile:
```
go tool pprof http://localhost:6060/debug/pprof/heap
```
Or to look at a 30-second CPU profile:
```
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
```
Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:
```
go tool pprof http://localhost:6060/debug/pprof/block
```
Or to look at the holders of contended mutexes, after calling runtime.SetMutexProfileFraction in your program:
```
go tool pprof http://localhost:6060/debug/pprof/mutex
```
(For more info see https://pkg.go.dev/net/http/pprof)
---------
Co-authored-by: Alex Layne <alayne@redhat.com>
228 lines
6.4 KiB
TOML
228 lines
6.4 KiB
TOML
title = "gitleaks config"
|
|
# https://learnxinyminutes.com/docs/toml/ for toml reference
|
|
|
|
[[rules]]
|
|
description = "1Password Secret Key"
|
|
id = "1password-secret-key"
|
|
regex = '''A3-[A-Z0-9]{6}-(?:(?:[A-Z0-9]{11})|(?:[A-Z0-9]{6}-[A-Z0-9]{5}))-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}'''
|
|
tags = ["1Password"]
|
|
|
|
[[rules]]
|
|
description = "AWS Access Key"
|
|
id = "aws-access-key"
|
|
regex = '''(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}'''
|
|
tags = ["key", "AWS"]
|
|
|
|
[[rules]]
|
|
description = "AWS Secret Key"
|
|
id = "aws-secret-key"
|
|
regex = '''(?i)aws_(.{0,20})?=?.[\'\"0-9a-zA-Z\/+]{40}'''
|
|
tags = ["key", "AWS"]
|
|
|
|
[[rules]]
|
|
description = "AWS MWS key"
|
|
id = "aws-mws-key"
|
|
regex = '''amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
|
tags = ["key", "AWS", "MWS"]
|
|
|
|
[[rules]]
|
|
description = "Facebook Secret Key"
|
|
id = "facebook-secret-key"
|
|
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
|
|
tags = ["key", "Facebook"]
|
|
|
|
[[rules]]
|
|
description = "Facebook Client ID"
|
|
id = "facebook-client-id"
|
|
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
|
|
tags = ["key", "Facebook"]
|
|
|
|
[[rules]]
|
|
description = "Twitter Secret Key"
|
|
id = "twitter-secret-key"
|
|
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
|
|
tags = ["key", "Twitter"]
|
|
|
|
[[rules]]
|
|
description = "Twitter Client ID"
|
|
id = "twitter-client-id"
|
|
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]'''
|
|
tags = ["client", "Twitter"]
|
|
|
|
[[rules]]
|
|
description = "Github Personal Access Token"
|
|
id = "github-pat"
|
|
regex = '''ghp_[0-9a-zA-Z]{36}'''
|
|
tags = ["key", "Github"]
|
|
[[rules]]
|
|
description = "Github OAuth Access Token"
|
|
id = "github-oauth"
|
|
regex = '''gho_[0-9a-zA-Z]{36}'''
|
|
tags = ["key", "Github"]
|
|
[[rules]]
|
|
id = "github-app"
|
|
description = "Github App Token"
|
|
regex = '''(ghu|ghs)_[0-9a-zA-Z]{36}'''
|
|
tags = ["key", "Github"]
|
|
[[rules]]
|
|
id = "github-refresh"
|
|
description = "Github Refresh Token"
|
|
regex = '''ghr_[0-9a-zA-Z]{76}'''
|
|
tags = ["key", "Github"]
|
|
|
|
[[rules]]
|
|
id = "linkedin-client"
|
|
description = "LinkedIn Client ID"
|
|
regex = '''(?i)linkedin(.{0,20})?(?-i)[0-9a-z]{12}'''
|
|
tags = ["client", "LinkedIn"]
|
|
|
|
[[rules]]
|
|
id = "linkedin-secret"
|
|
description = "LinkedIn Secret Key"
|
|
regex = '''(?i)linkedin(.{0,20})?[0-9a-z]{16}'''
|
|
tags = ["secret", "LinkedIn"]
|
|
|
|
[[rules]]
|
|
id = "slack"
|
|
description = "Slack"
|
|
regex = '''xox[baprs]-(?:[0-9a-zA-Z]{10,48})?'''
|
|
tags = ["key", "Slack"]
|
|
|
|
[[rules]]
|
|
id = "apkey"
|
|
description = "Asymmetric Private Key"
|
|
regex = '''-----BEGIN (?:(?:EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY(?: BLOCK)?-----'''
|
|
tags = ["key", "AsymmetricPrivateKey"]
|
|
|
|
[[rules]]
|
|
id = "google"
|
|
description = "Google API key"
|
|
regex = '''AIza[0-9A-Za-z\-_]{35}'''
|
|
tags = ["key", "Google"]
|
|
|
|
[[rules]]
|
|
id = "google"
|
|
description = "Google (GCP) Service Account"
|
|
regex = '''"type": "service_account"'''
|
|
tags = ["key", "Google"]
|
|
|
|
[[rules]]
|
|
id = "heroku"
|
|
description = "Heroku API key"
|
|
regex = '''(?i)heroku(.{0,20})?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
|
tags = ["key", "Heroku"]
|
|
|
|
[[rules]]
|
|
id = "mailchimp"
|
|
description = "MailChimp API key"
|
|
regex = '''(?i)(mailchimp|mc)(.{0,20})?[0-9a-f]{32}-us[0-9]{1,2}'''
|
|
tags = ["key", "Mailchimp"]
|
|
|
|
[[rules]]
|
|
id = "mailgun"
|
|
description = "Mailgun API key"
|
|
regex = '''((?i)(mailgun|mg)(.{0,20})?)?key-[0-9a-z]{32}'''
|
|
tags = ["key", "Mailgun"]
|
|
|
|
[[rules]]
|
|
id = "paypal"
|
|
description = "PayPal Braintree access token"
|
|
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
|
|
tags = ["key", "Paypal"]
|
|
|
|
[[rules]]
|
|
id = "piacatic"
|
|
description = "Picatic API key"
|
|
regex = '''sk_live_[0-9a-z]{32}'''
|
|
tags = ["key", "Picatic"]
|
|
|
|
[[rules]]
|
|
id = "sendgrid"
|
|
description = "SendGrid API Key"
|
|
regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}'''
|
|
tags = ["key", "SendGrid"]
|
|
|
|
[[rules]]
|
|
description = "Sidekiq Secret"
|
|
id = "sidekiq-secret"
|
|
regex = '''(?i)(?:BUNDLE_ENTERPRISE__CONTRIBSYS__COM|BUNDLE_GEMS__CONTRIBSYS__COM)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}([a-f0-9]{8}:[a-f0-9]{8})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
|
secretGroup = 1
|
|
keywords = [
|
|
"bundle_enterprise__contribsys__com","bundle_gems__contribsys__com",
|
|
]
|
|
|
|
[[rules]]
|
|
description = "Sidekiq Sensitive URL"
|
|
id = "sidekiq-sensitive-url"
|
|
regex = '''(?i)\b(http(?:s??):\/\/)([a-f0-9]{8}:[a-f0-9]{8})@(?:gems.contribsys.com|enterprise.contribsys.com)(?:[\/|\#|\?|:]|$)'''
|
|
secretGroup = 2
|
|
keywords = [
|
|
"gems.contribsys.com","enterprise.contribsys.com",
|
|
]
|
|
|
|
[[rules]]
|
|
id = "slack-webhook"
|
|
description = "Slack Webhook"
|
|
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8,12}/[a-zA-Z0-9_]{24}'''
|
|
tags = ["key", "slack"]
|
|
|
|
[[rules]]
|
|
id = "stripe"
|
|
description = "Stripe API key"
|
|
regex = '''(?i)stripe(.{0,20})?[sr]k_live_[0-9a-zA-Z]{24}'''
|
|
tags = ["key", "Stripe"]
|
|
|
|
[[rules]]
|
|
id = "square"
|
|
description = "Square access token"
|
|
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
|
|
tags = ["key", "square"]
|
|
|
|
[[rules]]
|
|
id = "square-oauth"
|
|
description = "Square OAuth secret"
|
|
regex = '''sq0csp-[0-9A-Za-z\-_]{43}'''
|
|
tags = ["key", "square"]
|
|
|
|
[[rules]]
|
|
id = "twilio"
|
|
description = "Twilio API key"
|
|
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
|
|
tags = ["key", "twilio"]
|
|
|
|
[[rules]]
|
|
id = "dynatrace"
|
|
description = "Dynatrace ttoken"
|
|
regex = '''dt0[a-zA-Z]{1}[0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}'''
|
|
tags = ["key", "Dynatrace"]
|
|
|
|
[[rules]]
|
|
id = "shopify"
|
|
description = "Shopify shared secret"
|
|
regex = '''shpss_[a-fA-F0-9]{32}'''
|
|
tags = ["key", "Shopify"]
|
|
|
|
[[rules]]
|
|
id = "shopify-access"
|
|
description = "Shopify access token"
|
|
regex = '''shpat_[a-fA-F0-9]{32}'''
|
|
tags = ["key", "Shopify"]
|
|
|
|
[[rules]]
|
|
id = "shopify-custom"
|
|
description = "Shopify custom app access token"
|
|
regex = '''shpca_[a-fA-F0-9]{32}'''
|
|
tags = ["key", "Shopify"]
|
|
|
|
[[rules]]
|
|
id = "shopify-private"
|
|
description = "Shopify private app access token"
|
|
regex = '''shppa_[a-fA-F0-9]{32}'''
|
|
tags = ["key", "Shopify"]
|
|
|
|
[[rules]]
|
|
id = "pypi"
|
|
description = "PyPI upload token"
|
|
regex = '''pypi-AgEIcHlwaS5vcmc[A-Za-z0-9-_]{50,1000}'''
|
|
tags = ["key", "pypi"]
|