Skip to content

Find, verify, and analyze leaked credentials

Add newlines when file is split (#937)

Bill Rich79cae3b82b77
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go
index 2096a2db4..522405b28 100644
--- a/pkg/sources/git/git.go
+++ b/pkg/sources/git/git.go
@@ -408,7 +408,9 @@ func (s *Git) gitChunk(ctx context.Context, diff gitparse.Diff, fileName, email,
newChunkBuffer := bytes.Buffer{}
lastOffset := 0
for offset := 0; originalChunk.Scan(); offset++ {
- line := originalChunk.Bytes()
+ line := make([]byte, len(originalChunk.Bytes())+1)
+ copy(line, originalChunk.Bytes())
+ line[len(line)-1] = byte('\n')
if len(line) > sources.ChunkSize || len(line)+newChunkBuffer.Len() > sources.ChunkSize {
// Add oversize chunk info
if newChunkBuffer.Len() > 0 {