From 484284706cbd921e9f24ac4c90b5447c8fbda778 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 2 Nov 2021 12:41:02 -0400 Subject: [PATCH] Use named pipe bit when checking for piped input (#603) * use named pipe bit when checking for piped input Signed-off-by: Alex Goodman Co-authored-by: Christopher Angelo Phillips --- internal/input.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/input.go b/internal/input.go index 92b267407..e9f74752d 100644 --- a/internal/input.go +++ b/internal/input.go @@ -12,5 +12,9 @@ func IsPipedInput() (bool, error) { return false, fmt.Errorf("unable to determine if there is piped input: %w", err) } - return fi.Mode()&os.ModeCharDevice == 0, nil + // note: we should NOT use the absence of a character device here as the hint that there may be input expected + // on stdin, as running syft as a subprocess you would expect no character device to be present but input can + // be from either stdin or indicated by the CLI. Checking if stdin is a pipe is the most direct way to determine + // if there *may* be bytes that will show up on stdin that should be used for the analysis source. + return fi.Mode()&os.ModeNamedPipe != 0, nil }