@@ -657,10 +657,23 @@ var _ = framework.KubeDescribe("Security Context", func() {
657
657
}
658
658
]
659
659
}`
660
+
661
+ // seccompProcStatusField is the field of /proc/$PID/status referencing the seccomp filter type.
662
+ seccompProcStatusField = "Seccomp:"
663
+
664
+ // procSelfStatusPath is the path to /proc/self/status.
665
+ procSelfStatusPath = "/proc/self/status"
666
+ )
667
+
668
+ var (
669
+ profileDir , blockHostNameProfilePath , blockchmodProfilePath string
670
+ err error
671
+
672
+ sysAdminCap = []string {"SYS_ADMIN" }
673
+
674
+ // seccompProcSelfStatusGrepCommand is the command to grep the seccomp status of the current process.
675
+ seccompProcSelfStatusGrepCommand = []string {"grep" , seccompProcStatusField , procSelfStatusPath }
660
676
)
661
- var profileDir , blockHostNameProfilePath , blockchmodProfilePath string
662
- var err error
663
- sysAdminCap := []string {"SYS_ADMIN" }
664
677
665
678
BeforeEach (func () {
666
679
profileDir , err = createSeccompProfileDir ()
@@ -689,7 +702,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
689
702
podID , containerID = seccompTestContainer (rc , ic , seccompProfile )
690
703
691
704
By ("verify seccomp profile" )
692
- verifySeccomp (rc , containerID , [] string { "grep" , "ecc" , "/proc/self/status" } , false , "0" ) // seccomp disabled
705
+ verifySeccomp (rc , containerID , seccompProcSelfStatusGrepCommand , false , "0" ) // seccomp disabled
693
706
})
694
707
695
708
It ("should support seccomp localhost profile on the container" , func () {
@@ -714,7 +727,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
714
727
podID , containerID = seccompTestContainer (rc , ic , seccompProfile )
715
728
716
729
By ("verify seccomp profile" )
717
- verifySeccomp (rc , containerID , [] string { "grep" , "ecc" , "/proc/self/status" }, false , "1 " ) // seccomp enabled
730
+ verifySeccomp (rc , containerID , seccompProcSelfStatusGrepCommand , false , "2 " ) // seccomp enabled
718
731
})
719
732
720
733
It ("should support nil profile, which is unconfined" , func () {
@@ -724,7 +737,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
724
737
podID , containerID = seccompTestContainer (rc , ic , nil )
725
738
726
739
By ("verify seccomp profile" )
727
- verifySeccomp (rc , containerID , [] string { "grep" , "ecc" , "/proc/self/status" } , false , "0" ) // seccomp disabled
740
+ verifySeccomp (rc , containerID , seccompProcSelfStatusGrepCommand , false , "0" ) // seccomp disabled
728
741
})
729
742
730
743
// SYS_ADMIN capability allows sethostname, and seccomp is unconfined. sethostname should work.
0 commit comments