From d515af5c7bddbbe3bebf3a6288fb3e43b234719a Mon Sep 17 00:00:00 2001 From: Pawel Wieczorek Date: Tue, 17 Sep 2019 17:09:37 +0200 Subject: k8s: Validate API server not excluded authorization mode This patch verifies if CIS Kubernetes Benchmark v1.3.0 section regarding master node configuration is satisfied (1.1.19). Issue-ID: SECCOM-235 Change-Id: I00c9600fd0d351afb7141a5fa16f348eab67b12d Signed-off-by: Pawel Wieczorek --- test/security/k8s/src/check/validators/master/api_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/security/k8s/src/check/validators/master/api_test.go') diff --git a/test/security/k8s/src/check/validators/master/api_test.go b/test/security/k8s/src/check/validators/master/api_test.go index 233662a63..417616295 100644 --- a/test/security/k8s/src/check/validators/master/api_test.go +++ b/test/security/k8s/src/check/validators/master/api_test.go @@ -23,6 +23,7 @@ var _ = Describe("Api", func() { "PersistentVolumeClaimResize,MutatingAdmissionWebhook,ValidatingAdmissionWebhook," + "ResourceQuota,AlwaysPullImages,DenyEscalatingExec,SecurityContextDeny," + "PodSecurityPolicy,NodeRestriction,EventRateLimit", + "--authorization-mode=RBAC", } // kubeApiServerCasablanca was obtained from virtual environment for testing @@ -315,5 +316,16 @@ var _ = Describe("Api", func() { Entry("Should not be disabled on Casablanca cluster", kubeApiServerCasablanca, true), Entry("Should not be disabled on Dublin cluster", kubeApiServerDublin, true), ) + + DescribeTable("AlwaysAllow authorization mode", + func(params []string, expected bool) { + Expect(IsAlwaysAllowAuthorizationModeExcluded(params)).To(Equal(expected)) + }, + Entry("Is not explicitly disabled on insecure cluster", []string{}, false), + Entry("Is not absent on insecure cluster", []string{"--authorization-mode=Foo,Bar,AlwaysAllow,Baz,Quuz"}, false), + Entry("Is not explicitly disabled on Casablanca cluster", kubeApiServerCasablanca, false), + Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true), + Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true), + ) }) }) -- cgit 1.2.3-korg