@@ -34,6 +34,8 @@ const (
34
34
EphemeralStorageLimit = "2Mi"
35
35
)
36
36
37
+ var DefaultID int64 = 2137
38
+
37
39
func Mount (ctx context.Context , namespace , pvcName , localMountPoint string , needsRoot , debug bool ) error {
38
40
39
41
checkSSHFS ()
@@ -450,6 +452,12 @@ func getEphemeralContainerSettings(needsRoot bool) (string, *corev1.SecurityCont
450
452
allowPrivilegeEscalationTrue := true
451
453
allowPrivilegeEscalationFalse := false
452
454
readOnlyRootFilesystemTrue := true
455
+ runAsNonRootTrue := true
456
+
457
+ // Define seccomp profile type
458
+ seccompProfileRuntimeDefault := corev1.SeccompProfile {
459
+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
460
+ }
453
461
454
462
if needsRoot {
455
463
image = PrivilegedImage
@@ -459,6 +467,7 @@ func getEphemeralContainerSettings(needsRoot bool) (string, *corev1.SecurityCont
459
467
Capabilities : & corev1.Capabilities {
460
468
Add : []corev1.Capability {"SYS_ADMIN" , "SYS_CHROOT" },
461
469
},
470
+ SeccompProfile : & seccompProfileRuntimeDefault ,
462
471
}
463
472
} else {
464
473
securityContext = & corev1.SecurityContext {
@@ -467,6 +476,10 @@ func getEphemeralContainerSettings(needsRoot bool) (string, *corev1.SecurityCont
467
476
Capabilities : & corev1.Capabilities {
468
477
Drop : []corev1.Capability {"ALL" },
469
478
},
479
+ SeccompProfile : & seccompProfileRuntimeDefault ,
480
+ RunAsUser : & DefaultID ,
481
+ RunAsGroup : & DefaultID ,
482
+ RunAsNonRoot : & runAsNonRootTrue ,
470
483
}
471
484
}
472
485
return image , securityContext
0 commit comments