mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b3f10cb79 | ||
|
|
6748a89bf4 | ||
|
|
6f6e057042 | ||
|
|
b8f236c9b3 |
No files matched your search
+715
-653
File diff suppressed because it is too large.
Load diff
@@ -369,8 +369,7 @@ class CustomClass:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### .gitleaksignore
|
#### .gitleaksignore
|
||||||
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example.
|
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is expirmental and is subject to change in the future.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Secured by Jit
|
## Secured by Jit
|
||||||
|
|||||||
+16
-2
@@ -71,8 +71,7 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for a .gitleaksignore file
|
if fileExists(filepath.Join(source, ".gitleaksignore")) {
|
||||||
if info, err := os.Stat(filepath.Join(source, ".gitleaksignore")); !os.IsNotExist(err) && !info.IsDir() {
|
|
||||||
detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore"))
|
detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,3 +130,18 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fileExists(fileName string) bool {
|
||||||
|
// check for a .gitleaksignore file
|
||||||
|
info, err := os.Stat(fileName)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if info != nil && err == nil {
|
||||||
|
if !info.IsDir() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -450,6 +450,11 @@ func (d *Detector) Detect(fragment Fragment) []report.Finding {
|
|||||||
|
|
||||||
// addFinding synchronously adds a finding to the findings slice
|
// addFinding synchronously adds a finding to the findings slice
|
||||||
func (d *Detector) addFinding(finding report.Finding) {
|
func (d *Detector) addFinding(finding report.Finding) {
|
||||||
|
if finding.Commit == "" {
|
||||||
|
finding.Fingerprint = fmt.Sprintf("%s:%s:%d", finding.File, finding.RuleID, finding.StartLine)
|
||||||
|
} else {
|
||||||
|
finding.Fingerprint = fmt.Sprintf("%s:%s:%s:%d", finding.Commit, finding.File, finding.RuleID, finding.StartLine)
|
||||||
|
}
|
||||||
// check if we should ignore this finding
|
// check if we should ignore this finding
|
||||||
if _, ok := d.gitleaksIgnore[finding.Fingerprint]; ok {
|
if _, ok := d.gitleaksIgnore[finding.Fingerprint]; ok {
|
||||||
log.Debug().Msgf("ignoring finding with Fingerprint %s",
|
log.Debug().Msgf("ignoring finding with Fingerprint %s",
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ func TestFromGit(t *testing.T) {
|
|||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
Fingerprint: "d0ce473c3c9f6934e8d274604cf9ceae63700f03",
|
Fingerprint: "1b6da43b82b22e4eaa10bcf8ee591e91abbfc587:main.go:aws-access-key:20",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Description: "AWS Access Key",
|
Description: "AWS Access Key",
|
||||||
@@ -386,7 +386,7 @@ func TestFromGit(t *testing.T) {
|
|||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
Fingerprint: "df8d271fa20b928dfb12353cc16ddf9934225cb7",
|
Fingerprint: "491504d5a31946ce75e22554cc34203d8e5ff3ca:foo/foo.go:aws-access-key:9",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -412,7 +412,7 @@ func TestFromGit(t *testing.T) {
|
|||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
Fingerprint: "df8d271fa20b928dfb12353cc16ddf9934225cb7",
|
Fingerprint: "491504d5a31946ce75e22554cc34203d8e5ff3ca:foo/foo.go:aws-access-key:9",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -483,6 +483,7 @@ func TestFromFiles(t *testing.T) {
|
|||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
|
Fingerprint: "../testdata/repos/nogit/main.go:aws-access-key:20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -502,6 +503,7 @@ func TestFromFiles(t *testing.T) {
|
|||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
|
Fingerprint: "../testdata/repos/nogit/main.go:aws-access-key:20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package detect
|
package detect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@@ -22,11 +21,6 @@ func augmentGitFinding(finding report.Finding, textFragment *gitdiff.TextFragmen
|
|||||||
finding.EndLine += int(textFragment.NewPosition)
|
finding.EndLine += int(textFragment.NewPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate finding hash
|
|
||||||
h := sha1.New()
|
|
||||||
h.Write([]byte(fmt.Sprintf("%s:%s:%s:%d", finding.Commit, finding.File, finding.RuleID, finding.StartLine)))
|
|
||||||
finding.Fingerprint = fmt.Sprintf("%x", h.Sum(nil))
|
|
||||||
|
|
||||||
if f.PatchHeader != nil {
|
if f.PatchHeader != nil {
|
||||||
finding.Commit = f.PatchHeader.SHA
|
finding.Commit = f.PatchHeader.SHA
|
||||||
finding.Message = f.PatchHeader.Message()
|
finding.Message = f.PatchHeader.Message()
|
||||||
|
|||||||
Reference in new issue
Block a user