From 5408ab10c1d1a0830496b9e21db8ef6460d6b604 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 19:28:46 -0700 Subject: [PATCH 1/6] Remove lesser used XPC Services for Test App Testing WebKit2 is more important than testing sandboxed downloader service. More people should be adding entitlements to their app for connection services, so we will do that in the test app too. --- Sparkle.xcodeproj/project.pbxproj | 39 ------------------- TestApplication/Sparkle-Test-App.entitlements | 7 ++++ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index d38c7db3..1b485c6e 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -622,20 +622,6 @@ remoteGlobalIDString = 721C24441CB753E6005440CB; remoteInfo = "Installer Progress"; }; - 724BB3821D3203A9005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB36B1D31D0B7005D534A; - remoteInfo = SparkleInstallerConnection; - }; - 724BB39C1D333832005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB3921D333832005D534A; - remoteInfo = InstallerStatus; - }; 726B2B621C645FC900388755 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -699,13 +685,6 @@ remoteGlobalIDString = 726E07AC1CAF08D6001A286B; remoteInfo = SparkleInstallerLauncher; }; - 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 726E07EE1CAF37BD001A286B; - remoteInfo = SparkleUpdateDownloader; - }; 72F94F6A1CC4A0C8002DEE68 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -2598,11 +2577,8 @@ ); dependencies = ( 61B5F91C09C4CF7200B25A18 /* PBXTargetDependency */, - 724BB3831D3203A9005D534A /* PBXTargetDependency */, 72F94F621CC48669002DEE68 /* PBXTargetDependency */, - 72F94F641CC48669002DEE68 /* PBXTargetDependency */, 726E4A201C86C88F00C57C6A /* PBXTargetDependency */, - 724BB39D1D333832005D534A /* PBXTargetDependency */, ); name = "Sparkle Test App"; productName = "Test Application"; @@ -3794,16 +3770,6 @@ target = 721C24441CB753E6005440CB /* Installer Progress */; targetProxy = 721D8A791D4952B60032E472 /* PBXContainerItemProxy */; }; - 724BB3831D3203A9005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; - targetProxy = 724BB3821D3203A9005D534A /* PBXContainerItemProxy */; - }; - 724BB39D1D333832005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; - targetProxy = 724BB39C1D333832005D534A /* PBXContainerItemProxy */; - }; 726B2B631C645FC900388755 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */; @@ -3849,11 +3815,6 @@ target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; targetProxy = 72F94F611CC48669002DEE68 /* PBXContainerItemProxy */; }; - 72F94F641CC48669002DEE68 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 726E07EE1CAF37BD001A286B /* SparkleDownloader */; - targetProxy = 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */; - }; 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; diff --git a/TestApplication/Sparkle-Test-App.entitlements b/TestApplication/Sparkle-Test-App.entitlements index 35049e47..b0c011b8 100644 --- a/TestApplication/Sparkle-Test-App.entitlements +++ b/TestApplication/Sparkle-Test-App.entitlements @@ -6,6 +6,13 @@ com.apple.security.network.server + com.apple.security.network.client + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + com.apple.security.temporary-exception.shared-preference.read-write org.sparkle-project.SparkleTestApp From 372d711d2003ea6820ac5bb7a1859edc002bb063 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 19:43:12 -0700 Subject: [PATCH 2/6] Remove ATS allow-exception scripts for debug / test app --- Configurations/ConfigCommonCoverage.xcconfig | 1 - Configurations/ConfigCommonDebug.xcconfig | 2 - Configurations/ConfigCommonRelease.xcconfig | 2 - .../set-ats-exceptions-downloader-service.sh | 12 ------ Configurations/set-ats-exceptions-test-app.sh | 12 ------ Sparkle.xcodeproj/project.pbxproj | 39 ------------------- TestApplication/TestApplication-Info.plist | 5 +++ 7 files changed, 5 insertions(+), 68 deletions(-) delete mode 100755 Configurations/set-ats-exceptions-downloader-service.sh delete mode 100755 Configurations/set-ats-exceptions-test-app.sh diff --git a/Configurations/ConfigCommonCoverage.xcconfig b/Configurations/ConfigCommonCoverage.xcconfig index 4eface42..6473d933 100644 --- a/Configurations/ConfigCommonCoverage.xcconfig +++ b/Configurations/ConfigCommonCoverage.xcconfig @@ -1,6 +1,5 @@ #include "ConfigCommonDebug.xcconfig" -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index cbf15592..a47e02c6 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -2,8 +2,6 @@ // Debug only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 04b5a510..7b16ab2e 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -2,8 +2,6 @@ // Release only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 0 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/set-ats-exceptions-downloader-service.sh b/Configurations/set-ats-exceptions-downloader-service.sh deleted file mode 100755 index 9b5fa1b9..00000000 --- a/Configurations/set-ats-exceptions-downloader-service.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# http://stackoverflow.com/questions/32390228/is-it-possible-to-disable-ats-in-ios-9-just-for-debug-environment -INFOPLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}" -case "${SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS}" in -"YES"|"1") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${INFOPLIST}" -;; -"NO"|"0") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads NO" "${INFOPLIST}" -;; -esac diff --git a/Configurations/set-ats-exceptions-test-app.sh b/Configurations/set-ats-exceptions-test-app.sh deleted file mode 100755 index 53ccfc36..00000000 --- a/Configurations/set-ats-exceptions-test-app.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# We should make sure ATS is off for the test app - -DOWNLOADER_INFO_PLIST="${TARGET_BUILD_DIR}"/"${CONTENTS_FOLDER_PATH}"/XPCServices/"${DOWNLOADER_BUNDLE_ID}".xpc/Contents/Info.plist - -#Only alter bundles if code signing is off, else we'll invalidate the signature on them -#If code signing is enabled (as in debug mode), then we rely on another script for turning ATS exceptions on for these services -#In release mode however, those services do not have ATS exceptions set up which is why we have to set up exceptions *here* -if [ -z "${CODE_SIGN_IDENTITY}" ] ; then - /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${DOWNLOADER_INFO_PLIST}" -fi diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 1b485c6e..a6247e8d 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -200,13 +200,11 @@ 7246E0A41C83B685003B4E75 /* SPUStandardUpdaterController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7246E0A21C83B685003B4E75 /* SPUStandardUpdaterController.m */; }; 724BB3711D31D0B7005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3731D31D0B7005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3721D31D0B7005D534A /* main.m */; }; - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3871D32A167005D534A /* SUXPCInstallerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */; }; 724BB3881D32A167005D534A /* SUXPCInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */; }; 724BB3891D32B915005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3981D333832005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; 724BB39A1D333832005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3991D333832005D534A /* main.m */; }; - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB3931D333832005D534A /* org.sparkle-project.InstallerStatus.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3A81D33461B005D534A /* SUXPCInstallerStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */; }; 724BB3A91D33461B005D534A /* SUXPCInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */; }; 724BB3AA1D3347C2005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; @@ -441,7 +439,6 @@ 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */; }; 72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */; }; 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* org.sparkle-project.Downloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; }; 72F9EC341D5BF542004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; }; @@ -784,10 +781,7 @@ dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices"; dstSubfolderSpec = 16; files = ( - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */, - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */, 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */, - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */, 726E4A211C86C88F00C57C6A /* TestAppHelper.xpc in Embed XPC Services */, ); name = "Embed XPC Services"; @@ -1276,8 +1270,6 @@ 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = ""; }; 729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUUpdateValidator.h; path = Sparkle/SUUpdateValidator.h; sourceTree = SOURCE_ROOT; }; 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdateValidator.m; path = Sparkle/SUUpdateValidator.m; sourceTree = SOURCE_ROOT; }; - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-test-app.sh"; sourceTree = ""; }; - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-downloader-service.sh"; sourceTree = ""; }; 729BB3D11D503826007C4276 /* org.sparkle-project.Downloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.Downloader.entitlements"; path = "Downloader/org.sparkle-project.Downloader.entitlements"; sourceTree = SOURCE_ROOT; }; 729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = ""; }; 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = ""; }; @@ -2366,8 +2358,6 @@ EA1E285722B6622E004AA304 /* ed25519-Release.xcconfig */, EA1E285922B6622E004AA304 /* ed25519-Shared.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */, - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */, 14652F7919A93E5F00959E44 /* set-git-version-info.sh */, 720B4C2325EBFAFD005A0592 /* link-tools.sh */, 146EC84E19A68CF8004A50C5 /* Sparkle.podspec */, @@ -2571,7 +2561,6 @@ 61B5F90009C4CEE200B25A18 /* Frameworks */, 61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */, 726E4A261C86C88F00C57C6A /* Embed XPC Services */, - 729BB3CC1D501A8F007C4276 /* Run Script */, ); buildRules = ( ); @@ -2697,7 +2686,6 @@ 726E07EB1CAF37BD001A286B /* Sources */, 726E07EC1CAF37BD001A286B /* Frameworks */, 726E07ED1CAF37BD001A286B /* Resources */, - 729BB3D01D50354C007C4276 /* ShellScript */, ); buildRules = ( ); @@ -3207,33 +3195,6 @@ shellPath = /bin/sh; shellScript = "\"$SRCROOT/Configurations/link-tools.sh\"\n"; }; - 729BB3CC1D501A8F007C4276 /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-test-app.sh\"\n"; - }; - 729BB3D01D50354C007C4276 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-downloader-service.sh\"\n"; - }; 72A5D5F11D692C860009E5AC /* Run Script: Set Git Version Info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/TestApplication/TestApplication-Info.plist b/TestApplication/TestApplication-Info.plist index 428c815c..0672481c 100644 --- a/TestApplication/TestApplication-Info.plist +++ b/TestApplication/TestApplication-Info.plist @@ -30,5 +30,10 @@ http://localhost:1337/sparkletestcast.xml SUPublicEDKey eRFPLZuNM6m8bltmtpPX4fzKbufI1z6rKJHtgIIsllk= + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + From 895bb71faeb5af256de4c9046013352be11a9f59 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:03:59 -0700 Subject: [PATCH 3/6] Add InstallerStatus and InstallerConnection services to Distribution --- Sparkle.xcodeproj/project.pbxproj | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index a6247e8d..cd7b9deb 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -605,6 +605,20 @@ remoteGlobalIDString = 7205C43D1E13049400E370AE; remoteInfo = generate_appcast; }; + 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB36B1D31D0B7005D534A; + remoteInfo = SparkleInstallerConnection; + }; + 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB3921D333832005D534A; + remoteInfo = SparkleInstallerStatus; + }; 721D8A771D4952B60032E472 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -2500,6 +2514,8 @@ 72DBA37A1D5FDE95002594A8 /* PBXTargetDependency */, 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */, 72F94F6D1CC4A0C8002DEE68 /* PBXTargetDependency */, + 7218EC352623ED97008FECF3 /* PBXTargetDependency */, + 7218EC332623ED94008FECF3 /* PBXTargetDependency */, 1454BA1619637EDB00344E57 /* PBXTargetDependency */, 14732BCF1960F73500593899 /* PBXTargetDependency */, 7205C46B1E13070300E370AE /* PBXTargetDependency */, @@ -3721,6 +3737,16 @@ target = 7205C43D1E13049400E370AE /* generate_appcast */; targetProxy = 7205C46A1E13070300E370AE /* PBXContainerItemProxy */; }; + 7218EC332623ED94008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; + targetProxy = 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */; + }; + 7218EC352623ED97008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; + targetProxy = 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */; + }; 721D8A781D4952B60032E472 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72B398D11D3D879300EE297F /* Autoupdate */; From 07e96961bf40bcbb921f9c64df586aec08f84511 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:04:53 -0700 Subject: [PATCH 4/6] Sign altered app in release too for the test app --- TestApplication/SUTestApplicationDelegate.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index ad003e49..84aff79a 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -204,7 +204,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; - (void)signApplicationIfRequiredAtPath:(NSString *)applicationPath completion:(void (^)(void))completionBlock { -#ifdef DEBUG // This is unfortunately necessary for testing sandboxing NSXPCConnection *codeSignConnection = [[NSXPCConnection alloc] initWithServiceName:@"org.sparkle-project.TestAppHelper"]; codeSignConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(TestAppHelperProtocol)]; @@ -216,10 +215,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; completionBlock(); }]; -#else - (void)(applicationPath); // ignore unused warning - completionBlock(); -#endif } - (void)applicationWillTerminate:(NSNotification * __unused)notification From e7bc17b1928a31f3aaba01003d5d72fff26542c2 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:19:33 -0700 Subject: [PATCH 5/6] Use $(PRODUCT_BUNDLE_IDENTIFIER) for defaults exception for test app --- TestApplication/Sparkle-Test-App.entitlements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestApplication/Sparkle-Test-App.entitlements b/TestApplication/Sparkle-Test-App.entitlements index b0c011b8..b9e43ba8 100644 --- a/TestApplication/Sparkle-Test-App.entitlements +++ b/TestApplication/Sparkle-Test-App.entitlements @@ -15,7 +15,7 @@ com.apple.security.temporary-exception.shared-preference.read-write - org.sparkle-project.SparkleTestApp + $(PRODUCT_BUNDLE_IDENTIFIER) From eea87561ab13620cc1589fa1e7b2a63a0f818237 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 21:52:09 -0700 Subject: [PATCH 6/6] Update XPC Service signing script Add entitlements to InstallerConnection and InstallerStatus services and add option to specify bundle id in the now renamed codesign_xpc_service.py script. --- Configurations/codesign_xpc_service.py | 93 +++++++++++++++++++ Configurations/make-release-package.sh | 4 + ...e-project.InstallerConnection.entitlements | 12 +++ ...arkle-project.InstallerStatus.entitlements | 12 +++ Sparkle.xcodeproj/project.pbxproj | 6 ++ bin/codesign_embedded_executable | 46 --------- 6 files changed, 127 insertions(+), 46 deletions(-) create mode 100644 Configurations/codesign_xpc_service.py create mode 100644 InstallerConnection/org.sparkle-project.InstallerConnection.entitlements create mode 100644 InstallerStatus/org.sparkle-project.InstallerStatus.entitlements delete mode 100755 bin/codesign_embedded_executable diff --git a/Configurations/codesign_xpc_service.py b/Configurations/codesign_xpc_service.py new file mode 100644 index 00000000..6c3836db --- /dev/null +++ b/Configurations/codesign_xpc_service.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +import os, sys, subprocess, tempfile, pathlib + +PRODUCT_BUNDLE_ID_MACRO = "$(PRODUCT_BUNDLE_IDENTIFIER)" + +def log_message(message): + sys.stderr.write(message + "\n") + +#Surround a token with double quotes if it has a space in it +def sanitize(argument): + return ('"' + argument + '"' if ' ' in argument else argument) + +def _codesign_service(identity, path, entitlements_path=None): + command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) + log_message(" ".join(map(sanitize, command))) + + process = subprocess.Popen(command, stdout=subprocess.PIPE) + process.communicate() + if process.returncode != 0: + log_message("Error: Failed to codesign %s" % (path)) + sys.exit(1) + +def codesign_service(service_name, identity, path, entitlements_path=None): + #Sign the auxiliary executables (if any) + executables_path = os.path.join(path, "Contents/MacOS/") + if os.path.exists(executables_path): + for executable in os.listdir(executables_path): + if executable != service_name: + _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) + + #Sign the service bundle + _codesign_service(identity, path, entitlements_path) + +# Returns entitlements back with a bundle id applied if needed +def applied_entitlements_path(entitlements_path, bundle_id, temp_dir): + entitlements_str = pathlib.Path(entitlements_path).read_text() + if PRODUCT_BUNDLE_ID_MACRO in entitlements_str: + if bundle_id is None: + return None + else: + new_entitlements_str = entitlements_str.replace(PRODUCT_BUNDLE_ID_MACRO, bundle_id) + new_entitlements_path = os.path.join(temp_dir, os.path.basename(entitlements_path)) + pathlib.Path(new_entitlements_path).write_text(new_entitlements_str) + return new_entitlements_path + else: + return entitlements_path + +def print_usage(): + log_message("Usage:\n\t%s code-signing-identity [-b app-bundle-id] service1 service2 ..." % (sys.argv[0])) + log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/org.sparkle-project.InstallerLauncher.xpc" % (sys.argv[0])) + log_message("") + log_message("Use this script to sign XPC Services to include in your Sandboxed application.") + log_message("") + log_message("bundle-id is optional and only needs to be provided when signing InstallerConnection and InstallerStatus services. Most applications do not need to use these services and can provide additional entitlements to their application instead.") + log_message("") + log_message("This script may not be needed for common development workflows. Please visit https://sparkle-project.org/documentation/sandboxing/ for more details and instructions.") + +if __name__ == "__main__": + if len(sys.argv) < 3: + print_usage() + sys.exit(1) + + signing_identity = sys.argv[1] + remaining_args = sys.argv[2:] + bundle_id = None + if remaining_args[0] == '-b': + if len(remaining_args) < 3: + # We need the bundle-id and at least one XPC Service to sign + print_usage() + sys.exit(1) + else: + bundle_id = remaining_args[1] + services = remaining_args[2:] + else: + services = remaining_args + + with tempfile.TemporaryDirectory() as temp_dir: + for service in services: + parent, child = os.path.split(service) + service_name = os.path.splitext(child)[0] + entitlements_path = os.path.join(parent, service_name + ".entitlements") + if os.path.exists(entitlements_path): + service_entitlements_path = applied_entitlements_path(entitlements_path, bundle_id, temp_dir) + if service_entitlements_path is None: + print_usage() + log_message("") + log_message("Error: Bundle ID must be specified for signing %s. As noted in the usage above, you probably don't need to embed this service." % (service_name)) + sys.exit(1) + else: + service_entitlements_path = None + + codesign_service(service_name, signing_identity, service, service_entitlements_path) diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index ad52a215..6f28327b 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -26,6 +26,8 @@ if [ "$ACTION" = "" ] ; then cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin" + cp "$SRCROOT/Configurations/codesign_xpc_service.py" "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" + chmod 0755 "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging-spm" cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app" "$CONFIGURATION_BUILD_DIR/staging" @@ -43,6 +45,8 @@ if [ "$ACTION" = "" ] ; then cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" cp "$SRCROOT/Downloader/$DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerConnection/$INSTALLER_CONNECTION_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerStatus/$INSTALLER_STATUS_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" # Only copy dSYMs for Release builds, but don't check for the presence of the actual files # because missing dSYMs in a release build SHOULD trigger a build failure diff --git a/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements new file mode 100644 index 00000000..fa7d47e6 --- /dev/null +++ b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + + + diff --git a/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements new file mode 100644 index 00000000..0cceb6d0 --- /dev/null +++ b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + + + diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index cd7b9deb..069ab392 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -1020,6 +1020,9 @@ 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUInstallationType.h; sourceTree = ""; }; 72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = ""; }; 721652671D3C8FED00FD13D8 /* SUInstallerLauncherStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerLauncherStatus.h; path = InstallerLauncher/SUInstallerLauncherStatus.h; sourceTree = SOURCE_ROOT; }; + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerConnection.entitlements"; sourceTree = ""; }; + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerStatus.entitlements"; sourceTree = ""; }; + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = codesign_xpc_service.py; sourceTree = ""; }; 721BC2061D17A532002BC71E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 721BC2081D17A553002BC71E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 721BC20A1D17A5AD002BC71E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; @@ -2107,6 +2110,7 @@ 724BB36E1D31D0B7005D534A /* SUInstallerConnectionProtocol.h */, 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */, 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */, + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */, ); name = InstallerConnection; path = ../InstallerConnection; @@ -2123,6 +2127,7 @@ 7267E5DD1D3D8F5A00D1BF90 /* SUStatusInfoProtocol.h */, 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */, 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */, + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */, ); name = InstallerStatus; path = ../InstallerStatus; @@ -2372,6 +2377,7 @@ EA1E285722B6622E004AA304 /* ed25519-Release.xcconfig */, EA1E285922B6622E004AA304 /* ed25519-Shared.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */, 14652F7919A93E5F00959E44 /* set-git-version-info.sh */, 720B4C2325EBFAFD005A0592 /* link-tools.sh */, 146EC84E19A68CF8004A50C5 /* Sparkle.podspec */, diff --git a/bin/codesign_embedded_executable b/bin/codesign_embedded_executable deleted file mode 100755 index 2337949a..00000000 --- a/bin/codesign_embedded_executable +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -import os, sys, subprocess - -def log_message(message): - sys.stderr.write(message + "\n") - -#Surround a token with double quotes if it has a space in it -def sanitize(argument): - return ('"' + argument + '"' if ' ' in argument else argument) - -def _codesign_service(identity, path, entitlements_path=None): - command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) - log_message(" ".join(map(sanitize, command))) - - process = subprocess.Popen(command, stdout=subprocess.PIPE) - process.communicate() - if process.returncode != 0: - log_message("Error: Failed to codesign %s" % (path)) - sys.exit(1) - -def codesign_service(service_name, identity, path, entitlements_path=None): - #Sign the auxiliary executables (if any) - executables_path = os.path.join(path, "Contents/MacOS/") - if os.path.exists(executables_path): - for executable in os.listdir(executables_path): - if executable != service_name: - _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) - - #Sign the service bundle - _codesign_service(identity, path, entitlements_path) - -if __name__ == "__main__": - if len(sys.argv) < 3: - log_message("Usage:\n\t%s code-signing-identity executable1 executable1 ..." % (sys.argv[0])) - log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/*.xpc" % (sys.argv[0])) - sys.exit(1) - - signing_identity = sys.argv[1] - executables = sys.argv[2:] - - for executable in executables: - parent, child = os.path.split(executable) - service_name = os.path.splitext(child)[0] - entitlements_path = os.path.join(parent, service_name + ".entitlements") - codesign_service(service_name, signing_identity, executable, None if not os.path.exists(entitlements_path) else entitlements_path)