mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eb57cbe4d | ||
|
|
3531887941 | ||
|
|
e9ebde73bc | ||
|
|
469cd22f61 | ||
|
|
93e72c215d | ||
|
|
865478bcdc | ||
|
|
d6c0de7c85 | ||
|
|
0266ab8958 | ||
|
|
6b7ab73a52 |
No files matched your search
@@ -16,6 +16,9 @@
|
|||||||
<a href="https://hub.docker.com/r/zricethezav/gitleaks">
|
<a href="https://hub.docker.com/r/zricethezav/gitleaks">
|
||||||
<img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" />
|
<img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" />
|
||||||
</a>
|
</a>
|
||||||
|
<a href="https://www.jit.io/jit-open-source-gitleaks?utm_source=github&utm_medium=badge&utm_campaign=GitleaksReadme&utm_id=oss&items=item-secret-detection">
|
||||||
|
<img src="https://img.shields.io/badge/Secured%20by-Jit-B8287F?style=?style=plastic" />
|
||||||
|
</a>
|
||||||
<a href="https://twitter.com/intent/follow?screen_name=zricethezav">
|
<a href="https://twitter.com/intent/follow?screen_name=zricethezav">
|
||||||
<img src="https://img.shields.io/twitter/follow/zricethezav?label=Follow%20zricethezav&style=social&color=blue" alt="Follow @zricethezav" />
|
<img src="https://img.shields.io/twitter/follow/zricethezav?label=Follow%20zricethezav&style=social&color=blue" alt="Follow @zricethezav" />
|
||||||
</a>
|
</a>
|
||||||
@@ -124,7 +127,7 @@ When running `detect` on a git repository, gitleaks will parse the output of a `
|
|||||||
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L17-L25)).
|
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L17-L25)).
|
||||||
[`git log -p` generates patches](https://git-scm.com/docs/git-log#_generating_patch_text_with_p) which gitleaks will use to detect secrets.
|
[`git log -p` generates patches](https://git-scm.com/docs/git-log#_generating_patch_text_with_p) which gitleaks will use to detect secrets.
|
||||||
You can configure what commits `git log` will range over by using the `--log-opts` flag. `--log-opts` accepts any option for `git log -p`.
|
You can configure what commits `git log` will range over by using the `--log-opts` flag. `--log-opts` accepts any option for `git log -p`.
|
||||||
For example, if you wanted to run gitleaks on a range of commits you could use the following command: `gitleaks --source . --log-opts="--all commitA..commitB"`.
|
For example, if you wanted to run gitleaks on a range of commits you could use the following command: `gitleaks detect --source . --log-opts="--all commitA..commitB"`.
|
||||||
See the `git log` [documentation](https://git-scm.com/docs/git-log) for more information.
|
See the `git log` [documentation](https://git-scm.com/docs/git-log) for more information.
|
||||||
|
|
||||||
You can scan files and directories by using the `--no-git` option.
|
You can scan files and directories by using the `--no-git` option.
|
||||||
@@ -283,6 +286,8 @@ stopwords = [
|
|||||||
```
|
```
|
||||||
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples and advice on writing regular expressions for secret detection.
|
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples and advice on writing regular expressions for secret detection.
|
||||||
|
|
||||||
|
## Secured by Jit
|
||||||
|
We use [Jit](https://www.jit.io/jit-open-source-gitleaks?utm_source=github&utm_medium=readme&utm_campaign=GitleaksReadme&utm_id=oss&items=item-secret-detection) to secure our codebase, to achieve fully automated, full-stack continuous security using the world's best OSS security tools.
|
||||||
|
|
||||||
|
|
||||||
## Sponsorships
|
## Sponsorships
|
||||||
@@ -290,10 +295,6 @@ Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/b
|
|||||||
<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
|
<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
|
||||||
<img alt="Tines Sponsorship" src="https://user-images.githubusercontent.com/15034943/146411864-4878f936-b4f7-49a0-b625-f9f40c704bfa.png" width=200>
|
<img alt="Tines Sponsorship" src="https://user-images.githubusercontent.com/15034943/146411864-4878f936-b4f7-49a0-b625-f9f40c704bfa.png" width=200>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
|
||||||
<a href="https://www.typeform.com/">
|
|
||||||
<img src="https://user-images.githubusercontent.com/15034943/146945294-a6473d55-86b8-4f53-941e-7f185ad6b3d7.png" width=200/>
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ func main() {
|
|||||||
configRules = append(configRules, rules.AdobeClientID())
|
configRules = append(configRules, rules.AdobeClientID())
|
||||||
configRules = append(configRules, rules.AdobeClientSecret())
|
configRules = append(configRules, rules.AdobeClientSecret())
|
||||||
configRules = append(configRules, rules.AgeSecretKey())
|
configRules = append(configRules, rules.AgeSecretKey())
|
||||||
|
configRules = append(configRules, rules.AlgoliaApiKey())
|
||||||
configRules = append(configRules, rules.AlibabaAccessKey())
|
configRules = append(configRules, rules.AlibabaAccessKey())
|
||||||
configRules = append(configRules, rules.AlibabaSecretKey())
|
configRules = append(configRules, rules.AlibabaSecretKey())
|
||||||
configRules = append(configRules, rules.AsanaClientID())
|
configRules = append(configRules, rules.AsanaClientID())
|
||||||
@@ -80,7 +81,8 @@ func main() {
|
|||||||
configRules = append(configRules, rules.NewRelicBrowserAPIKey())
|
configRules = append(configRules, rules.NewRelicBrowserAPIKey())
|
||||||
configRules = append(configRules, rules.NPM())
|
configRules = append(configRules, rules.NPM())
|
||||||
configRules = append(configRules, rules.PlanetScalePassword())
|
configRules = append(configRules, rules.PlanetScalePassword())
|
||||||
configRules = append(configRules, rules.PlanetScaleToken())
|
configRules = append(configRules, rules.PlanetScaleAPIToken())
|
||||||
|
configRules = append(configRules, rules.PlanetScaleOAuthToken())
|
||||||
configRules = append(configRules, rules.PostManAPI())
|
configRules = append(configRules, rules.PostManAPI())
|
||||||
configRules = append(configRules, rules.PrivateKey())
|
configRules = append(configRules, rules.PrivateKey())
|
||||||
configRules = append(configRules, rules.PulumiAPIToken())
|
configRules = append(configRules, rules.PulumiAPIToken())
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AlgoliaApiKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Algolia API Key",
|
||||||
|
RuleID: "algolia-api-key",
|
||||||
|
Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`),
|
||||||
|
Keywords: []string{"algolia"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"algolia_key := " + secrets.NewSecret(hex("32")),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -13,9 +13,9 @@ func GenericCredential() *config.Rule {
|
|||||||
"key",
|
"key",
|
||||||
"api[^Version]",
|
"api[^Version]",
|
||||||
"token",
|
"token",
|
||||||
"pat",
|
|
||||||
"secret",
|
"secret",
|
||||||
"client",
|
"client",
|
||||||
|
"passwd",
|
||||||
"password",
|
"password",
|
||||||
"auth",
|
"auth",
|
||||||
}, `[0-9a-z\-_.=]{10,150}`),
|
}, `[0-9a-z\-_.=]{10,150}`),
|
||||||
@@ -26,7 +26,7 @@ func GenericCredential() *config.Rule {
|
|||||||
"token",
|
"token",
|
||||||
"secret",
|
"secret",
|
||||||
"client",
|
"client",
|
||||||
"pat",
|
"passwd",
|
||||||
"password",
|
"password",
|
||||||
"auth",
|
"auth",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func PlanetScalePassword() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "planetscale-password",
|
RuleID: "planetscale-password",
|
||||||
Description: "PlanetScale password",
|
Description: "PlanetScale password",
|
||||||
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{43}`),
|
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`),
|
||||||
SecretGroup: 1,
|
SecretGroup: 1,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pscale_pw_",
|
"pscale_pw_",
|
||||||
@@ -19,17 +19,19 @@ func PlanetScalePassword() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||||
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlanetScaleToken() *config.Rule {
|
func PlanetScaleAPIToken() *config.Rule {
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "planetscale-api-token",
|
RuleID: "planetscale-api-token",
|
||||||
Description: "PlanetScale API token",
|
Description: "PlanetScale API token",
|
||||||
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{43}`),
|
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`),
|
||||||
SecretGroup: 1,
|
SecretGroup: 1,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pscale_tkn_",
|
"pscale_tkn_",
|
||||||
@@ -38,7 +40,30 @@ func PlanetScaleToken() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||||
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PlanetScaleOAuthToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "planetscale-oauth-token",
|
||||||
|
Description: "PlanetScale OAuth token",
|
||||||
|
Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`),
|
||||||
|
SecretGroup: 1,
|
||||||
|
Keywords: []string{
|
||||||
|
"pscale_oauth_",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||||
|
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -1484,4 +1484,6 @@ var DefaultStopWords = []string{
|
|||||||
"boot",
|
"boot",
|
||||||
"book",
|
"book",
|
||||||
"branch",
|
"branch",
|
||||||
|
"combination",
|
||||||
|
"combo",
|
||||||
}
|
}
|
||||||
+23
-4
@@ -42,6 +42,14 @@ keywords = [
|
|||||||
"age-secret-key-1",
|
"age-secret-key-1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Algolia API Key"
|
||||||
|
id = "algolia-api-key"
|
||||||
|
regex = '''(?i)(?:algolia)(?:[0-9a-z\-_\s.]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}([a-z0-9]{32})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
||||||
|
keywords = [
|
||||||
|
"algolia",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Alibaba AccessKey ID"
|
description = "Alibaba AccessKey ID"
|
||||||
id = "alibaba-access-key-id"
|
id = "alibaba-access-key-id"
|
||||||
@@ -545,7 +553,7 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "PlanetScale password"
|
description = "PlanetScale password"
|
||||||
id = "planetscale-password"
|
id = "planetscale-password"
|
||||||
regex = '''(?i)\b(pscale_pw_(?i)[a-z0-9=\-_\.]{43})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
regex = '''(?i)\b(pscale_pw_(?i)[a-z0-9=\-_\.]{32,64})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
||||||
secretGroup = 1
|
secretGroup = 1
|
||||||
keywords = [
|
keywords = [
|
||||||
"pscale_pw_",
|
"pscale_pw_",
|
||||||
@@ -554,12 +562,21 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "PlanetScale API token"
|
description = "PlanetScale API token"
|
||||||
id = "planetscale-api-token"
|
id = "planetscale-api-token"
|
||||||
regex = '''(?i)\b(pscale_tkn_(?i)[a-z0-9=\-_\.]{43})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
regex = '''(?i)\b(pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
||||||
secretGroup = 1
|
secretGroup = 1
|
||||||
keywords = [
|
keywords = [
|
||||||
"pscale_tkn_",
|
"pscale_tkn_",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "PlanetScale OAuth token"
|
||||||
|
id = "planetscale-oauth-token"
|
||||||
|
regex = '''(?i)\b(pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
||||||
|
secretGroup = 1
|
||||||
|
keywords = [
|
||||||
|
"pscale_oauth_",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Postman API token"
|
description = "Postman API token"
|
||||||
id = "postman-api-token"
|
id = "postman-api-token"
|
||||||
@@ -724,11 +741,11 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Generic API Key"
|
description = "Generic API Key"
|
||||||
id = "generic-api-key"
|
id = "generic-api-key"
|
||||||
regex = '''(?i)(?:key|api[^Version]|token|pat|secret|client|password|auth)(?:[0-9a-z\-_\s.]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}([0-9a-z\-_.=]{10,150})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
regex = '''(?i)(?:key|api[^Version]|token|secret|client|passwd|password|auth)(?:[0-9a-z\-_\s.]{0,20})(?:[\s|']|[\s|"]){0,3}(?:=|>|:=|\|\|:|<=|=>|:)(?:'|\"|\s|=|\x60){0,5}([0-9a-z\-_.=]{10,150})(?:['|\"|\n|\r|\s|\x60]|$)'''
|
||||||
secretGroup = 1
|
secretGroup = 1
|
||||||
entropy = 3.5
|
entropy = 3.5
|
||||||
keywords = [
|
keywords = [
|
||||||
"key","api","token","secret","client","pat","password","auth",
|
"key","api","token","secret","client","passwd","password","auth",
|
||||||
]
|
]
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
stopwords= [
|
stopwords= [
|
||||||
@@ -2204,4 +2221,6 @@ stopwords= [
|
|||||||
"boot",
|
"boot",
|
||||||
"book",
|
"book",
|
||||||
"branch",
|
"branch",
|
||||||
|
"combination",
|
||||||
|
"combo",
|
||||||
]
|
]
|
||||||
@@ -65,7 +65,6 @@ func filter(findings []report.Finding, redact bool) []report.Finding {
|
|||||||
if strings.Contains(strings.ToLower(f.RuleID), "generic") {
|
if strings.Contains(strings.ToLower(f.RuleID), "generic") {
|
||||||
for _, fPrime := range findings {
|
for _, fPrime := range findings {
|
||||||
if f.StartLine == fPrime.StartLine &&
|
if f.StartLine == fPrime.StartLine &&
|
||||||
f.EndLine == fPrime.EndLine &&
|
|
||||||
f.Commit == fPrime.Commit &&
|
f.Commit == fPrime.Commit &&
|
||||||
f.RuleID != fPrime.RuleID &&
|
f.RuleID != fPrime.RuleID &&
|
||||||
strings.Contains(fPrime.Secret, f.Secret) &&
|
strings.Contains(fPrime.Secret, f.Secret) &&
|
||||||
|
|||||||
Reference in new issue
Block a user