diff --git a/github.go b/github.go index 201259c6..b07e1cee 100644 --- a/github.go +++ b/github.go @@ -51,6 +51,10 @@ func auditGithubPR() ([]Leak, error) { } files := commit.Files for _, f := range files { + if f.Patch == nil || f.Filename == nil { + continue + } + diff := gitDiff{ sha: commit.GetSHA(), content: *f.Patch, diff --git a/gitleaks_test.go b/gitleaks_test.go index 5db7c76a..54bae5e8 100644 --- a/gitleaks_test.go +++ b/gitleaks_test.go @@ -311,6 +311,15 @@ func TestRun(t *testing.T) { regexp.MustCompile("main.go"), }, }, + { + testOpts: Options{ + GithubPR: "https://github.com/gitleakstest/gronit/pull/2", + }, + description: "test github pr with commits without patch info", + numLeaks: 0, + expectedErrMsg: "", + commitPerPage: 1, + }, } g := goblin.Goblin(t) for _, test := range tests {