Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
added PL selector
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixking25 committed May 11, 2020
1 parent 9056f98 commit 3a166d6
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const (
expectedVal = "Allowing privilege escalation for containers is not allowed"
)


func MakeSecPod(Namespace string, AllowPrivilegeEscalation bool) (*v1.Pod) {
func MakeSecPod(Namespace string, AllowPrivilegeEscalation bool) *v1.Pod {
podName := "security-context-" + string(uuid.NewUUID())
podSpec := &v1.Pod{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -47,7 +46,7 @@ func MakeSecPod(Namespace string, AllowPrivilegeEscalation bool) (*v1.Pod) {
return podSpec
}

var _ = framework.KubeDescribe("Processes in tenant containers should not be allowed to gain additional priviliges", func() {
var _ = framework.KubeDescribe("[PL1] [PL2] [PL3] Processes in tenant containers should not be allowed to gain additional priviliges", func() {
var config *configutil.BenchmarkConfig
var tenantA configutil.TenantSpec
var user string
Expand All @@ -59,20 +58,20 @@ var _ = framework.KubeDescribe("Processes in tenant containers should not be all

tenantA, err = config.GetValidTenant()
framework.ExpectNoError(err)

user = configutil.GetContextFromKubeconfig(tenantA.Kubeconfig)
})

ginkgo.It("Validate tenants can not create pods/container with allowedprivilege set to true", func() {
ginkgo.By(fmt.Sprintf("tenant %s cannot create pod/container with with allowedprivilege set to true", user))

kclient := configutil.NewKubeClientWithKubeconfig(tenantA.Kubeconfig)

pod := MakeSecPod(tenantA.Namespace, true)
_, err = kclient.CoreV1().Pods(tenantA.Namespace).Create(pod)

if !strings.Contains(err.Error(), expectedVal) {
framework.Failf("%s must be unable to create pod/container that sets allowedprivileged to true", user)
}
})
})
})

0 comments on commit 3a166d6

Please sign in to comment.