Skip to content
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

buildah: Use either openat2(RESOLVE_BENEATH) or don't follow links #1377

Open
cgwalters opened this issue Sep 5, 2024 · 1 comment
Open

Comments

@cgwalters
Copy link
Contributor

I came across this bit of code that runs after the just-built image is mounted (to be passed to scanners):

https://github.com/konflux-ci/build-definitions/blame/38c6cd3f4733ed1ee638ce43bacd1096e3e5076d/task/buildah-remote/0.2/buildah-remote.yaml#L487

What would be a lot less ugly than just blowing away all symbolic links is using Linux's openat2 system call has RESOLVE_IN_ROOT which allows a process to safely inspect a distinct root and resolve any symlinks as if they're in that root.

Or perhaps simpler often, just...don't follow symlinks in whatever is doing this scanning. (Why would it traverse symlinks?)

@cgwalters cgwalters changed the title buildah: Use either openat2(RESOLVE_BENEATH) or spawn as container instead of deleting symlinks buildah: Use either openat2(RESOLVE_BENEATH) or don't follow links Sep 5, 2024
@chmeliik
Copy link
Contributor

chmeliik commented Nov 4, 2024

We delete the symlinks from the mounted container filesystem before running syft and/or the Java SBOM thingy on it

/opt/jboss/container/java/run/run-java.sh analyse-dependencies path $(cat /shared/container_path) -s $(workspaces.source.path)/sbom-image.json --task-run-name $(context.taskRun.name) --publishers $(results.SBOM_JAVA_COMPONENTS_COUNT.path)

For syft, the better solution would be to run it on an oci-archive: of the image rather than the exported filesystem. The Java thingy doesn't support that, but it's also pretty much dead code at this point, AFAIK nobody uses the Java support this way anymore. Once we get rid of that, we can change the task to run syft on an oci-archive: and this will become irrelevant

Until then, this is a minor issue and IMO not worth solving (it doesn't affect anything, the exported filesystem never leaves the buildah task pod)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants