-
Notifications
You must be signed in to change notification settings - Fork 571
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
Support scanning files in other mount namespaces #3396
Comments
Hey @ariel-miculas -- are you able to use the |
Thanks, @kzantow ,
If I had to guess, syft tries to convert the base path to an absolute path (which results in |
That's unfortunate -- from my understanding, Given this directory structure:
e.g.:
If I run Syft against
If I run with
If I run directly against the link with or without
This last case is effectively the same issue you have, correct? If so, I think we could just fix the initial directory path lookup to honor the |
The problem is you cannot call
The reason is that reading the symlink
So the base path is translated to And this
This is a lie, because |
This is one of the issues, yes.
The second issue is that we shouldn't call |
* honour the base-path flag when scanning files * don't evaluate symlinks for the base path * use procfsroot.EvalSymlinks() instead of filepath.EvalSymlinks() so that symlinks are always resolved relative to the base path Fixes anchore#3396 Signed-off-by: Ariel Miculas-Trif <[email protected]>
This is an early POC for my feature request: main...ariel-miculas:syft:allow-scanning-files-in-mount-namespaces
where 240346 is the PID of a shell running inside a docker container. I would like some early feedback on this if possible. |
Let me step back and try to clarify the issues with syft: 1. Honour the
|
What would you like to be added:
I want syft to be able to scan files in other mount namespaces.
Why is this needed:
Additional context:
As an example, I'm trying to scan a file on my host filesystem by running the syft scanner inside a docker container. Here, pid 117851 is a process running in my host mount namespace, and the docker permissions allow me to access
/proc/117851/root/
.syft cannot find
/home
because it's looking for it in its own mount namespace, instead of looking for it in the host's mount namespace. To work as expected, something like procfsroot should be used.Another way to make this work would be to use this file path as-is, instead of trying to resolve any paths. But the way syft's FileResolver from
file_source.go
works is by callingfileresolver.NewFromDirectory
which ends up callingfilepath.EvalSymlinks(...)
. This doesn't work forproc/PID/root
paths becauseproc/PID/root
is a symlink to/
, but/
refers to the root from the mount namespace thatsyft
is running in, not the target mount namespace that needs to be scanned.As a proof that this feature should be possible, I'm running trivy from a docker container set up identically:
The text was updated successfully, but these errors were encountered: