Skip to content

Commit b099584

Browse files
committed
fix(helm): scope managed SSH policy mutation
Signed-off-by: Simon Scatton <sscatton@nvidia.com>
1 parent aeb4142 commit b099584

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

‎deploy/helm/openshell/templates/clusterrole.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ rules:
139139
- create
140140
- get
141141
{{- if $managedSshIngressEnabled }}
142-
# Apply gateway-only SSH ingress isolation in managed namespaces.
142+
# Server-side apply needs patch only for the fixed SSH policy name.
143+
# The shared rule above provides get/create for runtime policies.
143144
- apiGroups:
144145
- networking.k8s.io
145146
resources:
146147
- networkpolicies
148+
resourceNames:
149+
- openshell-sandbox-ssh
147150
verbs:
148-
- get
149-
- create
150151
- patch
151-
- update
152152
{{- end }}
153153
{{- end }}
154154
{{- end }}

‎deploy/helm/openshell/tests/clusterrole_test.yaml‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tests:
1515
path: metadata.name
1616
value: openshell-node-reader-my-namespace
1717

18-
- it: grants managed namespace NetworkPolicy apply permissions
18+
- it: restricts managed SSH policy mutation to its fixed name
1919
set:
2020
server.drivers.kubernetes.workspaceMode: managed
2121
asserts:
@@ -24,7 +24,18 @@ tests:
2424
content:
2525
apiGroups: ["networking.k8s.io"]
2626
resources: ["networkpolicies"]
27-
verbs: ["get", "create", "patch", "update"]
27+
resourceNames: ["openshell-sandbox-ssh"]
28+
verbs: ["patch"]
29+
- contains:
30+
path: rules
31+
content:
32+
apiGroups: ["networking.k8s.io"]
33+
resources: ["networkpolicies"]
34+
verbs: ["create", "get"]
35+
- notExists:
36+
path: rules[?(@.resources[0] == "networkpolicies")].verbs[?(@ == "update")]
37+
- notExists:
38+
path: rules[?(@.resources[0] == "networkpolicies" && @.resourceNames == null)].verbs[?(@ == "patch")]
2839

2940
- it: limits namespaced admission reads to PVCs
3041
set:
@@ -77,7 +88,8 @@ tests:
7788
content:
7889
apiGroups: ["networking.k8s.io"]
7990
resources: ["networkpolicies"]
80-
verbs: ["get", "create", "patch", "update"]
91+
resourceNames: ["openshell-sandbox-ssh"]
92+
verbs: ["patch"]
8193

8294
- it: gives schema-v2 managed SSH ingress precedence over the legacy alias
8395
set:
@@ -92,7 +104,8 @@ tests:
92104
content:
93105
apiGroups: ["networking.k8s.io"]
94106
resources: ["networkpolicies"]
95-
verbs: ["get", "create", "patch", "update"]
107+
resourceNames: ["openshell-sandbox-ssh"]
108+
verbs: ["patch"]
96109

97110
- it: omits credential Secret access in managed mode
98111
set:
@@ -124,7 +137,7 @@ tests:
124137
- name: registry-two
125138
asserts:
126139
- notExists:
127-
path: rules[*].resourceNames
140+
path: rules[?(@.resources[0] == "secrets")].resourceNames
128141
- contains:
129142
path: rules
130143
content:

0 commit comments

Comments
 (0)