-
Notifications
You must be signed in to change notification settings - Fork 135
Fix audit middleware transport detection to use actual transport type instead of hardcoded paths #1974
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
Merged
Conversation
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
jhrozek
reviewed
Sep 19, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1974 +/- ##
==========================================
+ Coverage 48.13% 48.19% +0.06%
==========================================
Files 233 233
Lines 29229 29240 +11
==========================================
+ Hits 14069 14093 +24
+ Misses 14129 14111 -18
- Partials 1031 1036 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
blkt
reviewed
Sep 19, 2025
dmjb
previously approved these changes
Sep 19, 2025
dmjb
approved these changes
Sep 30, 2025
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.
Summary
This PR fixes the audit middleware's transport detection mechanism to use the actual transport type passed from the command line instead of relying on hardcoded path patterns like
/sse.Problem
The audit middleware was using hardcoded path checking (
strings.Contains(path, "/sse")) to determine if a request was using SSE transport. This approach was problematic because:/v1/sse,/sse,/api/sse)Solution
Refactored the audit middleware to:
sse,streamable-http) from the run configurationstrings.Contains(path, "/sse")logicGETwithAcceptcontainingtext/event-stream(covers SSE + Streamable HTTP stream).NewAuditorWithTransportto require transport type parameterChanges
Core Changes
pkg/audit/auditor.go:transportTypefield toAuditorstructNewAuditorWithTransportto require transport typeisSSETransport()to use direct transport type comparisondetermineEventTypeandaddMetadatapkg/audit/config.go:CreateMiddlewareWithTransportto require transport typeGetMiddlewareFromFileto accept transport type parameterpkg/audit/middleware.go:MiddlewareParamsto includeTransportTypefieldCreateMiddlewareto always use transport-aware constructorisMCPStreamOpenRequest(GET +Accept: text/event-stream) and log connection-open immediately for those; remove path checks andisMCPMessagePost; no ResponseWriter changes.pkg/runner/config_builder.go&pkg/runner/middleware.go:Test Updates
pkg/audit/auditor_test.go&pkg/audit/config_test.go:NewAuditorWithTransportwith appropriate transport typesTestDetermineEventTypeto use correct transport types for each test caseBenefits
Testing
Original identified issue: #1957 (comment)