Skip to content

Commit 2b0de6d

Browse files
committed
Merge remote-tracking branch 'origin/ref/consolidate-vendored-code-v9' into license/remove-application-not-responding-attribution-v9
2 parents fc5f062 + 25ab45c commit 2b0de6d

125 files changed

Lines changed: 834 additions & 1969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
- Only the name and no-arg constructor of `SentryAndroidOptions` are kept, instead of every member of every `SentryOptions` subclass.
1717
- `sentry-android-ndk` no longer keeps native methods of all `io.sentry.**` classes. `sentry-native-ndk` still keeps its own.
1818
- If your code reaches any of these by name through JNI, reflection, or bindings, add your own keep rules for exactly what it uses.
19+
- Remove the deprecated `sendDefaultPii` option from Java APIs, properties and environment variables, Android manifest metadata, and Spring annotations ([#6793](https://github.com/getsentry/sentry-java/pull/6793))
20+
- Configure automatically collected data with `dataCollection` instead. See the Data Collection documentation for [Android](https://docs.sentry.io/platforms/android/configuration/options/#dataCollection), [Java](https://docs.sentry.io/platforms/java/configuration/options/#dataCollection), and [Spring Boot](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/options/#dataCollection). `DataCollection.forceDataCollection()` is also removed because the defaults now apply automatically.
21+
- When no `dataCollection` setting is specified, user information, database query data, file paths, GraphQL documents and variables, and HTTP request and response bodies are enabled. Cookies, URL query parameters, and HTTP headers use their default deny lists.
22+
- Logback raw message templates and parameters are controlled only by `includeUnencodedMessage` when an encoder is configured.
23+
- OpenTelemetry-derived HTTP headers are controlled by OpenTelemetry capture configuration, not Data Collection, because the SDK can't distinguish manually supplied attributes from values added by automatic instrumentation. Known security cookies remain filtered; use `beforeSendTransaction` for additional scrubbing.
24+
- Apply the Data Collection URL query-parameter policy to URL fragments. Sensitive fragment parameters are now filtered by default, and fragments are omitted when URL query-parameter collection is disabled ([#6814](https://github.com/getsentry/sentry-java/pull/6814))
1925
- The Spring Boot 3 integrations are tested against Spring Boot 3.4 and newer. Spring Boot 3.2 and 3.3 are no longer supported ([#6656](https://github.com/getsentry/sentry-java/pull/6656))
2026
- Remove the deprecated `io.sentry.android.core.LoadClass`. Use `io.sentry.util.LoadClass` instead ([#6594](https://github.com/getsentry/sentry-java/pull/6594))
2127
- `SentryOptions.getIgnoredErrors()`, `getIgnoredTransactions()`, `getIgnoredCheckIns()` and `getIgnoredSpanOrigins()` now return `List<String>` instead of `List<FilterString>`, matching their setters ([#6489](https://github.com/getsentry/sentry-java/pull/6489))
@@ -137,11 +143,13 @@
137143

138144
### Fixes
139145

146+
- Omit request cookies when no cookie headers are present ([#6799](https://github.com/getsentry/sentry-java/pull/6799))
140147
- Set Apollo 3, 4, and 5 HTTP spans to `CANCELLED` instead of `INTERNAL_ERROR` when the request is cancelled ([#6284](https://github.com/getsentry/sentry-java/pull/6284))
141148
- Preserve independent Netty read and write timeout events when exception singletons are reused. These exceptions now bypass event deduplication by default, so applications with multiple capture integrations may report the same timeout more than once. Use `SentryOptions.setIgnoredErrorsForDeduplication(...)` or `ignored-errors-for-deduplication` to customize or clear the default exclusions. ([#6465](https://github.com/getsentry/sentry-java/pull/6465))
142149
- Prevent changes to reused tracing options from affecting spans and transactions after creation ([#6417](https://github.com/getsentry/sentry-java/pull/6417))
143150
- Avoid duplicate serialization debug logs when calculating serialized object sizes ([#6255](https://github.com/getsentry/sentry-java/pull/6255))
144151
- `Contexts.setProfile(null)` now removes the profile context instead of throwing ([#6684](https://github.com/getsentry/sentry-java/pull/6684))
152+
- Do not capture failed Apollo 3, 4, and 5 requests when the GraphQL `errors` array is empty ([#6285](https://github.com/getsentry/sentry-java/pull/6285))
145153

146154
### Dependencies
147155

‎REVIEWS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ rule file in [`.cursor/rules/`](.cursor/rules) for the area the diff touches (`a
4848
- Real secrets, tokens, or DSNs in code, logs, or configs. Obviously-fake DSNs in tests, samples,
4949
and docs are expected — do not flag those.
5050
- New code that collects user-identifiable data (headers, cookies, request/response bodies, URL
51-
query strings, IPs, usernames, file paths, device identifiers) must be gated behind
52-
`options.isSendDefaultPii()`, and must not be on by default otherwise.
51+
query strings, IPs, usernames, file paths, device identifiers) must use the corresponding
52+
`DataCollectionResolver` policy and follow the documented defaults.
5353
- Debug flags, verbose logging, or sampling overrides accidentally left enabled in production
5454
defaults.
5555

‎sentry-android-core/src/main/java/io/sentry/android/core/Installation.java‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ final class Installation {
2121

2222
private static final Charset UTF_8 = Charset.forName("UTF-8");
2323

24+
// The id is a UUID, so a valid file is far below this
25+
private static final int MAX_INSTALLATION_FILE_SIZE = 1024;
26+
2427
static final @NotNull AutoClosableReentrantLock staticLock = new AutoClosableReentrantLock();
2528

2629
private Installation() {}
@@ -43,20 +46,33 @@ public static String id(final @NotNull Context context) throws RuntimeException
4346
return deviceId;
4447
}
4548
deviceId = readInstallationFile(installation);
46-
} catch (Throwable e) {
49+
if (deviceId == null) {
50+
deviceId = writeInstallationFile(installation);
51+
}
52+
} catch (IOException e) {
4753
throw new RuntimeException(e);
4854
}
4955
}
5056
return deviceId;
5157
}
5258
}
5359

60+
/**
61+
* Returns null when the file is larger than an id can be, or can't be read, so the caller treats
62+
* it as corrupt. The size check keeps an oversized file from being read into memory.
63+
*/
5464
@TestOnly
55-
static @NotNull String readInstallationFile(final @NotNull File installation) throws IOException {
65+
static @Nullable String readInstallationFile(final @NotNull File installation) {
5666
try (final RandomAccessFile f = new RandomAccessFile(installation, "r")) {
57-
final byte[] bytes = new byte[(int) f.length()];
67+
final long length = f.length();
68+
if (length > MAX_INSTALLATION_FILE_SIZE) {
69+
return null;
70+
}
71+
final byte[] bytes = new byte[(int) length];
5872
f.readFully(bytes);
5973
return new String(bytes, UTF_8);
74+
} catch (IOException e) {
75+
return null;
6076
}
6177
}
6278

‎sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ final class ManifestMetadataReader {
115115
static final String COLLECT_ADDITIONAL_CONTEXT = "io.sentry.additional-context";
116116
static final String COLLECT_EXTERNAL_STORAGE_CONTEXT = "io.sentry.external-storage-context";
117117

118-
static final String SEND_DEFAULT_PII = "io.sentry.send-default-pii";
119-
120118
static final String DATA_COLLECTION_USER_INFO = "io.sentry.data-collection.user-info";
121119
static final String DATA_COLLECTION_HTTP_BODIES = "io.sentry.data-collection.http-bodies";
122120
static final String DATA_COLLECTION_COOKIES = "io.sentry.data-collection.cookies";
@@ -564,9 +562,6 @@ static void applyMetadata(
564562
sdkInfo.setVersion(readStringNotNull(metadata, logger, SDK_VERSION, sdkInfo.getVersion()));
565563
options.setSdkVersion(sdkInfo);
566564

567-
options.setSendDefaultPii(
568-
readBool(metadata, logger, SEND_DEFAULT_PII, options.isSendDefaultPii()));
569-
570565
// sdkInfo.addIntegration();
571566

572567
@Nullable

‎sentry-android-core/src/test/java/io/sentry/android/core/ApplicationExitInfoEventProcessorTest.kt‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ class ApplicationExitInfoEventProcessorTest {
106106
populateScopeCache: Boolean = false,
107107
populateOptionsCache: Boolean = false,
108108
replayErrorSampleRate: Double? = null,
109-
isSendDefaultPii: Boolean = true,
110109
): ApplicationExitInfoEventProcessor {
111110
options.cacheDirPath = dir.newFolder().absolutePath
112111
options.environment = "release"
113-
options.isSendDefaultPii = isSendDefaultPii
114112
options.addScopeObserver(PersistingScopeObserver(options))
115113

116114
whenever(buildInfo.sdkInfoVersion).thenReturn(currentSdk)
@@ -248,7 +246,7 @@ class ApplicationExitInfoEventProcessorTest {
248246
fixture.options.dataCollection.setUserInfo(true)
249247
val hint = HintUtils.createWithTypeCheckHint(AbnormalExitHint())
250248

251-
val processed = processEvent(hint, isSendDefaultPii = false)
249+
val processed = processEvent(hint)
252250

253251
assertNotNull(processed.contexts.device!!.id)
254252
}
@@ -370,17 +368,18 @@ class ApplicationExitInfoEventProcessorTest {
370368
}
371369

372370
@Test
373-
fun `when backfillable event is enrichable, does not backfill user ip`() {
371+
fun `when user info is disabled, does not backfill user ip`() {
372+
fixture.options.dataCollection.setUserInfo(false)
374373
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
375-
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
374+
val processed = processEvent(hint, populateScopeCache = true)
376375
assertNull(processed.user!!.ipAddress)
377376
}
378377

379378
@Test
380379
fun `when user info is disabled, does not backfill automatic user data`() {
381380
fixture.options.dataCollection.setUserInfo(false)
382381
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
383-
val processed = processEvent(hint, isSendDefaultPii = true, populateScopeCache = true)
382+
val processed = processEvent(hint, populateScopeCache = true)
384383

385384
assertEquals("bot", processed.user!!.username)
386385
assertEquals("bot@me.com", processed.user!!.id)
@@ -391,7 +390,7 @@ class ApplicationExitInfoEventProcessorTest {
391390
fun `when user info is enabled, backfills automatic user data`() {
392391
fixture.options.dataCollection.setUserInfo(true)
393392
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
394-
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
393+
val processed = processEvent(hint, populateScopeCache = true)
395394

396395
assertEquals("bot", processed.user!!.username)
397396
assertEquals("bot@me.com", processed.user!!.id)
@@ -1214,7 +1213,6 @@ class ApplicationExitInfoEventProcessorTest {
12141213
tmpDir,
12151214
populateScopeCache = false,
12161215
populateOptionsCache = false,
1217-
isSendDefaultPii = false,
12181216
)
12191217

12201218
val hintTimestamp = System.currentTimeMillis()
@@ -1271,7 +1269,6 @@ class ApplicationExitInfoEventProcessorTest {
12711269
tmpDir,
12721270
populateScopeCache = false,
12731271
populateOptionsCache = false,
1274-
isSendDefaultPii = false,
12751272
)
12761273
fixture.persistOptions(PROGUARD_UUID_FILENAME, "previous-uuid")
12771274
setLastUpdateTime(2_000)
@@ -1441,7 +1438,6 @@ class ApplicationExitInfoEventProcessorTest {
14411438
hint: Hint,
14421439
populateScopeCache: Boolean = false,
14431440
populateOptionsCache: Boolean = false,
1444-
isSendDefaultPii: Boolean = true,
14451441
configureEvent: SentryEvent.() -> Unit = {},
14461442
): SentryEvent {
14471443
val original = SentryEvent().apply(configureEvent)
@@ -1451,7 +1447,6 @@ class ApplicationExitInfoEventProcessorTest {
14511447
tmpDir,
14521448
populateScopeCache = populateScopeCache,
14531449
populateOptionsCache = populateOptionsCache,
1454-
isSendDefaultPii = isSendDefaultPii,
14551450
)
14561451
return processor.process(original, hint)!!
14571452
}

‎sentry-android-core/src/test/java/io/sentry/android/core/DefaultAndroidEventProcessorTest.kt‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class DefaultAndroidEventProcessorTest {
7373

7474
lateinit var sentryTracer: SentryTracer
7575

76-
fun getSut(context: Context, isSendDefaultPii: Boolean = false): DefaultAndroidEventProcessor {
77-
options.isSendDefaultPii = isSendDefaultPii
76+
fun getSut(context: Context): DefaultAndroidEventProcessor {
7877
whenever(scopes.options).thenReturn(options)
7978
sentryTracer = SentryTracer(TransactionContext("", ""), scopes)
8079
return DefaultAndroidEventProcessor(context, buildInfo, options)
@@ -269,16 +268,8 @@ class DefaultAndroidEventProcessorTest {
269268
}
270269

271270
@Test
272-
fun `when event user data does not have ip address set, sets no ip address if sendDefaultPii is false`() {
273-
val sut = fixture.getSut(context, isSendDefaultPii = false)
274-
val event = SentryEvent().apply { user = User() }
275-
sut.process(event, Hint())
276-
assertNotNull(event.user) { assertNull(it.ipAddress) }
277-
}
278-
279-
@Test
280-
fun `when event user data does not have ip address set, sets {{auto}} if sendDefaultPii is true`() {
281-
val sut = fixture.getSut(context, isSendDefaultPii = true)
271+
fun `when event user data does not have ip address set, sets {{auto}} by default`() {
272+
val sut = fixture.getSut(context)
282273
val event = SentryEvent().apply { user = User() }
283274
sut.process(event, Hint())
284275
assertNotNull(event.user) { assertEquals("{{auto}}", it.ipAddress) }
@@ -287,7 +278,7 @@ class DefaultAndroidEventProcessorTest {
287278
@Test
288279
fun `when user info is disabled, sets installation id but not automatic ip`() {
289280
fixture.options.dataCollection.setUserInfo(false)
290-
val sut = fixture.getSut(context, isSendDefaultPii = true)
281+
val sut = fixture.getSut(context)
291282
val event = SentryEvent().apply { user = User() }
292283

293284
sut.process(event, Hint())
@@ -301,7 +292,7 @@ class DefaultAndroidEventProcessorTest {
301292
@Test
302293
fun `when user info is enabled, sets automatic user data`() {
303294
fixture.options.dataCollection.setUserInfo(true)
304-
val sut = fixture.getSut(context, isSendDefaultPii = false)
295+
val sut = fixture.getSut(context)
305296
val event = SentryEvent().apply { user = User() }
306297

307298
sut.process(event, Hint())

‎sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt‎

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,37 +1482,14 @@ class ManifestMetadataReaderTest {
14821482
}
14831483

14841484
@Test
1485-
fun `applyMetadata reads send default pii and keep default value if not found`() {
1486-
// Arrange
1487-
val context = fixture.getContext()
1488-
1489-
// Act
1490-
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1491-
1492-
// Assert
1493-
assertFalse(fixture.options.isSendDefaultPii)
1494-
}
1495-
1496-
@Test
1497-
fun `applyMetadata reads send default pii to options`() {
1498-
// Arrange
1499-
val bundle = bundleOf(ManifestMetadataReader.SEND_DEFAULT_PII to true)
1500-
val context = fixture.getContext(metaData = bundle)
1501-
1502-
// Act
1503-
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1504-
1505-
// Assert
1506-
assertTrue(fixture.options.isSendDefaultPii)
1507-
}
1508-
1509-
@Test
1510-
fun `applyMetadata preserves legacy data collection when metadata is absent`() {
1485+
fun `applyMetadata uses data collection defaults when metadata is absent`() {
15111486
val context = fixture.getContext()
15121487

15131488
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
15141489

1515-
assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
1490+
assertThat(fixture.options.dataCollectionResolver.isUserInfo).isTrue()
1491+
assertThat(fixture.options.dataCollectionResolver.cookies)
1492+
.isEqualTo(KeyValueCollectionBehavior.denyList())
15161493
}
15171494

15181495
@Test
@@ -1605,32 +1582,14 @@ class ManifestMetadataReaderTest {
16051582
assertThat(fixture.options.dataCollection.httpBodies).isEmpty()
16061583
}
16071584

1608-
@Test
1609-
fun `applyMetadata data collection takes precedence over send default pii`() {
1610-
val bundle =
1611-
bundleOf(
1612-
ManifestMetadataReader.SEND_DEFAULT_PII to false,
1613-
ManifestMetadataReader.DATA_COLLECTION_COOKIES + ".mode" to "off",
1614-
)
1615-
val context = fixture.getContext(metaData = bundle)
1616-
1617-
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1618-
1619-
assertThat(fixture.options.isSendDefaultPii).isFalse()
1620-
assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isTrue()
1621-
assertThat(fixture.options.dataCollectionResolver.isUserInfo).isTrue()
1622-
assertThat(fixture.options.dataCollectionResolver.cookies)
1623-
.isEqualTo(KeyValueCollectionBehavior.off())
1624-
}
1625-
16261585
@Test
16271586
fun `applyMetadata ignores invalid data collection body type`() {
16281587
val bundle = bundleOf(ManifestMetadataReader.DATA_COLLECTION_HTTP_BODIES to "invalid")
16291588
val context = fixture.getContext(metaData = bundle)
16301589

16311590
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
16321591

1633-
assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
1592+
assertThat(fixture.options.dataCollection.httpBodies).isNull()
16341593
}
16351594

16361595
@Test
@@ -1640,7 +1599,7 @@ class ManifestMetadataReaderTest {
16401599

16411600
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
16421601

1643-
assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
1602+
assertThat(fixture.options.dataCollection.cookies).isNull()
16441603
}
16451604

16461605
@Test

‎sentry-android-integration-tests/sentry-samples-android/src/main/AndroidManifest.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,6 @@
318318
android:name="io.sentry.attach-view-hierarchy"
319319
android:value="true" />
320320

321-
<!-- how to enable the send default pii-->
322-
<meta-data
323-
android:name="io.sentry.send-default-pii"
324-
android:value="true" />
325-
326321
<!-- how to disable sentry -->
327322
<!-- <meta-data android:name="io.sentry.enabled" android:value="false" /> -->
328323

‎sentry-apollo-3/detekt-baseline.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ID>CyclomaticComplexMethod:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$private fun captureEvent( request: HttpRequest, response: HttpResponse, operationName: String?, operationType: String?, )</ID>
88
<ID>LongMethod:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$private fun captureEvent( request: HttpRequest, response: HttpResponse, operationName: String?, operationType: String?, )</ID>
99
<ID>LongParameterList:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$( span: ISpan?, request: HttpRequest, response: HttpResponse?, statusCode: Int?, operationName: String?, operationType: String?, operationId: String?, )</ID>
10-
<ID>LongParameterList:SentryApollo3InterceptorClientErrors.kt$SentryApollo3InterceptorClientErrors.Fixture$( captureFailedRequests: Boolean = DEFAULT_CAPTURE_FAILED_REQUESTS, failedRequestTargets: List&lt;String> = listOf(DEFAULT_PROPAGATION_TARGETS), httpStatusCode: Int = 200, responseBody: String = responseBodyOk, sendDefaultPii: Boolean = false, includeCookies: Boolean = sendDefaultPii, socketPolicy: SocketPolicy = SocketPolicy.KEEP_OPEN, configureOptions: SentryOptions.() -> Unit = {}, )</ID>
10+
<ID>LongParameterList:SentryApollo3InterceptorClientErrors.kt$SentryApollo3InterceptorClientErrors.Fixture$( captureFailedRequests: Boolean = DEFAULT_CAPTURE_FAILED_REQUESTS, failedRequestTargets: List&lt;String> = listOf(DEFAULT_PROPAGATION_TARGETS), httpStatusCode: Int = 200, responseBody: String = responseBodyOk, includeCookies: Boolean = false, socketPolicy: SocketPolicy = SocketPolicy.KEEP_OPEN, configureOptions: SentryOptions.() -> Unit = {}, )</ID>
1111
<ID>MaxLineLength:LaunchDetailsQuery.kt$LaunchDetailsQuery.Companion$"query LaunchDetails(${'$'}id: ID!) { launch(id: ${'$'}id) { id site mission { name missionPatch(size: LARGE) } rocket { name type } } }"</ID>
1212
<ID>MaxLineLength:SentryApollo3InterceptorTest.kt$SentryApollo3InterceptorTest$"thirdPartyBaggage=someValue,secondThirdPartyBaggage=secondValue; property;propertyKey=propertyValue,anotherThirdPartyBaggage=anotherValue"</ID>
1313
<ID>MaxLineLength:SentryApollo3InterceptorTest.kt$SentryApollo3InterceptorTest.Fixture$"secondThirdPartyBaggage=secondValue; property;propertyKey=propertyValue,anotherThirdPartyBaggage=anotherValue"</ID>

0 commit comments

Comments
 (0)