-
Notifications
You must be signed in to change notification settings - Fork 20
fix: block cluster-scoped resources from being wrapped in an envelope #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: block cluster-scoped resources from being wrapped in an envelope #32
Conversation
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
8c6c173 to
84de5b6
Compare
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
457a462 to
788c33b
Compare
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
Signed-off-by: michaelawyu <chenyu1@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR prevents cluster‐scoped resources from being wrapped in an envelope to address a security concern and updates related tests and manifests accordingly.
- Removed the webhook configuration block from the test envelope configmap and updated related tests.
- Changed test helper calls and expectations (e.g. using checkEnvelopQuotaPlacement and expecting errors when cluster‐scoped resources are wrapped) to align with the new validation.
- Updated manifests and integration tests to use ResourceQuota instead of the removed webhook configuration.
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/resources/test-envelop-configmap.yaml | Removed the webhook configuration block from the envelope. |
| test/e2e/join_and_leave_test.go | Updated CRP status check parameter from false to true and renamed helper calls. |
| test/e2e/enveloped_object_placement_test.go | Adjusted test expectations and helper function call names. |
| pkg/controllers/workgenerator/suite_test.go | Removed references to the webhook manifest and added new manifest for resourcequota2. |
| pkg/controllers/workgenerator/manifests/* | Updated the envelope configmap manifest and added a new ResourceQuota manifest. |
| pkg/controllers/workgenerator/controller_test.go | Changed test expectation—now expecting failure for an envelope with cluster‐scoped resources. |
| pkg/controllers/workgenerator/controller_integration_test.go | Updated integration test to use resourcequota2 manifest instead of webhook manifest. |
| pkg/controllers/workgenerator/controller.go | Added validation to block wrapping cluster‐scoped resources with a clear error message. |
Files not reviewed (1)
- pkg/controllers/workgenerator/manifests/test-envelop-configmap.yaml: Language not supported
Comments suppressed due to low confidence (2)
test/e2e/join_and_leave_test.go:102
- The parameter change from 'false' to 'true' in customizedCRPStatusUpdatedActual likely reflects new validation behavior. It may be beneficial to update the inline comment to clarify why the expectation has changed and to ensure the test aligns with the intended security concern.
crpStatusUpdatedActual := customizedCRPStatusUpdatedActual(crpName, wantSelectedResources, allMemberClusterNames, nil, "0", true)
pkg/controllers/workgenerator/controller_test.go:246
- The expected outcome for this test case has been updated to fail when a cluster-scoped resource is wrapped in an envelope. Verify that the test description and expected behavior clearly convey this new policy.
"config map with cluster and namespace scoped data in the correct namespace should fail": {
| klog.ErrorS(unMarshallErr, "manifest has invalid content", "manifestKey", key, "envelopeResource", klog.KObj(uConfigMap)) | ||
| return nil, fmt.Errorf("the object with manifest key `%s` in envelope config `%s` is malformatted, err: %w", key, klog.KObj(uConfigMap), unMarshallErr) | ||
| } | ||
| if len(uManifest.GetNamespace()) == 0 { |
Copilot
AI
Apr 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new check preventing wrapping of cluster-scoped resources is correctly implemented with a clear error message. Consider adding a dedicated unit test case to explicitly verify that cluster-scoped objects are blocked.
| // Block cluster-scoped resources. | ||
| return nil, fmt.Errorf("cannot wrap cluster-scoped resource %s in the envelope %s", uManifest.GetName(), klog.KObj(uConfigMap)) | ||
| } | ||
| if len(uManifest.GetNamespace()) != 0 && uManifest.GetNamespace() != configMap.Namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the new condition added, this is just
| if len(uManifest.GetNamespace()) != 0 && uManifest.GetNamespace() != configMap.Namespace { | |
| if uManifest.GetNamespace() != configMap.Namespace { |
Description of your changes
This PR blocks cluster-scoped resources from being wrapped in an envelope to address a security concern.
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer