Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: edge case where scan never completes #258

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . .
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o /app/2ms .

# Runtime image
FROM cgr.dev/chainguard/git@sha256:0663e8c8a5c6fcad6cc2c08e7668d7b46f7aee025a923cee19f69475e187752a
FROM cgr.dev/chainguard/git@sha256:91f984bed3cef8b6b9bdefb8e4ae2c9ec2c28564b237c2a0e432549c105ceb16

WORKDIR /app

Expand Down
6 changes: 6 additions & 0 deletions plugins/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func (p *GitPlugin) scanGit(path string, scanOptions string, itemsChan chan ISou
defer close()

for file := range diffs {
if file.PatchHeader == nil {
// While parsing the PatchHeader, the token size limit may be exceeded, resulting in a nil value.
// This scenario is unlikely, but it causes the scan to never complete.
file.PatchHeader = &gitdiff.PatchHeader{}
}

log.Debug().Msgf("file: %s; Commit: %s", file.NewName, file.PatchHeader.Title)
if file.IsBinary || file.IsDelete {
continue
Expand Down