Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit accc5a0

Browse files
authored
expand data handling (#663)
1 parent 75167cb commit accc5a0

File tree

9 files changed

+58
-17
lines changed

9 files changed

+58
-17
lines changed

src/docs/sdk/basics.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Development Basics
3-
sidebar_order: 0
3+
sidebar_order: 2
44
---
55

66
So you want to develop an SDK? Before you get started here are some basics that are

src/docs/sdk/data-handling.mdx

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,55 @@
11
---
22
title: "Data Handling"
3-
sidebar_order: 5
3+
sidebar_order: 3
44
---
55

66
Data handling is the standardized context in how we want SDKs help users filter data.
77

88
## Sensitive Data
99

10-
In older SDKs you might sometimes see elaborate constructs to allow the user to strip away sensitive data. Newer SDKs no longer have this feature as it turned out to be too hard to maintain per-SDK. Instead, only two simple config options are left:
10+
SDKs should not include PII or other sensitive data in the payload by default.
11+
When building an SDK we can come across to some API that can give useful information to debug a problem.
12+
In the event that API returns data considered PII, we guard that behind a flag called _Send Default PII_.
13+
This is an option in the SDK called [_send-default-pii_](https://docs.sentry.io/platforms/python/configuration/options/#send-default-pii)
14+
and is **disabled by default**. That means that data that is naturally sensitive is not sent by default.
1115

12-
- [_send-default-pii_](https://docs.sentry.io/error-reporting/configuration/#send-default-pii) is **disabled by default**, meaning that data that is naturally sensitive is not sent by default. That means, for example:
16+
Some examples of data guarded by this flag:
1317

14-
- When attaching HTTP requests to events, "raw" bodies (bodies which cannot be parsed as JSON or formdata) are removed, and known sensitive headers such as `Authorization` or `Cookies` are removed too.
18+
- When attaching HTTP requests to events
19+
- Request Body: "raw" bodies (bodies which cannot be parsed as JSON or formdata) are removed
20+
- HTTP Headers: known sensitive headers such as `Authorization` or `Cookies` are removed too.
21+
- *Note* that if a user explicitly sets a request on the scope, nothing is stripped from that request. The above rules only apply to integrations that come with the SDK.
22+
- User-specific information (e.g. the current user ID according to the used web-framework) is not sent at all.
23+
- On desktop applications
24+
- The username logged in the device is not included. This is often a person's name.
25+
- The machine name is not included, for example `Bruno's laptop`
26+
- SDKs don't set `{{auto}}` as `user.ip`. This instructs the server to keep the connection's IP address.*
1527

16-
- User-specific information (e.g. the current user ID according to the used webframework) is not sent at all.
28+
* Specifically about IP address, it's important to note that it's standard to log IP address of incoming connecting in services on the Internet.
29+
This not only allows security tools and operations to understand abuse coming from a single IP, like spam bots and other issues.
30+
But also developers to understand if issues in their application are being triggered by a single malicious source.
1731

18-
- Note that if a user explicitly sets a request on the scope, nothing is stripped from that request. The above rules only apply to integrations that come with the SDK.
32+
Sentry server is always aware of the connecting IP address and can use it for logging in some platforms. Namely JavaScript and iOS/macOS/tvOS.
33+
All other platforms require the event to include `user.ip={{auto}}` which happens if `sendDefaultPii` is set to true.
1934

20-
- [_before-send_](https://docs.sentry.io/error-reporting/configuration/#before-send) can be used to register a callback with custom logic to remove sensitive data.
35+
Before sending events to Sentry, the SDKs should invokes callbacks. That allows users to remove any sensitive data client-side.
36+
37+
- [`before-send` and `event-processors`](https://develop.sentry.dev/sdk/unified-api/#static-api) can be used to register a callback with custom logic to remove sensitive data.
38+
39+
### Application State
40+
41+
App state can be critical to help developers reproduce bugs. For that reason, SDKs often collect app state and append to events through auto instrumentation.
42+
43+
When attaching data that could potentially include sensitive data or PII, it's important to:
44+
45+
- Add a note on the docs to notify developers.
46+
- [Mark that part of the protocol on Relay](https://github.com/getsentry/relay/pull/1383) as such. This allows [data scrubbing](https://docs.sentry.io/product/relay/) to run on those fields.
47+
48+
Some examples of auto instrumentation that could attach sensitive data:
49+
50+
- A SQL integration that includes the query. If a user doesn't use parameterized queries, and appends sensitive data to it, the SDK could include that in the event payload.
51+
- Desktop apps including window title.
52+
- A Web framework routing instrumentation attaching route `to` and `from`.
2153

2254
## Variable Size
2355

src/docs/sdk/features.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'Expected Features'
3-
sidebar_order: 2
3+
sidebar_order: 4
44
---
55

66
The following is a description of features that are commonly expected in Sentry SDKs. Make sure to also
@@ -27,7 +27,7 @@ What scope means depends on the application, for a web framework it is most like
2727

2828
## Automatic Context Data
2929

30-
Automatic addition of useful attributes such as `tags` or `extra` or specific `contexts`. Typically means the SDK hooks into a framework so that it can set attributes that are known to be useful for most users.
30+
Automatic addition of useful attributes such as `tags` or `extra` or specific `contexts`. Typically means the SDK hooks into a framework so that it can set attributes that are known to be useful for most users. Please check [Data Handling](data-handling) for considerations.
3131

3232
## Breadcrumbs
3333

src/docs/sdk/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ The following is a guide for implementing a new Sentry SDK based on the new <Lin
66
It covers the protocol for event submission as well as guidelines for how clients should
77
typically look and behave.
88

9+
- <Link to="/sdk/overview/">Overview</Link>
910
- <Link to="/sdk/philosophy/">Philosophy and Design Principles</Link>
1011
- <Link to="/sdk/basics/">Development Basics</Link>
11-
- <Link to="/sdk/overview/">Overview</Link>
12+
- <Link to="/sdk/data-handling/">Data Handling</Link>
1213
- <Link to="/sdk/unified-api/">Unified API</Link>
1314
- <Link to="/sdk/features/">Expected Features</Link>
1415
- <Link to="/sdk/event-payloads/">Event Payloads</Link>
15-
- <Link to="/sdk/data-handling/">Data Handling</Link>
1616
- <Link to="/sdk/store/">Store Endpoint</Link>
1717
- <Link to="/sdk/envelopes/">Envelopes</Link>
1818
- <Link to="/sdk/sessions/">Sessions</Link>

src/docs/sdk/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Overview
3-
sidebar_order: 0
3+
sidebar_order: 1
44
---
55

66
The following is a guide for implementing a new Sentry SDK. It covers the protocol for event submission as well as guidelines for how clients should typically look and behave.

src/docs/sdk/philosophy.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ At no point should a customer upgrade the library and find themselves in a situa
4646
## Enable Customers
4747

4848
While we generally should try to keep the API surfaces of SDKs reasonable small. At the same time we also need to make sure that we enable customers to achieve their goals. Think about cases that the SDK maybe wouldn't be able to solve out of the box. If there are enough APIs that customers can use our SDKs in more creative ways, we generally see this as a added benefit.
49+
50+
## Handle PII and Sensitive Data with Care
51+
52+
Some types of errors cannot be resolved without the data that was given to the program.
53+
But make sure that auto instrumentations doesn't attach PII without an explicit opt-in from the user.
54+
The server must be aware of parts of the protocol that include PII to scrub them by default.
55+
Please check [Data Handling](data-handling) for more detail.

src/docs/sdk/rate-limiting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'Rate Limiting'
3-
sidebar_order: 3
3+
sidebar_order: 5
44
---
55

66
Rate limits are communicated to SDKs via status codes and response headers. For regular rate limit responses, we emit a [`429`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) status code and specify a [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header.

src/docs/sdk/signal-handlers.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
title: Signal Handlers
3+
sidebar_order: 30
34
---
45

5-
Some Sentry SDKs have to work with signal handlers to trap processes before they
6-
crash. This applies to mobile SDKs as well as the native SDK. As signal handlers
6+
Native Sentry SDKs like sentry-native and sentry-cocoa have to work with signal handlers
7+
to trap processes before they crash.
8+
This applies to mobile SDKs as well as the native SDK. As signal handlers
79
are notoriously difficult to work with and the restrictions placed on us are
810
quite limiting we have to partially bend the rules of what is acceptable.
911

src/docs/sdk/store.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Store Endpoint
3-
sidebar_order: 6
3+
sidebar_order: 50
44
---
55

66
The store endpoint is used to send JSON event payloads to Sentry. It is located

0 commit comments

Comments
 (0)