preserve existing funcitonality of not handling non-archive files in HandleFile

This commit is contained in:
Ahrav Dutta
2024-04-15 11:23:27 -07:00
parent b5af0b44a7
commit 7bbc77f1a8
+7 -1
View File
@@ -7,6 +7,7 @@ import (
"io"
"github.com/h2non/filetype"
"github.com/mholt/archiver/v4"
diskbufferreader "github.com/trufflesecurity/disk-buffer-reader"
logContext "github.com/trufflesecurity/trufflehog/v3/pkg/context"
@@ -105,7 +106,12 @@ func HandleFile(ctx logContext.Context, reReader *diskbufferreader.DiskBufferRea
return false
}
archiveChan, err := handler.HandleFile(ctx, reReader) // Delegate to the specific handler to process the file.
_, arReader, err := archiver.Identify("", reReader)
if errors.Is(err, archiver.ErrNoMatch) {
return false
}
archiveChan, err := handler.HandleFile(ctx, arReader) // Delegate to the specific handler to process the file.
if err != nil {
ctx.Logger().Error(err, "error handling file")
return false