Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Encode SwiftUI internal class names in session replay redaction to avoid App Store rejections (#7123)

## 8.57.3

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,25 @@ final class SentryUIRedactBuilder {
redactClasses.insert(ClassIdentifier(classId: "SwiftUI.CGDrawingView"))

// Used to render SwiftUI.Text on iOS versions prior to iOS 18
redactClasses.insert(ClassIdentifier(classId: "_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView"))
// This is the base64 representation of `_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView`
// Encoded to avoid triggering apple's rejections, see https://github.com/getsentry/sentry-cocoa/issues/7121
let encodedDrawingView = "X1R0Q09DVjdTd2lmdFVJMTFEaXNwbGF5TGlzdDExVmlld1VwZGF0ZXI4UGxhdGZvcm0xM0NHRHJhd2luZ1ZpZXc="
if let decodedDrawingView = encodedDrawingView.base64Decoded() {
redactClasses.insert(ClassIdentifier(classId: decodedDrawingView))
}

}

if options.maskAllImages {
redactClasses.insert(ClassIdentifier(objcType: UIImageView.self))

// Used by SwiftUI.Image to display SFSymbols, e.g. `Image(systemName: "star.fill")`
redactClasses.insert(ClassIdentifier(classId: "_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView"))
// This is the base64 representation of `_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView`
// Encoded to avoid triggering apple's rejections, see https://github.com/getsentry/sentry-cocoa/issues/7121
let encodedHitTestingView = "X1R0QzdTd2lmdFVJUDMzX0EzNDY0MzExN0YwMDI3N0I5M0RFQkFCNzBFQzA2OTcxMjJfVUlTaGFwZUhpdFRlc3RpbmdWaWV3"
if let decodedHitTestingView = encodedHitTestingView.base64Decoded() {
redactClasses.insert(ClassIdentifier(classId: decodedHitTestingView))
}

// Used by SwiftUI.Image to display images, e.g. `Image("my_image")`.
// The same view class is also used for structural backgrounds. We differentiate by
Expand Down Expand Up @@ -344,6 +354,10 @@ final class SentryUIRedactBuilder {
func isRedactContainerClassTestOnly(_ containerClass: AnyClass) -> Bool {
return isRedactContainerClass(containerClass)
}

func getRedactClassesIdentifiersTestOnly() -> Set<ClassIdentifier> {
redactClassesIdentifiers
}
#endif

/// Identifies and returns the regions within a given `UIView` that need to be redacted.
Expand Down Expand Up @@ -673,6 +687,13 @@ final class SentryUIRedactBuilder {
}
}

private extension String {
func base64Decoded() -> String? {
guard let data = Data(base64Encoded: self) else { return nil }
return String(data: data, encoding: .utf8)
}
}

#endif
#endif
// swiftlint:enable file_length type_body_length
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ class SentryUIRedactBuilderTests_Common: SentryUIRedactBuilderTests { // swiftli
unmaskedViewClasses: unmaskedViewClasses
))
}

// MARK: - Initialization
func testBase64EncodedClassesAreCorrectlyDecoded() {
// -- Arrange --
let sut = getSut(maskAllText: true, maskAllImages: true)

// -- Act --
let redactClassesIdentifiers = sut.getRedactClassesIdentifiersTestOnly()

let containsCGDrawingView = redactClassesIdentifiers.contains(where: { identifier in
return identifier.classId == "_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView"
})
let containsUIShapeHitTestingView = redactClassesIdentifiers.contains(where: { identifier in
return identifier.classId == "_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView"
})

// -- Assert --
XCTAssertTrue(containsCGDrawingView)
XCTAssertTrue(containsUIShapeHitTestingView)
}

// MARK: - Baseline

Expand Down
2 changes: 1 addition & 1 deletion scripts/.swiftlint-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.62.2
0.63.0
Loading