Repository navigation
feat: Sentry.AspNet now follows DataCollection for user info, cookies, headers, query strings and request bodies - #5983
jamescrosswell wants to merge 2 commits into
Conversation
SystemWebRequestEventProcessor and StartSentryTransaction now read the DataCollection resolver instead of SendDefaultPii: UserInfo gates the user, Cookies the cookies and Cookie header, HttpHeaders.Request the headers, UrlQueryParams the query string, and IncomingRequestBody whether the body is read. MaxRequestBodySize still limits the body size. Without ConfigureDataCollection the resolver bridges to SendDefaultPii, so behaviour is unchanged. Closes #5431 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR risk: mediumFor commit Main concerns: data sent to Sentry, public contract, reach. This label is a hint for reviewers, not an approval. |
There was a problem hiding this comment.
Good to approve, with optional comments
Migrates every SendDefaultPii gate in Sentry.AspNet listed in #5431, plus request headers, to the DataCollectionResolver. When DataCollection isn't configured, each bridge resolves to what the old code did, and the call sites match #5980 for ASP.NET Core.
- Optional:
test/Sentry.AspNet.Tests/Internal/SystemWebRequestEventProcessorTests.cs: no test coversHttpHeaders.Request = Offwith cookies still on, whereRequest.Cookiesshould still be captured. That's the System.Web equivalent ofPopulate_DataCollectionRequestHeadersOff_HeadersNotSetButCookiesArein #5980. Here cookies come fromRequest.Cookiesrather than the header loop, so it would pin that independence.
This is an automated preliminary review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5983 +/- ##
==========================================
+ Coverage 77.92% 77.94% +0.01%
==========================================
Files 535 535
Lines 19831 19838 +7
Branches 3967 3968 +1
==========================================
+ Hits 15454 15463 +9
+ Misses 3533 3532 -1
+ Partials 844 843 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ric-oliv
left a comment
There was a problem hiding this comment.
Looking good! While I was going through the user block, I noticed System.Web never sends the client's IP when user info is on, because the core enricher sets {{auto}} before the System.Web processor runs. That's been the case since 5.15.1, so it isn't from this PR. I opened #5985 for it.
One small thing about the description. The context.User?.Identity note says the processor threw and lost the event, but since #5688 the SDK logs a failing SDK processor and moves on. The event still went out, just without the username, claims, server name and request body. Maybe worth a tweak so the reason stays accurate?
Sentry.AspNet(System.Web) now reads the DataCollection resolver instead ofSendDefaultPii, both inSystemWebRequestEventProcessorand for the cookiesStartSentryTransactionattaches to transactions.UserHostAddress,identity.Name,NameIdentifierclaimUserInfoRequest.Cookiesand theCookieheaderCookiesHttpHeaders.RequestUrlQueryParamsHttpBodies(IncomingRequest)Part of #5420 (Phase 2).
Closes #5431
Behaviour
DataCollectionnot configured: unchanged. The resolver bridges each category to whatSendDefaultPiidid here before.ConfigureDataCollection(...)called: each category decides andSendDefaultPiiis ignored. An app that calls it withSendDefaultPii = falseand keeps the defaults now gets the user, deny-listed cookies and a[Filtered]Cookieheader from System.Web requests. This only affects apps that opted into the experimental option.Notes for review
RequestHeadersbridges to a plain deny list, which is what this call site always used.HttpBodiesdecides whether the body is read, andMaxRequestBodySizestill limits its size, as theDataCollectionOptions.HttpBodiesdocs already say. WhenIncomingRequestis off the extractor isn't called, so the request stream isn't touched.context.User?.Identityis now null-safe. Without an auth moduleHttpContext.Useris null, and the processor threw, losing the event. OnlySendDefaultPii = trueapps reached that line before; withUserInfodefaulting totrueonce DataCollection is configured, many more would.Sentry.AspNet.Teststargets net48 and runs on the Windows CI jobs only.🤖 Generated with Claude Code