Compare commits

...
10 Commits
Author SHA1 Message Date
Zachary Rice 12d276acd7 Bug 553 global allowlist (#554)
* add global file check

* rm whitespace
2021-04-22 18:07:07 -04:00
Pavel Shklovsky e6934bf0a5 Docker-based pre-commit configuration example (#551)
* Docker-based pre-commit configuration example

* Docker-based pre-commit configuration example
2021-04-21 12:58:03 -04:00
Zachary Rice 6f5ad9dc0b Update README.md 2021-04-12 11:07:28 -04:00
Zachary Rice a2019a4782 Update README.md 2021-04-09 14:21:15 -04:00
zricethezav 5d7b7718ec splitting out github rules and retabbing 2021-04-09 14:07:23 -04:00
Zachary Rice 190877a24b Pypi GitHub rules (#546)
* adding pypi and basic azure rules

* Adding new github format
2021-04-08 16:34:08 -04:00
mercurieteandmercuriete 144362b972 docs(Dockerfile): Fix example of usage on Dockerfile (#545)
* Closes #544

Co-authored-by: mercuriete <mercuriete@gmail.com>
2021-04-08 10:23:03 -04:00
Zachary Rice d353ac5108 Update README.md 2021-04-06 14:42:44 -04:00
Zachary Rice a27a08904a Update README.md 2021-03-05 16:40:07 -05:00
Zachary Rice 5ef4e336ce Update README.md 2021-03-05 16:39:23 -05:00
5 changed files with 168 additions and 134 deletions

No files matched your search

+1 -1
View File
@@ -12,6 +12,6 @@ ENTRYPOINT ["gitleaks"]
# How to use me : # How to use me :
# docker build -t gitleaks . # docker build -t gitleaks .
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks # docker run --rm --name=gitleaks gitleaks --repo-url=https://github.com/zricethezav/gitleaks
# This will check for secrets in https://github.com/zricethezav/gitleaks # This will check for secrets in https://github.com/zricethezav/gitleaks
+36 -39
View File
@@ -2,7 +2,6 @@
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" /> <img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
<p align="center"> <p align="center">
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a> <a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
<a href="https://gitter.im/gitleaks/gitleaks"><img alt="Travis" src="https://badges.gitter.im/gitleaks/gitleaks.svg?style=flat-square"></a>
</p> </p>
</p> </p>
@@ -50,42 +49,41 @@ Usage:
gitleaks [OPTIONS] gitleaks [OPTIONS]
Application Options: Application Options:
-v, --verbose Show verbose output from scan -v, --verbose Show verbose output from scan
-q, --quiet Sets log level to error and only output leaks, one json object per line -q, --quiet Sets log level to error and only output leaks, one json object per line
-r, --repo-url= Repository URL -r, --repo-url= Repository URL
-p, --path= Path to directory (repo if contains .git) or file -p, --path= Path to directory (repo if contains .git) or file
-c, --config-path= Path to config -c, --config-path= Path to config
--repo-config-path= Path to gitleaks config relative to repo root --repo-config-path= Path to gitleaks config relative to repo root
--version Version number --clone-path= Path to clone repo to disk
--username= Username for git repo --version Version number
--password= Password for git repo --username= Username for git repo
--access-token= Access token for git repo --password= Password for git repo
--threads= Maximum number of threads gitleaks spawns --access-token= Access token for git repo
--ssh-key= Path to ssh key used for auth --threads= Maximum number of threads gitleaks spawns
--unstaged Run gitleaks on unstaged code --ssh-key= Path to ssh key used for auth
--branch= Branch to scan --unstaged Run gitleaks on unstaged code
--redact Redact secrets from log messages and leaks --branch= Branch to scan
--debug Log debug messages --redact Redact secrets from log messages and leaks
--leaks-exit-code= Exit code when leaks have been encountered (default: 1) --debug Log debug messages
--no-git Treat git repos as plain directories and scan those --no-git Treat git repos as plain directories and scan those files
files --leaks-exit-code= Exit code when leaks have been encountered (default: 1)
-o, --report= Report output path --append-repo-config Append the provided or default config with the repo config.
-f, --format= JSON, CSV, SARIF (default: json) --additional-config= Path to an additional gitleaks config to append with an existing config. Can be used with --append-repo-config to append up to three configurations
--files-at-commit= Sha of commit to scan all files at commit -o, --report= Report output path
--commit= Sha of commit to scan or "latest" to scan the last -f, --format= JSON, CSV, SARIF (default: json)
commit of the repository --files-at-commit= Sha of commit to scan all files at commit
--commits= Comma separated list of a commits to scan --commit= Sha of commit to scan or "latest" to scan the last commit of the repository
--commits-file= Path to file of line separated list of commits to scan --commits= Comma separated list of a commits to scan
--commit-from= Commit to start scan from --commits-file= Path to file of line separated list of commits to scan
--commit-to= Commit to stop scan --commit-from= Commit to start scan from
--commit-since= Scan commits more recent than a specific date. Ex: --commit-to= Commit to stop scan
'2006-01-02' or '2006-01-02T15:04:05-0700' format. --commit-since= Scan commits more recent than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format.
--commit-until= Scan commits older than a specific date. Ex: --commit-until= Scan commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format.
'2006-01-02' or '2006-01-02T15:04:05-0700' format. --depth= Number of commits to scan
--depth= Number of commits to scan
Help Options: Help Options:
-h, --help Show this help message -h, --help Show this help message
``` ```
@@ -255,7 +253,7 @@ You can always set the exit code when leaves are encountered with the `--leaks-e
``` ```
### Sponsors ❤️ ### Sponsors ❤️
#### Corporate Sponsors #### Organization Sponsors
[![gammanet](https://gammanet.com/assets/images/new-design/gamma-logo.png)](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion) [![gammanet](https://gammanet.com/assets/images/new-design/gamma-logo.png)](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
Gamma proactively detects and remediates data leaks across cloud apps. Scan your public repos for secret leaks with [Gamma](https://gammanet.com/github-demo?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion) Gamma proactively detects and remediates data leaks across cloud apps. Scan your public repos for secret leaks with [Gamma](https://gammanet.com/github-demo?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
@@ -263,9 +261,8 @@ Gamma proactively detects and remediates data leaks across cloud apps. Scan your
#### Individual Sponsors #### Individual Sponsors
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks: These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
[![Adam Shannon](https://github.com/adamdecaf.png?size=50)](https://github.com/adamdecaf) | - [Adam Shannon](https://github.com/adamdecaf)
---| - [ProjectDiscovery](https://projectdiscovery.io/#/)
----
#### Logo Attribution #### Logo Attribution
+111 -94
View File
@@ -7,158 +7,175 @@ const DefaultConfig = `
title = "gitleaks config" title = "gitleaks config"
[[rules]] [[rules]]
description = "AWS Access Key" description = "AWS Access Key"
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}''' regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
tags = ["key", "AWS"] tags = ["key", "AWS"]
[[rules]] [[rules]]
description = "AWS Secret Key" description = "AWS Secret Key"
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]''' regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
tags = ["key", "AWS"] tags = ["key", "AWS"]
[[rules]] [[rules]]
description = "AWS MWS key" description = "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}''' 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"] tags = ["key", "AWS", "MWS"]
[[rules]] [[rules]]
description = "Facebook Secret Key" description = "Facebook Secret Key"
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]''' regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
tags = ["key", "Facebook"] tags = ["key", "Facebook"]
[[rules]] [[rules]]
description = "Facebook Client ID" description = "Facebook Client ID"
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]''' regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
tags = ["key", "Facebook"] tags = ["key", "Facebook"]
[[rules]] [[rules]]
description = "Twitter Secret Key" description = "Twitter Secret Key"
regex = '''(?i)twitter(.{0,20})?[0-9a-z]{35,44}''' regex = '''(?i)twitter(.{0,20})?[0-9a-z]{35,44}'''
tags = ["key", "Twitter"] tags = ["key", "Twitter"]
[[rules]] [[rules]]
description = "Twitter Client ID" description = "Twitter Client ID"
regex = '''(?i)twitter(.{0,20})?[0-9a-z]{18,25}''' regex = '''(?i)twitter(.{0,20})?[0-9a-z]{18,25}'''
tags = ["client", "Twitter"] tags = ["client", "Twitter"]
[[rules]] [[rules]]
description = "Github" description = "Github Personal Access Token"
regex = '''(?i)github.{0,3}((?i)token|api|key).{0,10}?(?-i)([0-9a-zA-Z]{35,40})''' regex = '''ghp_[0-9a-zA-Z]{36}'''
tags = ["key", "Github"] tags = ["key", "Github"]
[[rules]]
description = "Github OAuth Access Token"
regex = '''gho_[0-9a-zA-Z]{36}'''
tags = ["key", "Github"]
[[rules]]
description = "Github App Token"
regex = '''(ghu|ghs)_[0-9a-zA-Z]{36}'''
tags = ["key", "Github"]
[[rules]]
description = "Github Refresh Token"
regex = '''ghr_[0-9a-zA-Z]{76}'''
tags = ["key", "Github"]
[[rules]] [[rules]]
description = "LinkedIn Client ID" description = "LinkedIn Client ID"
regex = '''(?i)linkedin(.{0,20})?(?-i)[0-9a-z]{12}''' regex = '''(?i)linkedin(.{0,20})?(?-i)[0-9a-z]{12}'''
tags = ["client", "LinkedIn"] tags = ["client", "LinkedIn"]
[[rules]] [[rules]]
description = "LinkedIn Secret Key" description = "LinkedIn Secret Key"
regex = '''(?i)linkedin(.{0,20})?[0-9a-z]{16}''' regex = '''(?i)linkedin(.{0,20})?[0-9a-z]{16}'''
tags = ["secret", "LinkedIn"] tags = ["secret", "LinkedIn"]
[[rules]] [[rules]]
description = "Slack" description = "Slack"
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?''' regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
tags = ["key", "Slack"] tags = ["key", "Slack"]
[[rules]] [[rules]]
description = "Asymmetric Private Key" description = "Asymmetric Private Key"
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----''' regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
tags = ["key", "AsymmetricPrivateKey"] tags = ["key", "AsymmetricPrivateKey"]
[[rules]] [[rules]]
description = "Google API key" description = "Google API key"
regex = '''AIza[0-9A-Za-z\\-_]{35}''' regex = '''AIza[0-9A-Za-z\\-_]{35}'''
tags = ["key", "Google"] tags = ["key", "Google"]
[[rules]] [[rules]]
description = "Google (GCP) Service Account" description = "Google (GCP) Service Account"
regex = '''"type": "service_account"''' regex = '''"type": "service_account"'''
tags = ["key", "Google"] tags = ["key", "Google"]
[[rules]] [[rules]]
description = "Heroku API key" 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}''' regex = '''(?i)heroku(.{0,20})?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
tags = ["key", "Heroku"] tags = ["key", "Heroku"]
[[rules]] [[rules]]
description = "MailChimp API key" description = "MailChimp API key"
regex = '''(?i)(mailchimp|mc)(.{0,20})?[0-9a-f]{32}-us[0-9]{1,2}''' regex = '''(?i)(mailchimp|mc)(.{0,20})?[0-9a-f]{32}-us[0-9]{1,2}'''
tags = ["key", "Mailchimp"] tags = ["key", "Mailchimp"]
[[rules]] [[rules]]
description = "Mailgun API key" description = "Mailgun API key"
regex = '''((?i)(mailgun|mg)(.{0,20})?)?key-[0-9a-z]{32}''' regex = '''((?i)(mailgun|mg)(.{0,20})?)?key-[0-9a-z]{32}'''
tags = ["key", "Mailgun"] tags = ["key", "Mailgun"]
[[rules]] [[rules]]
description = "PayPal Braintree access token" description = "PayPal Braintree access token"
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}''' regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
tags = ["key", "Paypal"] tags = ["key", "Paypal"]
[[rules]] [[rules]]
description = "Picatic API key" description = "Picatic API key"
regex = '''sk_live_[0-9a-z]{32}''' regex = '''sk_live_[0-9a-z]{32}'''
tags = ["key", "Picatic"] tags = ["key", "Picatic"]
[[rules]] [[rules]]
description = "SendGrid API Key" description = "SendGrid API Key"
regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}''' regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}'''
tags = ["key", "SendGrid"] tags = ["key", "SendGrid"]
[[rules]] [[rules]]
description = "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}''' 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"] tags = ["key", "slack"]
[[rules]] [[rules]]
description = "Stripe API key" description = "Stripe API key"
regex = '''(?i)stripe(.{0,20})?[sr]k_live_[0-9a-zA-Z]{24}''' regex = '''(?i)stripe(.{0,20})?[sr]k_live_[0-9a-zA-Z]{24}'''
tags = ["key", "Stripe"] tags = ["key", "Stripe"]
[[rules]] [[rules]]
description = "Square access token" description = "Square access token"
regex = '''sq0atp-[0-9A-Za-z\-_]{22}''' regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
tags = ["key", "square"] tags = ["key", "square"]
[[rules]] [[rules]]
description = "Square OAuth secret" description = "Square OAuth secret"
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}''' regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
tags = ["key", "square"] tags = ["key", "square"]
[[rules]] [[rules]]
description = "Twilio API key" description = "Twilio API key"
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}''' regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
tags = ["key", "twilio"] tags = ["key", "twilio"]
[[rules]] [[rules]]
description = "Dynatrace ttoken" description = "Dynatrace ttoken"
regex = '''dt0[a-zA-Z]{1}[0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}''' regex = '''dt0[a-zA-Z]{1}[0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}'''
tags = ["key", "Dynatrace"] tags = ["key", "Dynatrace"]
[[rules]] [[rules]]
description = "Shopify shared secret" description = "Shopify shared secret"
regex = '''shpss_[a-fA-F0-9]{32}''' regex = '''shpss_[a-fA-F0-9]{32}'''
tags = ["key", "Shopify"] tags = ["key", "Shopify"]
[[rules]] [[rules]]
description = "Shopify access token" description = "Shopify access token"
regex = '''shpat_[a-fA-F0-9]{32}''' regex = '''shpat_[a-fA-F0-9]{32}'''
tags = ["key", "Shopify"] tags = ["key", "Shopify"]
[[rules]] [[rules]]
description = "Shopify custom app access token" description = "Shopify custom app access token"
regex = '''shpca_[a-fA-F0-9]{32}''' regex = '''shpca_[a-fA-F0-9]{32}'''
tags = ["key", "Shopify"] tags = ["key", "Shopify"]
[[rules]] [[rules]]
description = "Shopify private app access token" description = "Shopify private app access token"
regex = '''shppa_[a-fA-F0-9]{32}''' regex = '''shppa_[a-fA-F0-9]{32}'''
tags = ["key", "Shopify"] tags = ["key", "Shopify"]
[[rules]]
description = "PyPI upload token"
regex = '''pypi-AgEIcHlwaS5vcmc[A-Za-z0-9-_]{50,1000}'''
tags = ["key", "pypi"]
[allowlist] [allowlist]
description = "Allowlisted files" description = "Allowlisted files"
files = ['''^\.?gitleaks.toml$''', files = ['''^\.?gitleaks.toml$''',
'''(.*?)(png|jpg|gif|doc|docx|pdf|bin|xls|pyc|zip)$''', '''(.*?)(png|jpg|gif|doc|docx|pdf|bin|xls|pyc|zip)$''',
'''(go.mod|go.sum)$'''] '''(go.mod|go.sum)$''']
` `
+14
View File
@@ -0,0 +1,14 @@
# pre-commit configuration example to add docker-based hook that executes gitleaks
# This should be added to .pre-commit-config.yaml coniguration file: https://pre-commit.com/#2-add-a-pre-commit-configuration
repos:
- repo: local
hooks:
- id: gitleaks
name: Gitleaks
language: docker_image
entry: zricethezav/gitleaks:v7.4.0
args:
- --config-path
- .gitleaks.toml
- --verbose
+6
View File
@@ -184,6 +184,12 @@ func (us *UnstagedScanner) Scan() (Report, error) {
} }
} }
// Check if file is allow listed
if us.cfg.Allowlist.FileAllowed(filepath.Base(filename)) ||
us.cfg.Allowlist.PathAllowed(filename) {
continue
}
dmp := diffmatchpatch.New() dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(prevFileContents, currFileContents, false) diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
prettyDiff := diffPrettyText(diffs) prettyDiff := diffPrettyText(diffs)