mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ede68fd95d | ||
|
|
6c60c3dde3 |
+19
-5
@@ -20,11 +20,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
diffAddPrefix = "+"
|
diffAddPrefix = "+"
|
||||||
diffAddFilePrefix = "+++ b"
|
diffAddFilePrefix = "+++ b"
|
||||||
diffAddFilePrefixSlash = "+++ b/"
|
diffAddFilePrefixSlash = "+++ b/"
|
||||||
diffLineSignature = " @@"
|
diffLineSignature = " @@"
|
||||||
defaultLineNumber = -1
|
diffLineSignaturePrefix = "@@ "
|
||||||
|
defaultLineNumber = -1
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckRules accepts bundle and checks each rule defined in the config against the bundle's content.
|
// 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
|
leak.LineNumber = potentialLine
|
||||||
return
|
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++
|
currLine++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user