Skip to content

Commit

Permalink
Scan commit in since-commit (#416)
Browse files Browse the repository at this point in the history
* Scan commit in since-commit.

Fixes #413

* address lint issue

Co-authored-by: Dustin Decker <dustin@trufflesec.com>
  • Loading branch information
bill-rich and dustin-decker authored Apr 15, 2022
1 parent b970c43 commit 1f55171
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/sources/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,21 @@ func (s *Git) ScanCommits(repo *git.Repository, path string, scanOptions *ScanOp
urlMetadata := getSafeRemoteURL(repo, "origin")

var depth int64
var reachedBase = false
for file := range fileChan {
log.WithField("commit", file.PatchHeader.SHA).WithField("file", file.NewName).Trace("Scanning file from git")
if scanOptions.MaxDepth > 0 && depth >= scanOptions.MaxDepth {
log.Debugf("reached max depth")
break
}
depth++
if reachedBase && file.PatchHeader.SHA != scanOptions.BaseHash {
break
}
if len(scanOptions.BaseHash) > 0 {
if file.PatchHeader.SHA == scanOptions.BaseHash {
log.Debugf("reached base commit")
break
log.Debugf("Reached base commit. Finishing scanning files.")
reachedBase = true
}
}
if !scanOptions.Filter.Pass(file.NewName) {
Expand Down

0 comments on commit 1f55171

Please sign in to comment.