Skip to content

test(events): pin the scope-injection invariant - #751

Closed
yahyafakhroji wants to merge 1 commit into
mainfrom
test/pin-scope-injection-invariant
Closed

test(events): pin the scope-injection invariant#751
yahyafakhroji wants to merge 1 commit into
mainfrom
test/pin-scope-injection-invariant

Conversation

@yahyafakhroji

Copy link
Copy Markdown
Contributor

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-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. Review on #749 made the rule explicit; this pins it.

  • Tests asserting the involved/regarding object cannot set scope, on both the core/v1 and events.k8s.io/v1 paths, including when parent context is incomplete.
  • First coverage for injectEventsV1ScopeAnnotations.
  • The invariant documented on injectScopeAnnotations.
  • ExtraKeyParentType/Name and the audit-scope filter's copies aliased to the canonical iam.miloapis.com/v1alpha1 constants — three definitions of the same two strings become one.

No behaviour change.

Test plan

  • go build ./..., gofmt -l . — clean
  • go test ./internal/apiserver/events/... ./pkg/server/filters/... — pass

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.
@yahyafakhroji
yahyafakhroji deleted the test/pin-scope-injection-invariant branch August 6, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant