Skip to content

Commit fff4536

Browse files
Merge pull request #2027 from abays/narrow-wildcard-rbac-verbs
Narrow wildcard RBAC verbs to least-privilege on manager ClusterRole
2 parents 07ebcdf + 3532763 commit fff4536

3 files changed

Lines changed: 60 additions & 34 deletions

File tree

config/operator/rbac/role.yaml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,55 @@ rules:
77
- apiGroups:
88
- ""
99
resources:
10-
- configmaps
1110
- namespaces
11+
verbs:
12+
- create
13+
- get
14+
- update
15+
- apiGroups:
16+
- ""
17+
resources:
1218
- serviceaccounts
19+
verbs:
20+
- delete
21+
- get
22+
- list
23+
- watch
24+
- apiGroups:
25+
- ""
26+
resources:
1327
- services
1428
verbs:
15-
- '*'
29+
- create
30+
- delete
31+
- get
32+
- list
33+
- update
34+
- watch
1635
- apiGroups:
1736
- admissionregistration.k8s.io
1837
resources:
1938
- mutatingwebhookconfigurations
2039
- validatingwebhookconfigurations
2140
verbs:
22-
- '*'
41+
- create
42+
- delete
43+
- deletecollection
44+
- get
45+
- list
46+
- update
47+
- watch
2348
- apiGroups:
2449
- apiextensions.k8s.io
2550
resources:
26-
- '*'
51+
- customresourcedefinitions
2752
verbs:
28-
- '*'
53+
- create
54+
- delete
55+
- get
56+
- list
57+
- update
58+
- watch
2959
- apiGroups:
3060
- apps
3161
resources:

config/rbac/role.yaml

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ rules:
88
- ""
99
resources:
1010
- configmaps
11+
- pods
12+
- secrets
13+
- serviceaccounts
1114
- services
1215
verbs:
13-
- '*'
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
1423
- apiGroups:
1524
- ""
1625
resources:
@@ -29,26 +38,9 @@ rules:
2938
resources:
3039
- namespaces
3140
verbs:
32-
- '*'
33-
- apiGroups:
34-
- ""
35-
resources:
36-
- pods
37-
- secrets
38-
verbs:
3941
- create
40-
- delete
4142
- get
42-
- list
43-
- patch
4443
- update
45-
- watch
46-
- apiGroups:
47-
- ""
48-
resources:
49-
- serviceaccounts
50-
verbs:
51-
- '*'
5244
- apiGroups:
5345
- ""
5446
- project.openshift.io
@@ -62,20 +54,23 @@ rules:
6254
- mutatingwebhookconfigurations
6355
- validatingwebhookconfigurations
6456
verbs:
65-
- '*'
66-
- apiGroups:
67-
- apiextensions.k8s.io
68-
resources:
69-
- '*'
70-
verbs:
71-
- '*'
57+
- create
58+
- delete
59+
- deletecollection
60+
- get
61+
- list
62+
- update
63+
- watch
7264
- apiGroups:
7365
- apiextensions.k8s.io
7466
resources:
7567
- customresourcedefinitions
7668
verbs:
69+
- create
70+
- delete
7771
- get
7872
- list
73+
- update
7974
- watch
8075
- apiGroups:
8176
- apps

internal/controller/operator/openstack_controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ func SetupEnv() {
110110
//+kubebuilder:rbac:groups=operator.openstack.org,resources=openstacks,verbs=get;list;watch;create;update;patch;delete
111111
//+kubebuilder:rbac:groups=operator.openstack.org,resources=openstacks/status,verbs=get;update;patch
112112
//+kubebuilder:rbac:groups=operator.openstack.org,resources=openstacks/finalizers,verbs=update
113-
// +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations;validatingwebhookconfigurations,verbs="*"
113+
// +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations;validatingwebhookconfigurations,verbs=get;list;watch;create;update;delete;deletecollection
114114
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles;rolebindings,verbs=get;list;delete
115-
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources="*",verbs="*"
115+
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch;create;update;delete
116116
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete;
117-
// +kubebuilder:rbac:groups="",resources=serviceaccounts;configmaps;namespaces,verbs="*"
118-
// +kubebuilder:rbac:groups=core,resources=services,verbs="*";
117+
// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;delete
118+
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;create;update
119+
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;delete
119120
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=get;list;watch;
120121
// +kubebuilder:rbac:groups=cert-manager.io,resources=issuers,verbs=get;list;watch;create;update;patch;delete;
121122
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificates,verbs=get;list;watch;create;update;patch;delete;

0 commit comments

Comments
 (0)