mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
adding recover for patch generation (#534)
This commit is contained in:
1 parent
a10ae91ba7
commit
b3bed5658d
1 file changed
+9
-1
+9
-1
@@ -43,6 +43,14 @@ func (cs *CommitScanner) SetRepoName(repoName string) {
|
||||
func (cs *CommitScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
// sometimes the Patch generation will fail due to a known bug in
|
||||
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
if cs.cfg.Allowlist.CommitAllowed(cs.commit.Hash.String()) {
|
||||
return scannerReport, nil
|
||||
}
|
||||
@@ -62,7 +70,7 @@ func (cs *CommitScanner) Scan() (Report, error) {
|
||||
}
|
||||
|
||||
patch, err := parent.Patch(cs.commit)
|
||||
if err != nil {
|
||||
if err != nil || patch == nil {
|
||||
return scannerReport, fmt.Errorf("could not generate Patch")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user