File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package scc
3
3
import (
4
4
"fmt"
5
5
"net/http"
6
- "regexp"
7
6
"slices"
8
7
9
8
securityv1 "github.com/openshift/api/security/v1"
41
40
"system:serviceaccount:openshift-cluster-version:default" ,
42
41
"system:admin" ,
43
42
}
44
- allowedGroupsRe = regexp . MustCompile ( "^system:serviceaccounts:osde2e-(h-)?[a-z0-9]{5}" )
45
- defaultSCCs = []string {
43
+ allowedGroups = [] string {}
44
+ defaultSCCs = []string {
46
45
"anyuid" ,
47
46
"hostaccess" ,
48
47
"hostmount-anyuid" ,
@@ -126,8 +125,8 @@ func isAllowedUserGroup(request admissionctl.Request) bool {
126
125
return true
127
126
}
128
127
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 ) {
131
130
return true
132
131
}
133
132
}
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ func runSCCTests(t *testing.T, tests []sccTestSuites) {
79
79
}
80
80
}
81
81
}
82
- func TestUserNegative (t * testing.T ) {
82
+ func TestUser (t * testing.T ) {
83
83
tests := []sccTestSuites {
84
84
{
85
85
targetSCC : "hostnetwork" ,
@@ -121,12 +121,6 @@ func TestUserNegative(t *testing.T) {
121
121
userGroups : []string {"system:authenticated" , "system:authenticated:oauth" },
122
122
shouldBeAllowed : false ,
123
123
},
124
- }
125
- runSCCTests (t , tests )
126
- }
127
-
128
- func TestUserPositive (t * testing.T ) {
129
- tests := []sccTestSuites {
130
124
{
131
125
targetSCC : "testscc" ,
132
126
testID : "user-can-modify-normal" ,
@@ -169,11 +163,11 @@ func TestUserPositive(t *testing.T) {
169
163
},
170
164
{
171
165
targetSCC : "privileged" ,
172
- testID : "osde2e-serviceaccounts-are-allowed" ,
166
+ testID : "osde2e-serviceaccounts-are-not- allowed" ,
173
167
username : "system:serviceaccount:osde2e-abcde:osde2e-runner" ,
174
168
operation : admissionv1 .Update ,
175
169
userGroups : []string {"system:authenticated" , "system:serviceaccounts:osde2e-abcde" },
176
- shouldBeAllowed : true ,
170
+ shouldBeAllowed : false ,
177
171
},
178
172
}
179
173
runSCCTests (t , tests )
You can’t perform that action at this time.
0 commit comments