Skip to content

Commit c1006d1

Browse files
committed
Block creation of RBAC objects via DevWorkspace components
Signed-off-by: Angel Misevski <[email protected]>
1 parent 6c5c4d0 commit c1006d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webhook/workspace/handler/kubernetes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ func (h *WebhookHandler) validatePermissionsOnObject(ctx context.Context, req ad
7070
if err := yaml.Unmarshal([]byte(component), typeMeta); err != nil {
7171
return fmt.Errorf("failed to read content for component %s", componentName)
7272
}
73-
if typeMeta.Kind == "List" {
73+
kind := typeMeta.Kind
74+
if kind == "List" {
7475
return fmt.Errorf("lists are not supported in Kubernetes or OpenShift components")
7576
}
77+
if kind == "Role" || kind == "Rolebinding" || kind == "ClusterRole" || kind == "ClusterRoleBinding" {
78+
return fmt.Errorf("kubernetes RBAC objects are not permitted within DevWorkspace components")
79+
}
7680

7781
// Workaround to get the correct resource type for a given kind -- probably fragile
7882
// Convert e.g. Pod -> pods, Deployment -> deployments

0 commit comments

Comments
 (0)