mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 03:34:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ede68fd95d | ||
|
|
6c60c3dde3 |
+19
-5
@@ -20,11 +20,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
diffAddPrefix = "+"
|
||||
diffAddFilePrefix = "+++ b"
|
||||
diffAddFilePrefixSlash = "+++ b/"
|
||||
diffLineSignature = " @@"
|
||||
defaultLineNumber = -1
|
||||
diffAddPrefix = "+"
|
||||
diffAddFilePrefix = "+++ b"
|
||||
diffAddFilePrefixSlash = "+++ b/"
|
||||
diffLineSignature = " @@"
|
||||
diffLineSignaturePrefix = "@@ "
|
||||
defaultLineNumber = -1
|
||||
)
|
||||
|
||||
// CheckRules accepts bundle and checks each rule defined in the config against the bundle's content.
|
||||
@@ -238,6 +239,19 @@ func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo)
|
||||
leak.LineNumber = potentialLine
|
||||
return
|
||||
}
|
||||
} else if strings.HasPrefix(txt, diffLineSignaturePrefix) && currStartDiffLine != 0 {
|
||||
// This logic is used for when there are multiple leaks of the same offender within the same patch
|
||||
i := strings.Index(txt, diffAddPrefix)
|
||||
pairs := strings.Split(strings.Split(txt[i+1:], diffLineSignature)[0], ",")
|
||||
currStartDiffLine, err = strconv.Atoi(pairs[0])
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
return
|
||||
}
|
||||
currLine = 0
|
||||
if !strings.HasSuffix(txt, diffLineSignature) {
|
||||
currLine = -1
|
||||
}
|
||||
}
|
||||
currLine++
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user