mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
[fixup] - skip files in the archive handler (#2195)
This commit is contained in:
parent
2728e514d2
commit
331336dc0a
1 changed files with 8 additions and 4 deletions
|
@ -109,6 +109,7 @@ func (a *Archive) openArchive(ctx context.Context, depth int, reader io.Reader,
|
|||
switch archive := format.(type) {
|
||||
case archiver.Decompressor:
|
||||
info := decompressorInfo{depth: depth, reader: arReader, archiveChan: archiveChan, archiver: archive}
|
||||
|
||||
return a.handleDecompressor(ctx, info)
|
||||
case archiver.Extractor:
|
||||
return archive.Extract(context.WithValue(ctx, depthKey, depth+1), reader, nil, a.extractorHandler(archiveChan))
|
||||
|
@ -142,8 +143,7 @@ func (a *Archive) handleDecompressor(ctx context.Context, info decompressorInfo)
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newReader := bytes.NewReader(fileBytes)
|
||||
return a.openArchive(ctx, info.depth+1, newReader, info.archiveChan)
|
||||
return a.openArchive(ctx, info.depth+1, bytes.NewReader(fileBytes), info.archiveChan)
|
||||
}
|
||||
|
||||
// IsFiletype returns true if the provided reader is an archive.
|
||||
|
@ -176,13 +176,17 @@ func (a *Archive) extractorHandler(archiveChan chan []byte) func(context.Context
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if common.SkipFile(f.Name()) {
|
||||
logger.V(5).Info("skipping file", "filename", f.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
fileBytes, err := a.ReadToMax(ctx, fReader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fileContent := bytes.NewReader(fileBytes)
|
||||
|
||||
err = a.openArchive(ctx, depth, fileContent, archiveChan)
|
||||
err = a.openArchive(ctx, depth, bytes.NewReader(fileBytes), archiveChan)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue