diff --git a/CHANGELOG.md b/CHANGELOG.md index c75dc8ddc7b..be3f55dd283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Breaking Changes + +- Bumped minimum macOS version from 10.14.0 to 10.15.0 + ## 9.1.0 > [!Warning] diff --git a/Package.swift b/Package.swift index 0c36cba063c..0371e709b98 100644 --- a/Package.swift +++ b/Package.swift @@ -114,7 +114,7 @@ var targets: [Target] = [ let package = Package( name: "Sentry", - platforms: [.iOS(.v15), .macOS(.v10_14), .tvOS(.v15), .watchOS(.v8), .visionOS(.v1)], + platforms: [.iOS(.v15), .macOS(.v10_15), .tvOS(.v15), .watchOS(.v8), .visionOS(.v1)], products: products, targets: targets, swiftLanguageModes: [.v5], diff --git a/Sources/Configuration/DeploymentTargets.xcconfig b/Sources/Configuration/DeploymentTargets.xcconfig index 0d5622c773b..f557a82acfc 100644 --- a/Sources/Configuration/DeploymentTargets.xcconfig +++ b/Sources/Configuration/DeploymentTargets.xcconfig @@ -1,4 +1,4 @@ -MACOSX_DEPLOYMENT_TARGET = 10.14 +MACOSX_DEPLOYMENT_TARGET = 10.15 IPHONEOS_DEPLOYMENT_TARGET = 15.0 TVOS_DEPLOYMENT_TARGET = 15.0 WATCHOS_DEPLOYMENT_TARGET = 8.0 diff --git a/Sources/Configuration/SentrySwiftUI.xcconfig b/Sources/Configuration/SentrySwiftUI.xcconfig index b7042d49099..cd2a55f2b9c 100644 --- a/Sources/Configuration/SentrySwiftUI.xcconfig +++ b/Sources/Configuration/SentrySwiftUI.xcconfig @@ -1,7 +1,7 @@ PRODUCT_NAME = SentrySwiftUI CURRENT_PROJECT_VERSION = 9.1.0 -MACOSX_DEPLOYMENT_TARGET = 10.14 +MACOSX_DEPLOYMENT_TARGET = 10.15 IPHONEOS_DEPLOYMENT_TARGET = 15.0 WATCHOS_DEPLOYMENT_TARGET = 8.0 TVOS_DEPLOYMENT_TARGET = 15.0 diff --git a/Sources/Swift/SentryDsn.swift b/Sources/Swift/SentryDsn.swift index d12ee3b3a36..0722bf54342 100644 --- a/Sources/Swift/SentryDsn.swift +++ b/Sources/Swift/SentryDsn.swift @@ -1,8 +1,7 @@ @_implementationOnly import _SentryPrivate +import CryptoKit import Foundation -import CommonCrypto - /// Represents a Sentry Data Source Name (DSN) which identifies a Sentry project. @objc(SentryDsn) public final class SentryDsn: NSObject { @@ -78,12 +77,8 @@ public final class SentryDsn: NSObject { data = Data() } - var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH)) - data.withUnsafeBytes { bytes in - _ = CC_SHA1(bytes.baseAddress, CC_LONG(data.count), &digest) - } - - return digest.map { String(format: "%02x", $0) }.joined() + let hash = Insecure.SHA1.hash(data: data) + return hash.map { String(format: "%02x", $0) }.joined() } /// Returns the envelope endpoint URL for this DSN. diff --git a/Tests/SentryTests/Networking/SentryDsnTests.m b/Tests/SentryTests/Networking/SentryDsnTests.m index 00636569c07..e09318541bd 100644 --- a/Tests/SentryTests/Networking/SentryDsnTests.m +++ b/Tests/SentryTests/Networking/SentryDsnTests.m @@ -81,4 +81,46 @@ - (void)testGetEnvelopeDsnCachesResult XCTAssertTrue([dsn getEnvelopeEndpoint] == [dsn getEnvelopeEndpoint]); } +- (void)testGetHash_ReturnsSHA1Hash +{ + SentryDsn *dsn = [[SentryDsn alloc] initWithString:@"https://username:password@getsentry.net/1" + didFailWithError:nil]; + + NSString *hash = [dsn getHash]; + + XCTAssertNotNil(hash); + XCTAssertEqual(hash.length, 40, @"SHA1 hash should be 40 characters"); + + NSCharacterSet *hexCharacterSet = + [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdef"]; + NSCharacterSet *hashCharacterSet = [NSCharacterSet characterSetWithCharactersInString:hash]; + XCTAssertTrue([hexCharacterSet isSupersetOfSet:hashCharacterSet], + @"Hash should only contain hexadecimal characters"); +} + +- (void)testGetHash_IsConsistent +{ + NSString *dsnString = @"https://username:password@getsentry.net/1"; + SentryDsn *dsn1 = [[SentryDsn alloc] initWithString:dsnString didFailWithError:nil]; + SentryDsn *dsn2 = [[SentryDsn alloc] initWithString:dsnString didFailWithError:nil]; + + NSString *hash1 = [dsn1 getHash]; + NSString *hash2 = [dsn2 getHash]; + + XCTAssertEqualObjects(hash1, hash2, @"Same DSN should produce the same hash"); +} + +- (void)testGetHash_DifferentDsnProducesDifferentHash +{ + SentryDsn *dsn1 = [[SentryDsn alloc] initWithString:@"https://user1:pass1@getsentry.net/1" + didFailWithError:nil]; + SentryDsn *dsn2 = [[SentryDsn alloc] initWithString:@"https://user2:pass2@getsentry.net/2" + didFailWithError:nil]; + + NSString *hash1 = [dsn1 getHash]; + NSString *hash2 = [dsn2 getHash]; + + XCTAssertNotEqualObjects(hash1, hash2, @"Different DSNs should produce different hashes"); +} + @end diff --git a/sdk_api.json b/sdk_api.json index 3de45287fa0..4372d37ee4c 100644 --- a/sdk_api.json +++ b/sdk_api.json @@ -30755,22 +30755,22 @@ }, { "kind": "Import", - "name": "CommonCrypto", - "printedName": "CommonCrypto", + "name": "CoreGraphics", + "printedName": "CoreGraphics", "declKind": "Import", "moduleName": "Sentry" }, { "kind": "Import", - "name": "CoreGraphics", - "printedName": "CoreGraphics", + "name": "CoreMedia", + "printedName": "CoreMedia", "declKind": "Import", "moduleName": "Sentry" }, { "kind": "Import", - "name": "CoreMedia", - "printedName": "CoreMedia", + "name": "CryptoKit", + "printedName": "CryptoKit", "declKind": "Import", "moduleName": "Sentry" },