Fix unsafe json access in sentry_device#3309
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3309 +/- ##
==========================================
- Coverage 88.08% 88.00% -0.09%
==========================================
Files 295 296 +1
Lines 10217 10244 +27
==========================================
+ Hits 9000 9015 +15
- Misses 1217 1229 +12 ☔ View full report in Codecov by Sentry. |
Contributor
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 944b773 | 1252.82 ms | 1254.08 ms | 1.27 ms |
| aeb02f2 | 1244.29 ms | 1256.55 ms | 12.26 ms |
| 5b9a0da | 1249.69 ms | 1250.71 ms | 1.03 ms |
| 40c8f93 | 1234.27 ms | 1261.98 ms | 27.71 ms |
| 819c1e7 | 1250.59 ms | 1249.08 ms | -1.51 ms |
| c1e775e | 1263.08 ms | 1275.32 ms | 12.24 ms |
| c8596a6 | 1234.11 ms | 1241.19 ms | 7.08 ms |
| 192b44c | 1269.08 ms | 1275.52 ms | 6.44 ms |
| de377fd | 1252.28 ms | 1254.76 ms | 2.48 ms |
| e2d675d | 1238.48 ms | 1242.76 ms | 4.28 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 944b773 | 5.53 MiB | 6.00 MiB | 479.98 KiB |
| aeb02f2 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 5b9a0da | 5.53 MiB | 5.96 MiB | 444.32 KiB |
| 40c8f93 | 5.53 MiB | 6.00 MiB | 479.94 KiB |
| 819c1e7 | 5.53 MiB | 6.00 MiB | 479.96 KiB |
| c1e775e | 20.70 MiB | 22.46 MiB | 1.75 MiB |
| c8596a6 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 192b44c | 5.53 MiB | 5.96 MiB | 444.33 KiB |
| de377fd | 20.71 MiB | 22.43 MiB | 1.73 MiB |
| e2d675d | 7.86 MiB | 9.44 MiB | 1.58 MiB |
Previous results on branch: fix/unsafe-access-sentry-device
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5551800 | 1261.46 ms | 1265.96 ms | 4.50 ms |
| 2a0b9c7 | 1233.52 ms | 1246.59 ms | 13.07 ms |
| d177ad0 | 1246.53 ms | 1245.63 ms | -0.90 ms |
| 3563704 | 1260.73 ms | 1257.17 ms | -3.57 ms |
| 3e5fad6 | 1269.69 ms | 1264.14 ms | -5.54 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5551800 | 5.53 MiB | 6.00 MiB | 484.71 KiB |
| 2a0b9c7 | 5.53 MiB | 6.00 MiB | 484.82 KiB |
| d177ad0 | 5.53 MiB | 6.00 MiB | 485.18 KiB |
| 3563704 | 5.53 MiB | 6.00 MiB | 484.98 KiB |
| 3e5fad6 | 5.53 MiB | 6.00 MiB | 484.73 KiB |
Contributor
Android Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 575ebaa | 478.00 ms | 585.76 ms | 107.76 ms |
| 73a3c38 | 478.18 ms | 526.62 ms | 48.44 ms |
| 819c1e7 | 449.80 ms | 442.98 ms | -6.82 ms |
| a10aff4 | 488.19 ms | 515.02 ms | 26.83 ms |
| 7cfee3b | 498.78 ms | 516.98 ms | 18.20 ms |
| 3615e19 | 468.38 ms | 504.71 ms | 36.33 ms |
| 73dca78 | 476.53 ms | 522.21 ms | 45.68 ms |
| aeb02f2 | 373.84 ms | 437.00 ms | 63.16 ms |
| e2d675d | 457.92 ms | 529.17 ms | 71.25 ms |
| 2cb90b9 | 479.38 ms | 552.69 ms | 73.31 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 575ebaa | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 73a3c38 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 819c1e7 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| a10aff4 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
| 7cfee3b | 6.54 MiB | 7.70 MiB | 1.17 MiB |
| 3615e19 | 6.54 MiB | 7.70 MiB | 1.16 MiB |
| 73dca78 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| aeb02f2 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| e2d675d | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 2cb90b9 | 6.54 MiB | 7.70 MiB | 1.17 MiB |
Previous results on branch: fix/unsafe-access-sentry-device
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3e5fad6 | 365.02 ms | 361.24 ms | -3.78 ms |
| 5551800 | 579.29 ms | 598.21 ms | 18.92 ms |
| 2a0b9c7 | 433.07 ms | 457.19 ms | 24.12 ms |
| 3563704 | 411.51 ms | 440.96 ms | 29.45 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3e5fad6 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 5551800 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 2a0b9c7 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 3563704 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
buenaflor
commented
Oct 23, 2025
Comment on lines
+46
to
+50
| // Handle numeric 0 and 1 as boolean values | ||
| if (value is num) { | ||
| if (value == 0) return false; | ||
| if (value == 1) return true; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
the reason for this is when using FFI objective_c conversions bool are represented as 1 or 0 nums
denrase
requested changes
Oct 23, 2025
denrase
reviewed
Oct 23, 2025
| /// Extension providing type-safe value extraction from JSON maps | ||
| @internal | ||
| extension TypeSafeMapExtension on Map<String, dynamic> { | ||
| /// Generic, type-safe extraction with a few built-in coercions: |
denrase
approved these changes
Oct 23, 2025
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
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.
📜 Description
Currently accessing the json values is not type safe
💡 Motivation and Context
Fixes #3301
💚 How did you test it?
Unit tests
📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
Replace other protocol classes to use the new type safe access methods