github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/run_seccomp_test.go (about) 1 package integration 2 3 import ( 4 . "github.com/containers/podman/v5/test/utils" 5 . "github.com/onsi/ginkgo/v2" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("Podman run", func() { 10 11 It("podman run --seccomp-policy default", func() { 12 session := podmanTest.Podman([]string{"run", "-q", "--seccomp-policy", "default", alpineSeccomp, "ls"}) 13 session.WaitWithDefaultTimeout() 14 Expect(session).Should(ExitCleanly()) 15 }) 16 17 It("podman run --seccomp-policy ''", func() { 18 // Empty string is interpreted as "default". 19 session := podmanTest.Podman([]string{"run", "-q", "--seccomp-policy", "", alpineSeccomp, "ls"}) 20 session.WaitWithDefaultTimeout() 21 Expect(session).Should(ExitCleanly()) 22 }) 23 24 It("podman run --seccomp-policy invalid", func() { 25 session := podmanTest.Podman([]string{"run", "--seccomp-policy", "invalid", alpineSeccomp, "ls"}) 26 session.WaitWithDefaultTimeout() 27 Expect(session).To(ExitWithError(125, `invalid seccomp policy "invalid": valid policies are ["default" "image"]`)) 28 }) 29 30 It("podman run --seccomp-policy image (block all syscalls)", func() { 31 session := podmanTest.Podman([]string{"run", "--seccomp-policy", "image", alpineSeccomp, "ls"}) 32 session.WaitWithDefaultTimeout() 33 // TODO: we're getting a "cannot start a container that has 34 // stopped" error which seems surprising. Investigate 35 // why that is so. 36 if podmanTest.OCIRuntime == "runc" { 37 // TODO: worse than that. With runc, we get two alternating failures: 38 // 126 + cannot start a container that has stopped 39 // 127 + failed to connect to container's attach socket ... ENOENT 40 Expect(session.ExitCode()).To(BeNumerically(">=", 126), "Exit status using runc") 41 } else { 42 expect := "OCI runtime error: crun: read from the init process" 43 if IsRemote() { 44 expect = "for attach: crun: read from the init process: OCI runtime error" 45 } 46 Expect(session).To(ExitWithError(126, expect)) 47 } 48 }) 49 50 It("podman run --seccomp-policy image (bogus profile)", func() { 51 session := podmanTest.Podman([]string{"run", "--seccomp-policy", "image", alpineBogusSeccomp, "ls"}) 52 session.WaitWithDefaultTimeout() 53 Expect(session).Should(ExitWithError(125, "loading seccomp profile failed: decoding seccomp profile failed: invalid character 'B' looking for beginning of value")) 54 }) 55 })