mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
128cd22f7c | ||
|
|
1a6d2b0a7a | ||
|
|
0874ebcc3f |
No files matched your search
@@ -24,6 +24,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
- name: Validate Config
|
|
||||||
run: go generate ./... && git diff --exit-code
|
|
||||||
@@ -208,54 +208,6 @@ gitleaks git --baseline-path gitleaks-report.json --report-path findings.json
|
|||||||
|
|
||||||
After running the detect command with the --baseline-path parameter, report output (findings.json) will only contain new issues.
|
After running the detect command with the --baseline-path parameter, report output (findings.json) will only contain new issues.
|
||||||
|
|
||||||
### Verify Findings
|
|
||||||
|
|
||||||
You can verify a finding found by gitleaks using a `git log` command.
|
|
||||||
Example output:
|
|
||||||
|
|
||||||
```
|
|
||||||
Finding: aws_secret="AKIAIMNOJVGFDXXXE4OA"
|
|
||||||
RuleID: aws-access-token
|
|
||||||
Secret AKIAIMNOJVGFDXXXE4OA
|
|
||||||
Entropy: 3.65
|
|
||||||
File: checks_test.go
|
|
||||||
Line: 37
|
|
||||||
Commit: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
|
||||||
Author: Zachary Rice
|
|
||||||
Email: z@email.com
|
|
||||||
Date: 2018-01-28T17:39:00Z
|
|
||||||
Fingerprint: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29:checks_test.go:aws-access-token:37
|
|
||||||
```
|
|
||||||
|
|
||||||
We can use the following format to verify the leak:
|
|
||||||
|
|
||||||
```
|
|
||||||
git log -L {StartLine,EndLine}:{File} {Commit}
|
|
||||||
```
|
|
||||||
|
|
||||||
So in this example it would look like:
|
|
||||||
|
|
||||||
```
|
|
||||||
git log -L 37,37:checks_test.go ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
|
||||||
```
|
|
||||||
|
|
||||||
Which gives us:
|
|
||||||
|
|
||||||
```
|
|
||||||
commit ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
|
||||||
Author: zricethezav <thisispublicanyways@gmail.com>
|
|
||||||
Date: Sun Jan 28 17:39:00 2018 -0500
|
|
||||||
|
|
||||||
[update] entropy check
|
|
||||||
|
|
||||||
diff --git a/checks_test.go b/checks_test.go
|
|
||||||
--- a/checks_test.go
|
|
||||||
+++ b/checks_test.go
|
|
||||||
@@ -28,0 +37,1 @@
|
|
||||||
+ "aws_secret= \"AKIAIMNOJVGFDXXXE4OA\"": true,
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## Pre-Commit hook
|
## Pre-Commit hook
|
||||||
|
|
||||||
You can run Gitleaks as a pre-commit hook by copying the example `pre-commit.py` script into
|
You can run Gitleaks as a pre-commit hook by copying the example `pre-commit.py` script into
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ func TestTranslate(t *testing.T) {
|
|||||||
cfg: Config{},
|
cfg: Config{},
|
||||||
wantError: fmt.Errorf("rule |id| is missing or empty, regex: (?i)(discord[a-z0-9_ .\\-,]{0,25})(=|>|:=|\\|\\|:|<=|=>|:).{0,5}['\\\"]([a-h0-9]{64})['\\\"]"),
|
wantError: fmt.Errorf("rule |id| is missing or empty, regex: (?i)(discord[a-z0-9_ .\\-,]{0,25})(=|>|:=|\\|\\|:|<=|=>|:).{0,5}['\\\"]([a-h0-9]{64})['\\\"]"),
|
||||||
},
|
},
|
||||||
{
|
//{
|
||||||
cfgName: "no_regex_or_path",
|
// cfgName: "no_regex_or_path",
|
||||||
cfg: Config{},
|
// cfg: Config{},
|
||||||
wantError: fmt.Errorf("discord-api-key: both |regex| and |path| are empty, this rule will have no effect"),
|
// wantError: fmt.Errorf("discord-api-key: both |regex| and |path| are empty, this rule will have no effect"),
|
||||||
},
|
//},
|
||||||
{
|
{
|
||||||
cfgName: "bad_entropy_group",
|
cfgName: "bad_entropy_group",
|
||||||
cfg: Config{},
|
cfg: Config{},
|
||||||
|
|||||||
+5
-3
@@ -60,10 +60,12 @@ func (r Rule) Validate() error {
|
|||||||
return fmt.Errorf("rule |id| is missing or empty" + context)
|
return fmt.Errorf("rule |id| is missing or empty" + context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: uncomment this once it works with |extend|.
|
||||||
|
// See: https://github.com/gitleaks/gitleaks/issues/1507#issuecomment-2352559213
|
||||||
// Ensure the rule actually matches something.
|
// Ensure the rule actually matches something.
|
||||||
if r.Regex == nil && r.Path == nil {
|
//if r.Regex == nil && r.Path == nil {
|
||||||
return fmt.Errorf("%s: both |regex| and |path| are empty, this rule will have no effect", r.RuleID)
|
// return fmt.Errorf("%s: both |regex| and |path| are empty, this rule will have no effect", r.RuleID)
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Ensure |secretGroup| works.
|
// Ensure |secretGroup| works.
|
||||||
if r.Regex != nil && r.SecretGroup > r.Regex.NumSubexp() {
|
if r.Regex != nil && r.SecretGroup > r.Regex.NumSubexp() {
|
||||||
|
|||||||
Reference in new issue
Block a user