Skip to content

Find, verify, and analyze leaked credentials

Fix binary file hanging bug in git sources (#2388)

Miccah01c9ac7b593d
diff --git a/pkg/gitparse/gitparse.go b/pkg/gitparse/gitparse.go
index 4a3731245..627546793 100644
--- a/pkg/gitparse/gitparse.go
+++ b/pkg/gitparse/gitparse.go
@@ -375,6 +375,9 @@ func (c *Parser) executeCommand(ctx context.Context, cmd *exec.Cmd, isStaged boo
go func() {
c.FromReader(ctx, stdOut, commitChan, isStaged)
+ if err := stdOut.Close(); err != nil {
+ ctx.Logger().V(2).Info("Error closing git stdout pipe.", "error", err)
+ }
if err := cmd.Wait(); err != nil {
ctx.Logger().V(2).Info("Error waiting for git command to complete.", "error", err)
}
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go
index 7a7de1ddb..279b9acaa 100644
--- a/pkg/sources/git/git.go
+++ b/pkg/sources/git/git.go
@@ -1143,6 +1143,9 @@ func (s *Git) handleBinary(ctx context.Context, gitDir string, reporter sources.
return err
}
defer func() {
+ if err := fileReader.Close(); err != nil {
+ ctx.Logger().Error(err, "error closing fileReader")
+ }
if err := cmd.Wait(); err != nil {
ctx.Logger().Error(
err, "error waiting for command",