-
Notifications
You must be signed in to change notification settings - Fork 367
[no-relnote] Add e2e test for firmware path traversal #1169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ package e2e | |||||||||||||||||||||
|
||||||||||||||||||||||
import ( | ||||||||||||||||||||||
"context" | ||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||
"path/filepath" | ||||||||||||||||||||||
"strings" | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -297,4 +298,57 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() { | |||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
When("Running a container where the firmware folder resolves outside the container root", Ordered, func() { | ||||||||||||||||||||||
var outputDir string | ||||||||||||||||||||||
BeforeAll(func(ctx context.Context) { | ||||||||||||||||||||||
output, _, err := runner.Run("mktemp -d -p $(pwd)") | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
outputDir = strings.TrimSpace(output) | ||||||||||||||||||||||
|
||||||||||||||||||||||
_, _, err = runner.Run("docker pull ubuntu") | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
|
||||||||||||||||||||||
_, _, err = runner.Run(`docker build -t firmware-test \ | ||||||||||||||||||||||
--build-arg RM_VERSION="$(basename $(ls -d /lib/firmware/nvidia/*.*))" \ | ||||||||||||||||||||||
--build-arg CURRENT_DIR="` + outputDir + `" \ | ||||||||||||||||||||||
- <<EOF | ||||||||||||||||||||||
FROM ubuntu | ||||||||||||||||||||||
RUN mkdir -p /lib/firmware/nvidia/ | ||||||||||||||||||||||
ARG RM_VERSION | ||||||||||||||||||||||
ARG CURRENT_DIR | ||||||||||||||||||||||
RUN ln -s /../../../../../../../../\$CURRENT_DIR /lib/firmware/nvidia/\$RM_VERSION | ||||||||||||||||||||||
elezar marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
EOF`) | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
AfterEach(func(ctx context.Context) { | ||||||||||||||||||||||
output, _, err := runner.Run("ls -A " + outputDir) | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
Expect(output).To(BeEmpty()) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
AfterAll(func(ctx context.Context) { | ||||||||||||||||||||||
if outputDir != "" { | ||||||||||||||||||||||
runner.Run(fmt.Sprintf("rm -rf %s", outputDir)) | ||||||||||||||||||||||
ArangoGutierrez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
} | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
It("should not fail when using CDI", func(ctx context.Context) { | ||||||||||||||||||||||
output, _, err := runner.Run("docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all firmware-test") | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
Expect(output).To(BeEmpty()) | ||||||||||||||||||||||
ArangoGutierrez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our other CDI tests we use:
Suggested change
|
||||||||||||||||||||||
It("should not fail when using the nvidia-container-runtime", func(ctx context.Context) { | ||||||||||||||||||||||
_, _, err := runner.Run("docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all firmware-test") | ||||||||||||||||||||||
Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
It("should fail when using the nvidia-container-runtime-hook", Label("legacy"), func(ctx context.Context) { | ||||||||||||||||||||||
_, stderr, err := runner.Run("docker run --rm --runtime=runc --gpus=all firmware-test") | ||||||||||||||||||||||
Expect(err).To(HaveOccurred()) | ||||||||||||||||||||||
Expect(stderr).To(ContainSubstring("nvidia-container-cli.real: mount error: path error:")) | ||||||||||||||||||||||
ArangoGutierrez marked this conversation as resolved.
Show resolved
Hide resolved
ArangoGutierrez marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a test for the
Suggested change
|
||||||||||||||||||||||
}) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
Comment on lines
+353
to
354
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to move the check for empty output folders to an AfterEach so that we don't have to repeat it for every test (and also don't forget to add it to new tests). |
Uh oh!
There was an error while loading. Please reload this page.