Merge branch 'master' into ui-separation-and-xpc

This commit is contained in:
Zorg committed 2016-12-04 17:05:01 -05:00
commit 9ea4cf1bf6
12 files changed
+184 -53

No files matched your search

+22 -41
View File
@@ -9,7 +9,7 @@
#import "AppInstaller.h"
#import "TerminationListener.h"
#import "SUInstaller.h"
#import "SPUInstallerValidation.h"
#import "SUUpdateValidator.h"
#import "SULog.h"
#import "SUHost.h"
#import "SULocalizations.h"
@@ -52,6 +52,8 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
@property (nonatomic, strong) TerminationListener *terminationListener;
@property (nonatomic) SUUpdateValidator *updateValidator;
@property (nonatomic, readonly, copy) NSString *hostBundleIdentifier;
@property (nonatomic) SUHost *host;
@property (nonatomic, copy) NSString *updateDirectoryPath;
@@ -68,7 +70,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
@property (nonatomic) BOOL receivedInstallationData;
@property (nonatomic) BOOL finishedValidation;
@property (nonatomic) BOOL agentInitiatedConnection;
@property (nonatomic) BOOL validatedArchiveBeforeExtraction;
@property (nonatomic) dispatch_queue_t installerQueue;
@property (nonatomic) BOOL performedStage1Installation;
@@ -86,6 +87,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
@synthesize receivedUpdaterPong = _receivedUpdaterPong;
@synthesize hostBundleIdentifier = _hostBundleIdentifier;
@synthesize terminationListener = _terminationListener;
@synthesize updateValidator = _updateValidator;
@synthesize host = _host;
@synthesize updateDirectoryPath = _updateDirectoryPath;
@synthesize downloadName = _downloadName;
@@ -96,7 +98,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
@synthesize shouldRelaunch = _shouldRelaunch;
@synthesize shouldShowUI = _shouldShowUI;
@synthesize installer = _installer;
@synthesize validatedArchiveBeforeExtraction = _validatedArchiveBeforeExtraction;
@synthesize willCompleteInstallation = _willCompleteInstallation;
@synthesize receivedInstallationData = _receivedInstallationData;
@synthesize installerQueue = _installerQueue;
@@ -187,23 +188,26 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
NSString *archivePath = [self.updateDirectoryPath stringByAppendingPathComponent:self.downloadName];
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:self.host.bundlePath decryptionPassword:self.decryptionPassword delegate:self];
BOOL success;
if (!unarchiver) {
SULog(@"Error: No valid unarchiver for %@", archivePath);
[self unarchiverDidFail];
success = NO;
} else {
// Delta & package updates will require validation before extraction
// Normal application updates are a bit more lenient allowing developers to change one of apple dev ID or DSA keys
if ([[unarchiver class] requiresValidationBeforeUnarchiving] || ![self.installationType isEqualToString:SPUInstallationTypeApplication]) {
if ([SPUInstallerValidation validateUpdateForHost:self.host archivePath:archivePath DSASignature:self.dsaSignature]) {
self.validatedArchiveBeforeExtraction = YES;
[unarchiver start];
} else {
SULog(@"Error: Archive could not be validated for %@", archivePath);
[self unarchiverDidFail];
}
} else {
[unarchiver start];
}
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated] || ![self.installationType isEqualToString:SPUInstallationTypeApplication];
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath dsaSignature:self.dsaSignature host:self.host performingPrevalidation:needsPrevalidation];
success = self.updateValidator.canValidate;
}
if (!success) {
[self unarchiverDidFail];
} else {
[unarchiver start];
}
}
@@ -219,8 +223,8 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
- (void)unarchiverDidFail
{
// Clear this in case we try another extraction attempt (eg: if it failed once from a delta update)
self.validatedArchiveBeforeExtraction = NO;
// No longer need update validator until next possible extraction (eg: if initial delta update fails)
self.updateValidator = nil;
// Client could try update again with different inputs
// Eg: one common case is if a delta update fails, client may want to fall back to regular update
@@ -240,30 +244,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
{
[self.communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
NSString *archivePath = [self.updateDirectoryPath stringByAppendingPathComponent:self.downloadName];
BOOL isPackage = NO;
// The path to the new bundle or package
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:self.updateDirectoryPath forHost:self.host isPackage:&isPackage isGuided:NULL];
NSURL *installSourceURL = [NSURL fileURLWithPath:installSourcePath];
if (installSourceURL == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
[self cleanupAndExitWithStatus:EXIT_FAILURE];
}
BOOL validationSuccess = YES;
if (!self.validatedArchiveBeforeExtraction) {
if (isPackage) {
// If we get here, then the appcast installation type was lying to us.. This error will be caught later when starting the installer.
validationSuccess = [SPUInstallerValidation validateUpdateForHost:self.host archivePath:archivePath DSASignature:self.dsaSignature];
} else {
// Validate the bundle code signatures and DSA signatures of archive together
validationSuccess = [SPUInstallerValidation validateBundleUpdateForHost:self.host newBundleURL:installSourceURL archivePath:archivePath DSASignature:self.dsaSignature];
}
} else if (!isPackage) {
// Just make sure the bundle is valid to check that the developer didn't make a careless mistake
validationSuccess = [SPUInstallerValidation validateCodeSignatureIfAvailableForBundleURL:installSourceURL];
}
BOOL validationSuccess = [self.updateValidator validateWithUpdateDirectory:self.updateDirectoryPath];
if (!validationSuccess) {
SULog(@"Error: update validation was a failure");
+1 -1
View File
@@ -106,7 +106,7 @@
NSError *error = nil;
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:bundleURL error:&error]) {
SULog(@"Failed to validate code sign signature on bundle at %@", bundleURL);
SULog(@"Failed to validate code sign signature on bundle at %@ with error: %@", bundleURL, error);
return NO;
}
return YES;
+1 -1
View File
@@ -35,7 +35,7 @@
return [[path pathExtension] isEqualToString:@"delta"];
}
+ (BOOL)requiresValidationBeforeUnarchiving
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return YES;
}
+1 -1
View File
@@ -32,7 +32,7 @@
return [[path pathExtension] isEqualToString:@"dmg"];
}
+ (BOOL)requiresValidationBeforeUnarchiving
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return NO;
}
+1 -1
View File
@@ -63,7 +63,7 @@
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
}
+ (BOOL)requiresValidationBeforeUnarchiving
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return NO;
}
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)canUnarchivePath:(NSString *)path;
+ (BOOL)requiresValidationBeforeUnarchiving;
+ (BOOL)unsafeIfArchiveIsNotValidated;
- (void)start;
+1 -1
View File
@@ -17,7 +17,7 @@ SPARKLE_ICON_NAME = AppIcon
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 15
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION_PATCH = 1
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
+1 -1
View File
@@ -14,7 +14,7 @@ release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
cat Sparkle.podspec
@echo "Don't forget to update CocoaPods!"
@echo "Don't forget to update CocoaPods! pod trunk push"
build:
xcodebuild clean build
+6 -5
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.15.0"
s.version = "1.15.1"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -11,15 +11,16 @@ Pod::Spec.new do |s|
:file => 'LICENSE'
}
s.authors = {
'Andy Matuschak' => 'andy@andymatuschak.org',
'Kornel Lesiński' => 'pornel@pornel.net',
'C.W. Betts' => 'computers57@hotmail.com',
'Jake Petroules' => 'jake.petroules@petroules.com',
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
'Kornel Lesiński' => 'pornel@pornel.net',
'Jake Petroules' => 'jake.petroules@petroules.com',
'C.W. Betts' => 'computers57@hotmail.com',
'Andy Matuschak' => 'andy@andymatuschak.org',
}
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Sparkle.framework'
+6
View File
@@ -266,6 +266,7 @@
7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */; };
7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
729924941DF4A45000DBCDF5 /* SUUpdateValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */; };
72A1C2631CD6849C004CD282 /* SPUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SPUUpdatePermissionPrompt.h */; };
72A450531C69A68900D67EEA /* SPUUpdatePermissionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SPUUpdatePermissionResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
72A450541C69A68900D67EEA /* SPUUpdatePermissionResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SPUUpdatePermissionResponse.m */; };
@@ -1041,6 +1042,8 @@
728638EE1CAF589C00783084 /* ConfigDownloader.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigDownloader.xcconfig; sourceTree = "<group>"; };
7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUURLRequest.h; sourceTree = "<group>"; };
7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = "<group>"; };
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 = "<group>"; };
729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-downloader-service.sh"; sourceTree = "<group>"; };
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; };
@@ -1448,6 +1451,8 @@
7267E59E1D3D8A6F00D1BF90 /* main.m */,
7267E5A01D3D8A7E00D1BF90 /* AppInstaller.h */,
7267E5A11D3D8A7E00D1BF90 /* AppInstaller.m */,
729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */,
729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */,
721D8A8A1D4D3A6F0032E472 /* SPUInstallerValidation.h */,
721D8A8B1D4D3A6F0032E472 /* SPUInstallerValidation.m */,
7267E5A61D3D8A9900D1BF90 /* AgentConnection.h */,
@@ -2984,6 +2989,7 @@
7267E5D31D3D8CF200D1BF90 /* bscommon.c in Sources */,
7267E5D41D3D8CF200D1BF90 /* bspatch.c in Sources */,
7267E5D21D3D8CE800D1BF90 /* bsdiff.c in Sources */,
729924941DF4A45000DBCDF5 /* SUUpdateValidator.m in Sources */,
7267E5CE1D3D8C7500D1BF90 /* SULog.m in Sources */,
7267E5CD1D3D8C7200D1BF90 /* SPUSecureCoding.m in Sources */,
7267E5CC1D3D8C6B00D1BF90 /* SUConstants.m in Sources */,
+25
View File
@@ -0,0 +1,25 @@
//
// SUUpdateValidator.h
// Sparkle
//
// Created by Mayur Pawashe on 12/3/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
@class SUHost;
@interface SUUpdateValidator : NSObject
// Pass YES to performingPrevalidation if archive validation must be done immediately, before extraction
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation;
// Indicates whether we can perform (post) validation later
@property (nonatomic, readonly) BOOL canValidate;
// precondition: validation must be possible (see -canValidate)
// This is "post" validation, after an archive has been extracted
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory;
@end
+118
View File
@@ -0,0 +1,118 @@
//
// SUUpdateValidator.m
// Sparkle
//
// Created by Mayur Pawashe on 12/3/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUUpdateValidator.h"
#import "SPUInstallerValidation.h"
#import "SUInstaller.h"
#import "SUHost.h"
#import "SULog.h"
@interface SUUpdateValidator ()
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, readonly) BOOL prevalidatedDsaSignature;
@property (nonatomic, readonly) NSString *dsaSignature;
@property (nonatomic, readonly) NSString *downloadPath;
@end
@implementation SUUpdateValidator
@synthesize host = _host;
@synthesize canValidate = _canValidate;
@synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature;
@synthesize dsaSignature = _dsaSignature;
@synthesize downloadPath = _downloadPath;
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation
{
self = [super init];
if (self != nil) {
BOOL canValidate;
BOOL prevalidatedDsaSignature;
if (performingPrevalidation) {
NSString *publicDSAKey = host.publicDSAKey;
if (publicDSAKey == nil) {
prevalidatedDsaSignature = NO;
SULog(@"Failed to validate update before unarchiving because no DSA key was found");
} else if (dsaSignature == nil) {
prevalidatedDsaSignature = NO;
SULog(@"Failed to validate update before unarchiving because no DSA signature was found");
} else {
prevalidatedDsaSignature = [SPUInstallerValidation validateUpdateForHost:host archivePath:downloadPath DSASignature:dsaSignature];
if (!prevalidatedDsaSignature) {
SULog(@"DSA signature validation before unarchiving failed for update %@", downloadPath);
}
}
canValidate = prevalidatedDsaSignature;
} else {
prevalidatedDsaSignature = NO;
canValidate = YES;
}
_canValidate = canValidate;
_prevalidatedDsaSignature = prevalidatedDsaSignature;
_downloadPath = [downloadPath copy];
_dsaSignature = [dsaSignature copy];
_host = host;
}
return self;
}
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory
{
assert(self.canValidate);
NSString *DSASignature = self.dsaSignature;
NSString *downloadPath = self.downloadPath;
SUHost *host = self.host;
BOOL prevalidatedDsaSignature = self.prevalidatedDsaSignature;
BOOL validationCheckSuccess;
BOOL isPackage = NO;
// install source could point to a new bundle or a package
NSString *installSource = [SUInstaller installSourcePathInUpdateFolder:updateDirectory forHost:host isPackage:&isPackage isGuided:NULL];
if (installSource == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
validationCheckSuccess = NO;
} else {
NSURL *installSourceURL = [NSURL fileURLWithPath:installSource];
if (!prevalidatedDsaSignature) {
// Check to see if we have a package or bundle to validate
if (isPackage) {
// If we get here, then the appcast installation type was lying to us.. This error will be caught later when starting the installer.
// For package type updates, all we do is check if the DSA signature is valid
validationCheckSuccess = [SPUInstallerValidation validateUpdateForHost:host archivePath:downloadPath DSASignature:DSASignature];
if (!validationCheckSuccess) {
SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
}
} else {
// For application bundle updates, validate the bundle code signatures and DSA signatures of archive together
validationCheckSuccess = [SPUInstallerValidation validateBundleUpdateForHost:host newBundleURL:installSourceURL archivePath:downloadPath DSASignature:DSASignature];
}
} else if (isPackage) {
// We already prevalidated the package and nothing else needs to be done
validationCheckSuccess = YES;
} else {
// Because we already prevalidated the DSA signature, this is just a consistency check to see
// if the developer signed their application properly with their Apple ID
// Currently, this case only gets hit for binary delta updates
validationCheckSuccess = [SPUInstallerValidation validateCodeSignatureIfAvailableForBundleURL:installSourceURL];
}
}
return validationCheckSuccess;
}
@end