-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excluded paths are still scanned and cause syft to crash. #3258
Comments
Hi @reure1 -- the directories you are excluding are at the root of the filesystem but you are using relative paths |
The tool does not allow absolute paths. I am not using a container, so I'm scanning the whole system, minus some directories. Excluding file paths. You can see in the debug output that every directory I told it to exclude the indexer still indexes, but does not scan. The indexer (resolver) error on the /boot/efi/EFI/redhat/grub.cfg file when it should be excluded. syft scan dir:/ --verbose=2 --exclude=./web --exclude=./boot --exclude=./var/lib/yum --exclude ./dev --exclude./sys -o cyclonedx=sbom.cyclonedx.xml So what would be better command to scan the system? |
If you are running a directory scan, as you noted, exclude paths need to be relative to the scan root. I don't have a RHEL instance to test this on at the moment, but running on the latest Fedora, after receiving permission errors such for paths such as I should note, I used Syft 1.12.2, maybe give that a try? If that doesn't seem to solve the issue, are there other steps or a publicly available container or ISO that exhibits the problem? |
@kzantow, when you ran your scan did you use -vv or --verbose=2? When you look at the logs you will see directories that you excluded that you don't have permissions to go into. That is where syft is dying. I believe that is part of the indexer/resolver and not the scanner. Again I exclude "--exclude ./boot" the faital is:
The fatal error should have never happened because the indexer/resolver should have never gone down that path. |
I ran Syft 1.12.2 this morning and the indexer/resolver ignores --exclude also. Syft crashes at the same place. Why it crashes instead of just printing the warning, I don't know. /web is another directory that I excluded and should be skipped.
|
It seems like there are 2 distinct issues here:
In regards to the first issue: Syft crashing, to me this is the crux of your problems but I am unable to reproduce. I would very much like to ensure this does not happen, but I'll need some way to reproduce instead of speculating on a fix. In regards to the second issue -- seeing references to without --exclude
with --exclude ./boot
You can see a distinct difference, where syft has excluded many paths as expected, but there still is a reference to |
@kzantow, thank you for your response. I mostly agree with you. I feel that if syft didn't try to access files it was told to ignore symlink or not, the crash would not happen. I am using a very locked down version of Redhat and I can't share any logs. |
There are probably better ways of finding these, but I was able to identify where the links are on my VM using:
Update: I tried Rocky and Alma minimal ISO virtual machines, and both of these succeeded without crashing; I don't think we can make a lot more progress without a way to reproduce the issue. |
I will see if we can come up with something. We may just have to use a different SBOM tool. |
@kzantow btw there is a symlink for /etc/grub2.cfg and ../boot/grub2.cfg |
I started looking at the code. This will give me a chance to learn a little Go. lstat is only on one place. So I will start there.
|
I had to work on something else for a few days. I'm glad to see someone else had the issue and could easily reproduce it. |
@kzantow, I came up with a quick fix. return fmt.Errorf("unable to index filesystem path=%q: %w, currentPath, err) to: log.WithFields("path", currentPath).Warn("unable to index filesystem path")
continue |
@reure1 that's a good idea! It would be great if we could report this as part of our new "known unknowns" feature which was added by #2998. What we would like is for the directory_indexer to be able to use syft/syft/pkg/cataloger/golang/scan_binary.go Lines 48 to 51 in 5d165e0
However, there might be additional wiring needed to make this work from inside a resolver (above link is to a cataloger, not a resolver). If you'd like to pick this up, just let us know! We're happy to help. |
What happened: I excluded paths --exclude ./boot --exclude ./web I had verbose set to 2
When ran you seed WARN unable to access path="/web" lstat /web no such file or directory
This is really a permission issue., but it should have never checked.
The bigger issues was the error:
unable to get file resolver: unable to create directory resolver: unable to index filesystem path="/boot/efi/EFI/readhat/grub.cfg": lstat /boot/dfi/DFIL permission denied
syft exits.
This makes the tool useless.
What you expected to happen: The paths excluded would not be scanned.
Steps to reproduce the issue: Use a user that does not have permission to read /boot
Anything else we need to know?:
Environment:
syft version
: 1.11.0cat /etc/os-release
or similar): Redhat 7.9 and 8.4The text was updated successfully, but these errors were encountered: