mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 14:50:53 -08:00
Using bufio reader for Stdin, otherwise the first 3 bytes are consumed and file gets "corrupted" (stdin is not seekable?)
This commit is contained in:
committed by
Simarpreet Singh
parent
9bf16ae1ba
commit
2cb920d5d9
@@ -1,8 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -37,11 +37,10 @@ func IsCommandAvailable(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func IsGzip(f *os.File) bool {
|
||||
func IsGzip(f *bufio.Reader) bool {
|
||||
buf := make([]byte, 3)
|
||||
n, _ := f.Read(buf)
|
||||
defer f.Seek(0, io.SeekStart)
|
||||
if n < 3 {
|
||||
buf, err := f.Peek(3)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return buf[0] == 0x1F && buf[1] == 0x8B && buf[2] == 0x8
|
||||
|
||||
Reference in New Issue
Block a user