feat: enforce filterRules restrictions on workspace create and update - #1364
Draft
Snehadas2005 wants to merge 1 commit into
Draft
feat: enforce filterRules restrictions on workspace create and update#1364Snehadas2005 wants to merge 1 commit into
Snehadas2005 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
Snehadas2005
force-pushed
the
task-enforce-filterrules
branch
from
August 29, 2026 05:47
785b769 to
cfcf26a
Compare
Snehadas2005
marked this pull request as draft
August 29, 2026 06:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements server-side enforcement of
WorkspaceKind.spec.filterRules[]restrictions during Workspace creation (POST /workspaces) and update (PUT /workspaces/:name). Even if the frontend UI restricts or disables invalid options, the backend independently validates selectedimageConfigandpodConfigoptions against defined filter rules using the workspace's target namespace context to prevent direct API misuse.Specifically:
filterRulesfor both selectedimageConfigandpodConfigoptions using the target namespace context.filterRulesifimageConfigand/orpodConfigare actually modified. This prevents existing workloads from breaking on unrelated workspace updates (e.g. updating labels/display name) when an administrator adds a new deny rule post-creation.422 Unprocessable Entitycontaining the matched filter rule'sdenyMessage.textwithincause.validation_errors[].Key Changes
Workspace Repository (
internal/repositories/workspaces/repo.go)enforceFilterRuleRestrictions: Helper function that retrieves the referencedWorkspaceKind, resolves target namespace labels viaresolveNamespaceLabels, and invokes the sharedfilterrules.Evaluate()engine for the selectedimageConfigandpodConfig.CreateWorkspace: InvokesenforceFilterRuleRestrictionsupfront before creating the Kubernetes resource.UpdateWorkspace: Checks ifnewOptions.ImageConfig != currentOptions.ImageConfigornewOptions.PodConfig != currentOptions.PodConfigbefore validating, ensuring unchanged options are not re-checked.helper.NewInternalValidationError(filterErrs)to map denied options directly into the existingcause.validation_errors[]field error structure without requiring changes to the handler layer (workspaces_handler.go).Unit & Integration Tests (
api/workspaces_handler_test.go)Added an
Orderedtest contextEnforcing filterRule restrictions on Workspace create/updatecovering:imageConfigmatches a deny rule.podConfigmatches a deny rule.imageConfig.Verification
go vet ./...andgo fmt ./...across the backend with 0 errors/warnings.go build ./cmd/main.go.make test.Notes for Reviewers
403or422. This implementation uses422 Unprocessable Entityas it seamlessly reuses the existingInternalValidationError→failedValidationResponsepipeline already established for PVC/Secret mountability validation.closes: #1206
related: #682