Skip to content

Commit 631247e

Browse files
Merge pull request #299 from cblecker/remove-scc-osde2e
Remove osde2e exception from modifying SCCs
2 parents bdaa872 + b1ef152 commit 631247e

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

pkg/webhooks/scc/scc.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package scc
33
import (
44
"fmt"
55
"net/http"
6-
"regexp"
76
"slices"
87

98
securityv1 "github.com/openshift/api/security/v1"
@@ -41,8 +40,8 @@ var (
4140
"system:serviceaccount:openshift-cluster-version:default",
4241
"system:admin",
4342
}
44-
allowedGroupsRe = regexp.MustCompile("^system:serviceaccounts:osde2e-(h-)?[a-z0-9]{5}")
45-
defaultSCCs = []string{
43+
allowedGroups = []string{}
44+
defaultSCCs = []string{
4645
"anyuid",
4746
"hostaccess",
4847
"hostmount-anyuid",
@@ -126,8 +125,8 @@ func isAllowedUserGroup(request admissionctl.Request) bool {
126125
return true
127126
}
128127

129-
for _, group := range request.UserInfo.Groups {
130-
if allowedGroupsRe.Match([]byte(group)) {
128+
for _, group := range allowedGroups {
129+
if slices.Contains(request.UserInfo.Groups, group) {
131130
return true
132131
}
133132
}

pkg/webhooks/scc/scc_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func runSCCTests(t *testing.T, tests []sccTestSuites) {
7979
}
8080
}
8181
}
82-
func TestUserNegative(t *testing.T) {
82+
func TestUser(t *testing.T) {
8383
tests := []sccTestSuites{
8484
{
8585
targetSCC: "hostnetwork",
@@ -121,12 +121,6 @@ func TestUserNegative(t *testing.T) {
121121
userGroups: []string{"system:authenticated", "system:authenticated:oauth"},
122122
shouldBeAllowed: false,
123123
},
124-
}
125-
runSCCTests(t, tests)
126-
}
127-
128-
func TestUserPositive(t *testing.T) {
129-
tests := []sccTestSuites{
130124
{
131125
targetSCC: "testscc",
132126
testID: "user-can-modify-normal",
@@ -169,11 +163,11 @@ func TestUserPositive(t *testing.T) {
169163
},
170164
{
171165
targetSCC: "privileged",
172-
testID: "osde2e-serviceaccounts-are-allowed",
166+
testID: "osde2e-serviceaccounts-are-not-allowed",
173167
username: "system:serviceaccount:osde2e-abcde:osde2e-runner",
174168
operation: admissionv1.Update,
175169
userGroups: []string{"system:authenticated", "system:serviceaccounts:osde2e-abcde"},
176-
shouldBeAllowed: true,
170+
shouldBeAllowed: false,
177171
},
178172
}
179173
runSCCTests(t, tests)

0 commit comments

Comments
 (0)