Skip to content

fix(pii): Add more conditionals around sending data #16143

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Apr 28, 2025

Based on the docs work for the issue getsentry/sentry-docs#13407, I went through the repository and looked for places where a conditional check for sendDefaultPii might be missing.

@@ -205,6 +205,7 @@ function endSpan(span: Span, handlerData: HandlerDataFetch): void {
if (handlerData.response) {
setHttpStatus(span, handlerData.response.status);

// fixme: only send if `sendDefaultPii`?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think content length is something we could send

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean w/o sendDefaultPii === true? agreed!

@@ -45,6 +45,7 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =

const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {
...include,
// todo: also exclude cookies and headers if sendDefaultPii is false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually something we should do - the question is if we do this in a minor or major?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Http Client integration for browser, we only include the cookie data if this is explicitly enabled:

if (_shouldSendDefaultPii()) {
try {
const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;
if (cookieString) {
responseCookies = _parseCookieString(cookieString);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we should do it but my gut feeling is to do it in a major (see review comment)

@@ -17,6 +17,7 @@ export function serializeFormData(formData: FormData): string {

/** Get the string representation of a body. */
export function getBodyString(body: unknown, _logger: Logger = logger): [string | undefined, NetworkMetaWarning?] {
// fixme: only add body string if `sendDefaultPii` is enabled?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, we'll just need to add maxRequestBodySize

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only used in conjunction with Replay and the feature being enabled but I might be missing a case

@@ -232,7 +232,7 @@ function wrapRequestHandler<T extends RouteHandler = RouteHandler>(
if (response?.status) {
setHttpStatus(span, response.status);
isolationScope.setContext('response', {
headers: response.headers.toJSON(),
headers: response.headers.toJSON(), // fixme: headers are passed 1:1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the header-related data, we need to decide on whether we want to keep sending them all, filter them by excluding e.g. authorization headers or not send them all when no PII should be sent.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the data you identified should all be gated by the option (see comments). But to me it seems like we can only make this changes when we ship the next major, just so that users are more aware of the changes and they might need to set this flag.

Therefore, my overall suggestion would be to replace fixme with TODO(v10), merge this and ensure we track the change for v10.

If folks have other opinions that's fine, too. But let's make sure we avoid surprising users with data we no longer send :)

@@ -205,6 +205,7 @@ function endSpan(span: Span, handlerData: HandlerDataFetch): void {
if (handlerData.response) {
setHttpStatus(span, handlerData.response.status);

// fixme: only send if `sendDefaultPii`?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean w/o sendDefaultPii === true? agreed!

Comment on lines 62 to 63
// fixme: integration can be included - but integration should not add IP address etc
...(options.sendDefaultPii ? [requestDataIntegration()] : []),
Copy link
Member

@Lms24 Lms24 Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I agree that we should handle this within the integration instead of the top-level decision here.

@s1gr1d s1gr1d marked this pull request as ready for review April 30, 2025 15:48
@s1gr1d s1gr1d requested a review from a team as a code owner April 30, 2025 15:48
@s1gr1d s1gr1d requested a review from Lms24 April 30, 2025 15:48
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.

2 participants