mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61ee7c58cc | ||
|
|
ad7509e3b4 | ||
|
|
a62cc52aba |
No files matched your search
@@ -12,12 +12,17 @@ func PrivateKey() *config.Rule {
|
|||||||
Description: "Private Key",
|
Description: "Private Key",
|
||||||
RuleID: "private-key",
|
RuleID: "private-key",
|
||||||
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----`),
|
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----`),
|
||||||
Keywords: []string{"-----BEGIN PRIVATE"},
|
Keywords: []string{"-----BEGIN"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{`-----BEGIN PRIVATE KEY-----
|
tps := []string{`-----BEGIN PRIVATE KEY-----
|
||||||
anything
|
anything
|
||||||
-----END PRIVATE KEY-----`} // gitleaks:allow
|
-----END PRIVATE KEY-----`,
|
||||||
|
`-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
abcdefghijklmnopqrstuvwxyz
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
|
`,
|
||||||
|
} // gitleaks:allow
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -574,7 +574,7 @@ description = "Private Key"
|
|||||||
id = "private-key"
|
id = "private-key"
|
||||||
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----'''
|
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"-----begin private",
|
"-----begin",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
|
|||||||
+1
-1
@@ -335,7 +335,7 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if fInfo.Name() == ".git" {
|
if fInfo.Name() == ".git" && fInfo.IsDir() {
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
if fInfo.Mode().IsRegular() {
|
if fInfo.Mode().IsRegular() {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func location(fragment Fragment, matchIndex []int) Location {
|
|||||||
end := matchIndex[1]
|
end := matchIndex[1]
|
||||||
|
|
||||||
for lineNum, pair := range fragment.newlineIndices {
|
for lineNum, pair := range fragment.newlineIndices {
|
||||||
|
_lineNum = lineNum
|
||||||
newLineByteIndex := pair[0]
|
newLineByteIndex := pair[0]
|
||||||
if prevNewLine <= start && start < newLineByteIndex {
|
if prevNewLine <= start && start < newLineByteIndex {
|
||||||
lineSet = true
|
lineSet = true
|
||||||
|
|||||||
Reference in new issue
Block a user