test(events): pin the scope-injection invariant - #751
Closed
yahyafakhroji wants to merge 1 commit into
Closed
Conversation
Scope for an event comes only from the request's parent-type/parent-name context, never from the event body. That rule was implicit — the involved object was simply never read — so nothing would have failed if someone started reading it. - Assert the involved/regarding object cannot set scope, on both the core/v1 and events.k8s.io/v1 paths, including when parent context is incomplete. - Add coverage for injectEventsV1ScopeAnnotations, which had none. - Document the invariant and why the event body is untrusted for a tenant-isolation decision. - Alias ExtraKeyParentType/Name and the audit-scope filter's copies to the canonical iam.miloapis.com/v1alpha1 constants, so the two key strings have one definition instead of three. No behaviour change. Split out of #749 to keep that PR to the controller-side change.
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.
Split out of #749 to keep that PR to the controller-side change.
Scope for an event comes only from the request's
parent-type/parent-namecontext, never from the event body. That rule was implicit — the involved object was simply never read — so nothing would have failed if someone started reading it. Review on #749 made the rule explicit; this pins it.core/v1andevents.k8s.io/v1paths, including when parent context is incomplete.injectEventsV1ScopeAnnotations.injectScopeAnnotations.ExtraKeyParentType/Nameand the audit-scope filter's copies aliased to the canonicaliam.miloapis.com/v1alpha1constants — three definitions of the same two strings become one.No behaviour change.
Test plan
go build ./...,gofmt -l .— cleango test ./internal/apiserver/events/... ./pkg/server/filters/...— pass