Skip to content

Reject non-POST requests to the webhook handler#22

Merged
jenting merged 1 commit into
mainfrom
fix/restrict-post-method
Jun 10, 2026
Merged

Reject non-POST requests to the webhook handler#22
jenting merged 1 commit into
mainfrom
fix/restrict-post-method

Conversation

@jenting

@jenting jenting commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

The webhook handler now rejects any non-POST request with 405 Method Not Allowed before attempting to read or unmarshal the body.

Why

The apiserver always sends admission requests as POST. Previously any method (GET, PUT, etc.) would fall through to body reading and JSON unmarshalling, producing misleading 400 errors and doing needless work for stray or probing requests.

Testing

  • go build ./...
  • go test ./... — all pass, including a new TestHandleAdmissionReview_MethodNotAllowed covering GET/PUT/DELETE

🤖 Generated with Claude Code

The apiserver always sends admission requests as POST. Reject any other
method with 405 Method Not Allowed instead of attempting to unmarshal the
body, avoiding wasted work and confusing error responses for stray requests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jenting jenting merged commit d97e15d into main Jun 10, 2026
6 checks passed
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