Because there is a check in Grype for the size of the input file, which could be stdin. The behaviour of Size() is system-dependent according to the std docs.
I recommend getting rid of fileHasContent() entirely, since it's only used by the purl provider and doesn't have a reliable behaviour.
What happened:
I tried to run Grype for a single package coming from stdin:
This works on OSX, but not in a Linux container.
What you expected to happen:
The scanning happens as normal on all platforms.
How to reproduce it (as minimally and precisely as possible):
Running the example command above on Linux.
Anything else we need to know?:
That is the same problem as there: https://github.com/golang/go/issues/62392#issuecomment-1702010687
Because there is a check in Grype for the size of the input file, which could be stdin. The behaviour of Size() is system-dependent according to the std docs.
I recommend getting rid of fileHasContent() entirely, since it's only used by the purl provider and doesn't have a reliable behaviour.
Environment:
grype version
for OSX:grype version
for Linux:cat /etc/os-release
or similar): OSX 14.6.1 / Debian 12