mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5ce2e5499 | ||
|
|
847471aa89 | ||
|
|
6b2af4865a | ||
|
|
9d84b40080 | ||
|
|
0731b6e60d | ||
|
|
3fd125f629 | ||
|
|
ee0a9c99b9 | ||
|
|
9118cb6ecd | ||
|
|
6c90c08ce1 | ||
|
|
3cea65605b |
No files matched your search
@@ -1,20 +0,0 @@
|
||||
excluded:
|
||||
- Vendor
|
||||
disabled_rules:
|
||||
- opening_brace
|
||||
- empty_parentheses_with_trailing_closure
|
||||
- function_body_length
|
||||
- line_length
|
||||
- cyclomatic_complexity
|
||||
- large_tuple
|
||||
|
||||
# Rule-specific config
|
||||
trailing_comma:
|
||||
mandatory_comma: true
|
||||
force_try:
|
||||
severity: warning
|
||||
force_cast:
|
||||
severity: warning
|
||||
identifier_name:
|
||||
min_length:
|
||||
warning: 2
|
||||
+4
-6
@@ -1,7 +1,5 @@
|
||||
os: osx
|
||||
language: objective-c
|
||||
osx_image:
|
||||
- xcode10.3
|
||||
- xcode11.4
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -project Sparkle.xcodeproj -scheme Distribution -derivedDataPath build -enableCodeCoverage YES | xcpretty
|
||||
osx_image: xcode9
|
||||
before_install:
|
||||
- brew update
|
||||
script: make ci
|
||||
+10
-14
@@ -58,7 +58,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@property (nonatomic, copy) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy) NSString *downloadName;
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
@property (nonatomic, strong) SUSignatures *signatures;
|
||||
@property (nonatomic, copy) NSString *dsaSignature;
|
||||
@property (nonatomic, copy) NSString *relaunchPath;
|
||||
@property (nonatomic, copy) NSString *installationType;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@@ -91,7 +91,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@synthesize updateDirectoryPath = _updateDirectoryPath;
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize installationType = _installationType;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@@ -188,23 +188,19 @@ 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];
|
||||
|
||||
BOOL success = NO;
|
||||
BOOL success;
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@", archivePath);
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:self.signatures host:self.host];
|
||||
|
||||
// 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
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![self.installationType isEqualToString:SPUInstallationTypeApplication];
|
||||
|
||||
if (needsPrevalidation) {
|
||||
success = [self.updateValidator validateDownloadPath];
|
||||
} else {
|
||||
success = YES;
|
||||
}
|
||||
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) {
|
||||
@@ -255,7 +251,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
self.updateDirectoryPath = nil;
|
||||
self.downloadName = nil;
|
||||
self.decryptionPassword = nil;
|
||||
self.signatures = nil;
|
||||
self.dsaSignature = nil;
|
||||
self.relaunchPath = nil;
|
||||
self.host = nil;
|
||||
|
||||
@@ -391,7 +387,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
self.installationType = installationType;
|
||||
self.relaunchPath = installationData.relaunchPath;
|
||||
self.downloadName = installationData.downloadName;
|
||||
self.signatures = installationData.signatures;
|
||||
self.dsaSignature = installationData.dsaSignature;
|
||||
self.updateDirectoryPath = cacheInstallationPath;
|
||||
self.host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUSignatures;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUInstallationInputData : NSObject <NSSecureCoding>
|
||||
@@ -19,17 +17,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* hostBundlePath - path to host bundle to update & replace
|
||||
* updateDirectoryPath - path to update directory (i.e, temporary directory containing the new update archive)
|
||||
* downloadName - name of update archive in update directory
|
||||
* signatures - signatures for the update that came from the appcast item
|
||||
* dsaSignature - DSA signature for the update that came from the appcast item
|
||||
* decryptionPassword - optional decryption password for dmg archives
|
||||
*/
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relaunchPath;
|
||||
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy, readonly) NSString *downloadName;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (nonatomic, strong, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, copy, readonly) NSString *dsaSignature;
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "SPUInstallationInputData.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ static NSString *SURelaunchPathKey = @"SURelaunchPath";
|
||||
static NSString *SUHostBundlePathKey = @"SUHostBundlePath";
|
||||
static NSString *SUUpdateDirectoryPathKey = @"SUUpdateDirectoryPath";
|
||||
static NSString *SUDownloadNameKey = @"SUDownloadName";
|
||||
static NSString *SUSignaturesKey = @"SUSignatures";
|
||||
static NSString *SUDSASignatureKey = @"SUDSASignature";
|
||||
static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
|
||||
@@ -26,11 +26,11 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
@synthesize hostBundlePath = _hostBundlePath;
|
||||
@synthesize updateDirectoryPath = _updateDirectoryPath;
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize installationType = _installationType;
|
||||
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -42,7 +42,7 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
_installationType = [installationType copy];
|
||||
assert(SPUValidInstallationType(_installationType));
|
||||
|
||||
_signatures = signatures;
|
||||
_dsaSignature = [dsaSignature copy];
|
||||
_decryptionPassword = [decryptionPassword copy];
|
||||
}
|
||||
return self;
|
||||
@@ -75,14 +75,14 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
return nil;
|
||||
}
|
||||
|
||||
SUSignatures *signatures = [decoder decodeObjectOfClass:[SUSignatures class] forKey:SUSignaturesKey];
|
||||
if (signatures == nil) {
|
||||
NSString *dsaSignature = [decoder decodeObjectOfClass:[NSString class] forKey:SUDSASignatureKey];
|
||||
if (dsaSignature == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
|
||||
|
||||
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName installationType:installationType signatures:signatures decryptionPassword:decryptionPassword];
|
||||
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName installationType:installationType dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
@@ -92,7 +92,7 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:self.installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:self.signatures forKey:SUSignaturesKey];
|
||||
[coder encodeObject:self.dsaSignature forKey:SUDSASignatureKey];
|
||||
if (self.decryptionPassword != nil) {
|
||||
[coder encodeObject:self.decryptionPassword forKey:SUDecryptionPasswordKey];
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// SUDSAVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -12,46 +12,48 @@
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUSignatureVerifier ()
|
||||
@property (readonly) SUPublicKeys *pubKeys;
|
||||
@end
|
||||
|
||||
@implementation SUSignatureVerifier {
|
||||
@implementation SUDSAVerifier {
|
||||
SecKeyRef _secKey;
|
||||
}
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
if (!encodedSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature to check");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUDSAVerifier *verifier = [(SUDSAVerifier *)[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [verifier verifyFileAtPath:path signatures:signatures];
|
||||
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
NSData *signature =
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9
|
||||
[[NSData alloc] initWithBase64Encoding:strippedSignature];
|
||||
#else
|
||||
[[NSData alloc] initWithBase64EncodedString:strippedSignature options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
#endif
|
||||
return [verifier verifyFileAtPath:path signature:signature];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
_pubKeys = pubkeys;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SecKeyRef)dsaSecKeyRef {
|
||||
|
||||
NSData *data = [self.pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
@@ -70,85 +72,40 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = nil;
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
|
||||
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
|
||||
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
dsaPubKeySecKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
return dsaPubKeySecKey;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures
|
||||
- (void)dealloc
|
||||
{
|
||||
if (!path || !path.length) {
|
||||
return NO;
|
||||
if (_secKey) {
|
||||
CFRelease(_secKey);
|
||||
}
|
||||
|
||||
if (!signatures) {
|
||||
SULog(SULogLevelDefault, @"No signatures given to verifyFileAtPath");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSData *dsaSignature = signatures.dsaSignature;
|
||||
NSString *dsaPubKey = self.pubKeys.dsaPubKey;
|
||||
|
||||
const unsigned char *edSignature = signatures.ed25519Signature;
|
||||
const unsigned char *edPubKey = self.pubKeys.ed25519PubKey;
|
||||
|
||||
if (edPubKey && !edSignature) {
|
||||
SULog(SULogLevelDefault, @"There is no EdDSA signature in the update, but the app is capable of verifying them");
|
||||
} if (!edPubKey && edSignature) {
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it won't be used, because the old app doesn't have an EdDSA public key");
|
||||
} else if (edPubKey && edSignature) {
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&error];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, error);
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(edSignature, data.bytes, data.length, edPubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
|
||||
if (!dsaPubKey) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(SULogLevelDefault, @"This app has a DSA public key, so a DSA signature is required too");
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (dsaSignature) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dsaSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
} else if (!dsaPubKey) {
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
|
||||
} else {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:dsaSignature];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
if (!path.length) {
|
||||
return NO;
|
||||
}
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyStream:dataInputStream signature:signature];
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
|
||||
if (!dsaPubKeySecKey) {
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !signature) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -164,7 +121,6 @@
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
if (dsaPubKeySecKey) CFRelease(dsaPubKeySecKey);
|
||||
return NO;
|
||||
};
|
||||
|
||||
@@ -181,10 +137,10 @@
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// SUSignatureVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class SUSignatures;
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction;
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated;
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>:
|
||||
sais.c and sais.c, from sais-lite (2010/08/07) <https://sites.google.com/site/yuta256/sais>:
|
||||
Copyright (c) 2008-2010 Yuta Mori.
|
||||
|
||||
SUSignatureVerifier.m:
|
||||
SUDSAVerifier.m:
|
||||
Copyright (c) 2011 Mark Hamlin.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
14652F8019A9740F00959E44 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
|
||||
14652F8219A9746000959E44 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
|
||||
14652F8419A978C200959E44 /* SUExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 14652F8319A9759F00959E44 /* SUExport.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */; };
|
||||
14732BD019610A0D00593899 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
14732BD119610A1200593899 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
14732BD319610A1800593899 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14732BD219610A1800593899 /* XCTest.framework */; };
|
||||
@@ -49,19 +50,13 @@
|
||||
55C14F06136EF6DB00649790 /* SULog.h in Headers */ = {isa = PBXBuildFile; fileRef = 55C14F04136EF6DB00649790 /* SULog.h */; };
|
||||
55C14F07136EF6DB00649790 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
|
||||
55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 55E6F33219EC9F6C00005E76 /* SUErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
5A06357023FE332300478A72 /* libed25519.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA1E282D22B660BE004AA304 /* libed25519.a */; };
|
||||
5A06357323FE333600478A72 /* libed25519.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA1E282D22B660BE004AA304 /* libed25519.a */; };
|
||||
5A06357423FE33A400478A72 /* libed25519.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA1E282D22B660BE004AA304 /* libed25519.a */; };
|
||||
5A4094481C74EA5200983BE0 /* SUAppcastTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */; };
|
||||
5A6DD17123FE1FFC000AEF33 /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = EA1E286D22B665E8004AA304 /* SUSignatures.m */; };
|
||||
5AA89BA523FE27660094DAB8 /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = EA1E286D22B665E8004AA304 /* SUSignatures.m */; };
|
||||
5AA89BA623FE276A0094DAB8 /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = EA1E286D22B665E8004AA304 /* SUSignatures.m */; };
|
||||
5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */; };
|
||||
5AE459001C34118500E3BB47 /* SUUpdaterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */; };
|
||||
5AE459021C34118500E3BB47 /* SUVersionComparisonTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */; };
|
||||
5AF6C74F1AEA46D10014A3AB /* test.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.pkg */; };
|
||||
5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; };
|
||||
5AF9DC3C1981DBEE001EA135 /* SUSignatureVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUSignatureVerifierTest.m */; };
|
||||
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; };
|
||||
5D06E8FF0FD68D6D005AE3F6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
|
||||
5D06E9050FD68D7D005AE3F6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
5D1AF58B0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
|
||||
@@ -209,7 +204,7 @@
|
||||
7267E5871D3D89B300D1BF90 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5831D3D89B300D1BF90 /* SUPipedUnarchiver.m */; };
|
||||
7267E5881D3D89B300D1BF90 /* SUUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5851D3D89B300D1BF90 /* SUUnarchiver.m */; };
|
||||
7267E59C1D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; };
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUSignatureVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59B1D3D8A5A00D1BF90 /* SUSignatureVerifier.m */; };
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59B1D3D8A5A00D1BF90 /* SUDSAVerifier.m */; };
|
||||
7267E59F1D3D8A6F00D1BF90 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59E1D3D8A6F00D1BF90 /* main.m */; };
|
||||
7267E5A21D3D8A7E00D1BF90 /* AppInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A11D3D8A7E00D1BF90 /* AppInstaller.m */; };
|
||||
7267E5A81D3D8A9900D1BF90 /* AgentConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A71D3D8A9900D1BF90 /* AgentConnection.m */; };
|
||||
@@ -251,7 +246,7 @@
|
||||
7267E5EF1D3D915900D1BF90 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5711D3D895B00D1BF90 /* SUBinaryDeltaCommon.m */; };
|
||||
7267E5F01D3D915900D1BF90 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5731D3D895B00D1BF90 /* SUBinaryDeltaCreate.m */; };
|
||||
7267E5F11D3D917A00D1BF90 /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E57E1D3D896700D1BF90 /* SUBinaryDeltaUnarchiver.m */; };
|
||||
7267E5F21D3D918000D1BF90 /* SUSignatureVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59B1D3D8A5A00D1BF90 /* SUSignatureVerifier.m */; };
|
||||
7267E5F21D3D918000D1BF90 /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59B1D3D8A5A00D1BF90 /* SUDSAVerifier.m */; };
|
||||
7267E5F31D3D918500D1BF90 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; };
|
||||
7267E5F41D3D918B00D1BF90 /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5BB1D3D8B2700D1BF90 /* SUGuidedPackageInstaller.m */; };
|
||||
7267E5F51D3D918B00D1BF90 /* SUPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5BF1D3D8B2700D1BF90 /* SUPackageInstaller.m */; };
|
||||
@@ -404,6 +399,7 @@
|
||||
72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */; };
|
||||
72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */; };
|
||||
72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFB1B641961005C701A /* sparkletestcast.xml */; };
|
||||
72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */; };
|
||||
72E45DDD1B65C3BD005C701A /* sign_update in Resources */ = {isa = PBXBuildFile; fileRef = 72E45DDC1B65C3BD005C701A /* sign_update */; };
|
||||
72E539121D68C3FA0092CE5E /* SPUDownloadData.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */; };
|
||||
72EB87EA1CB8798800C37F42 /* ShowInstallerProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */; };
|
||||
@@ -543,13 +539,6 @@
|
||||
remoteGlobalIDString = EA1E280E22B64522004AA304;
|
||||
remoteInfo = bsdiff;
|
||||
};
|
||||
5A06357123FE332300478A72 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = EA1E282C22B660BE004AA304;
|
||||
remoteInfo = ed25519;
|
||||
};
|
||||
61B5F91B09C4CF7200B25A18 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
@@ -863,6 +852,7 @@
|
||||
14732BB91960EEEE00593899 /* SampleAppcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SampleAppcast.xml; sourceTree = "<group>"; };
|
||||
14732BBA1960EF7100593899 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = SOURCE_ROOT; };
|
||||
14732BBC1960EFB500593899 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = SOURCE_ROOT; };
|
||||
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = test_app_only_dsa_pub.pem; sourceTree = "<group>"; };
|
||||
14732BC11960F3B200593899 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = SOURCE_ROOT; usesTabs = 1; };
|
||||
14732BC31960F3FF00593899 /* generate_keys */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_keys; sourceTree = "<group>"; };
|
||||
14732BC41960F3FF00593899 /* sign_update */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update; sourceTree = "<group>"; };
|
||||
@@ -966,7 +956,7 @@
|
||||
5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = "<group>"; };
|
||||
5AF6C74E1AEA46D10014A3AB /* test.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.pkg; sourceTree = "<group>"; };
|
||||
5AF9DC3B1981DBEE001EA135 /* SUSignatureVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUSignatureVerifierTest.m; sourceTree = "<group>"; };
|
||||
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifierTest.m; sourceTree = "<group>"; };
|
||||
5D06E8D00FD68C7C005AE3F6 /* BinaryDelta */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = BinaryDelta; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */ = {isa = PBXFileReference; comments = "-Wno-shorten-64-to-32"; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bsdiff.c; sourceTree = "<group>"; };
|
||||
5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bspatch.c; sourceTree = "<group>"; };
|
||||
@@ -1158,8 +1148,8 @@
|
||||
7267E5891D3D89CA00D1BF90 /* SUUnarchiverProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUUnarchiverProtocol.h; path = Autoupdate/SUUnarchiverProtocol.h; sourceTree = SOURCE_ROOT; };
|
||||
7267E5981D3D8A5A00D1BF90 /* SUCodeSigningVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUCodeSigningVerifier.h; path = Autoupdate/SUCodeSigningVerifier.h; sourceTree = SOURCE_ROOT; };
|
||||
7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUCodeSigningVerifier.m; path = Autoupdate/SUCodeSigningVerifier.m; sourceTree = SOURCE_ROOT; };
|
||||
7267E59A1D3D8A5A00D1BF90 /* SUSignatureVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUSignatureVerifier.h; path = Autoupdate/SUSignatureVerifier.h; sourceTree = SOURCE_ROOT; };
|
||||
7267E59B1D3D8A5A00D1BF90 /* SUSignatureVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUSignatureVerifier.m; path = Autoupdate/SUSignatureVerifier.m; sourceTree = SOURCE_ROOT; };
|
||||
7267E59A1D3D8A5A00D1BF90 /* SUDSAVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUDSAVerifier.h; path = Autoupdate/SUDSAVerifier.h; sourceTree = SOURCE_ROOT; };
|
||||
7267E59B1D3D8A5A00D1BF90 /* SUDSAVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUDSAVerifier.m; path = Autoupdate/SUDSAVerifier.m; sourceTree = SOURCE_ROOT; };
|
||||
7267E59E1D3D8A6F00D1BF90 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Autoupdate/main.m; sourceTree = SOURCE_ROOT; };
|
||||
7267E5A01D3D8A7E00D1BF90 /* AppInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppInstaller.h; path = Autoupdate/AppInstaller.h; sourceTree = SOURCE_ROOT; };
|
||||
7267E5A11D3D8A7E00D1BF90 /* AppInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppInstaller.m; path = Autoupdate/AppInstaller.m; sourceTree = SOURCE_ROOT; };
|
||||
@@ -1287,6 +1277,7 @@
|
||||
72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateSettingsWindowController.m; sourceTree = "<group>"; };
|
||||
72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SUUpdateSettingsWindowController.xib; sourceTree = "<group>"; };
|
||||
72E45CFB1B641961005C701A /* sparkletestcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = sparkletestcast.xml; sourceTree = "<group>"; };
|
||||
72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test_app_only_dsa_priv_dont_ever_do_this_for_real.pem; sourceTree = "<group>"; };
|
||||
72E45DDC1B65C3BD005C701A /* sign_update */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = sign_update; path = bin/sign_update; sourceTree = SOURCE_ROOT; };
|
||||
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ShowInstallerProgress.m; path = Sparkle/InstallerProgress/ShowInstallerProgress.m; sourceTree = SOURCE_ROOT; };
|
||||
72F94ED51CC3441A002DEE68 /* ConfigInstallerLauncherDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigInstallerLauncherDebug.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -1377,7 +1368,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5A06357323FE333600478A72 /* libed25519.a in Frameworks */,
|
||||
EA1E281822B645CE004AA304 /* libbsdiff.a in Frameworks */,
|
||||
14732BD119610A1200593899 /* AppKit.framework in Frameworks */,
|
||||
14732BD019610A0D00593899 /* Foundation.framework in Frameworks */,
|
||||
@@ -1393,7 +1383,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5A06357423FE33A400478A72 /* libed25519.a in Frameworks */,
|
||||
14950073195FCE4E00BC5B5B /* AppKit.framework in Frameworks */,
|
||||
14950072195FCE4B00BC5B5B /* Foundation.framework in Frameworks */,
|
||||
61B5F90F09C4CF3A00B25A18 /* Sparkle.framework in Frameworks */,
|
||||
@@ -1478,7 +1467,6 @@
|
||||
EA1E281722B645AE004AA304 /* libbsdiff.a in Frameworks */,
|
||||
7267E5C91D3D8C4300D1BF90 /* CoreServices.framework in Frameworks */,
|
||||
7267E5CA1D3D8C4800D1BF90 /* Foundation.framework in Frameworks */,
|
||||
5A06357023FE332300478A72 /* libed25519.a in Frameworks */,
|
||||
7267E5D61D3D8D3500D1BF90 /* libbz2.tbd in Frameworks */,
|
||||
7267E5D51D3D8D2800D1BF90 /* libxar.tbd in Frameworks */,
|
||||
721D8A611D48413B0032E472 /* Security.framework in Frameworks */,
|
||||
@@ -1571,10 +1559,8 @@
|
||||
0867D69AFE84028FC02AAC07 /* Frameworks */,
|
||||
034768DFFF38A50411DB9C8B /* Products */,
|
||||
);
|
||||
indentWidth = 4;
|
||||
name = Sparkle;
|
||||
sourceTree = "<group>";
|
||||
tabWidth = 4;
|
||||
usesTabs = 0;
|
||||
};
|
||||
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
|
||||
@@ -1777,7 +1763,7 @@
|
||||
5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */,
|
||||
142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */,
|
||||
F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */,
|
||||
5AF9DC3B1981DBEE001EA135 /* SUSignatureVerifierTest.m */,
|
||||
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */,
|
||||
72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */,
|
||||
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */,
|
||||
72BEBFEE1D7287560019146B /* SUSpotlightImporterTest.swift */,
|
||||
@@ -1899,6 +1885,8 @@
|
||||
72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */,
|
||||
72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */,
|
||||
72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */,
|
||||
72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */,
|
||||
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */,
|
||||
61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */,
|
||||
);
|
||||
name = "Test Application";
|
||||
@@ -1910,8 +1898,8 @@
|
||||
children = (
|
||||
7267E5981D3D8A5A00D1BF90 /* SUCodeSigningVerifier.h */,
|
||||
7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */,
|
||||
7267E59A1D3D8A5A00D1BF90 /* SUSignatureVerifier.h */,
|
||||
7267E59B1D3D8A5A00D1BF90 /* SUSignatureVerifier.m */,
|
||||
7267E59A1D3D8A5A00D1BF90 /* SUDSAVerifier.h */,
|
||||
7267E59B1D3D8A5A00D1BF90 /* SUDSAVerifier.m */,
|
||||
);
|
||||
name = Verifiers;
|
||||
path = ..;
|
||||
@@ -2679,7 +2667,6 @@
|
||||
);
|
||||
dependencies = (
|
||||
37DC0CE62340667000501A67 /* PBXTargetDependency */,
|
||||
5A06357223FE332300478A72 /* PBXTargetDependency */,
|
||||
);
|
||||
name = Autoupdate;
|
||||
productName = Autoupdate;
|
||||
@@ -2988,6 +2975,8 @@
|
||||
72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */,
|
||||
725F97A61C8B304D00265BE4 /* SUInstallUpdateViewController.xib in Resources */,
|
||||
72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */,
|
||||
72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */,
|
||||
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -3269,8 +3258,8 @@
|
||||
7267E5F31D3D918500D1BF90 /* SUCodeSigningVerifier.m in Sources */,
|
||||
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */,
|
||||
7267E5F61D3D919000D1BF90 /* SUDiskImageUnarchiver.m in Sources */,
|
||||
7267E5F21D3D918000D1BF90 /* SUSignatureVerifier.m in Sources */,
|
||||
5AF9DC3C1981DBEE001EA135 /* SUSignatureVerifierTest.m in Sources */,
|
||||
7267E5F21D3D918000D1BF90 /* SUDSAVerifier.m in Sources */,
|
||||
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */,
|
||||
7267E5E91D3D90AA00D1BF90 /* SUFileManager.m in Sources */,
|
||||
72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */,
|
||||
7267E5F41D3D918B00D1BF90 /* SUGuidedPackageInstaller.m in Sources */,
|
||||
@@ -3339,7 +3328,6 @@
|
||||
7267E5DC1D3D8F1E00D1BF90 /* SPUMessageTypes.m in Sources */,
|
||||
723C8A561E2D60DB00C14942 /* SUTouchBarButtonGroup.m in Sources */,
|
||||
721652621D3C44A100FD13D8 /* SPUSystemAuthorization.m in Sources */,
|
||||
5AA89BA623FE276A0094DAB8 /* SUSignatures.m in Sources */,
|
||||
7267E5FA1D3DAC3600D1BF90 /* StatusInfo.m in Sources */,
|
||||
720595EF1D700568000572E8 /* SUApplicationInfo.m in Sources */,
|
||||
7214B8831D456C2400CB5CED /* SUBundleIcon.m in Sources */,
|
||||
@@ -3392,7 +3380,6 @@
|
||||
721D8A7B1D4963190032E472 /* SPULocalCacheDirectory.m in Sources */,
|
||||
7267E5E11D3D901600D1BF90 /* SPUMessageTypes.m in Sources */,
|
||||
724BB3AF1D34828A005D534A /* SPUSystemAuthorization.m in Sources */,
|
||||
5AA89BA523FE27660094DAB8 /* SUSignatures.m in Sources */,
|
||||
7214B8841D456C9500CB5CED /* SUBundleIcon.m in Sources */,
|
||||
726E07BF1CAF0C6C001A286B /* SUConstants.m in Sources */,
|
||||
7267E5E81D3D90AA00D1BF90 /* SUFileManager.m in Sources */,
|
||||
@@ -3502,12 +3489,11 @@
|
||||
7267E59C1D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m in Sources */,
|
||||
7267E5CC1D3D8C6B00D1BF90 /* SUConstants.m in Sources */,
|
||||
7267E5861D3D89B300D1BF90 /* SUDiskImageUnarchiver.m in Sources */,
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUSignatureVerifier.m in Sources */,
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUDSAVerifier.m in Sources */,
|
||||
7267E5E71D3D90AA00D1BF90 /* SUFileManager.m in Sources */,
|
||||
7267E5C21D3D8B2700D1BF90 /* SUGuidedPackageInstaller.m in Sources */,
|
||||
7267E5D71D3D8D3F00D1BF90 /* SUHost.m in Sources */,
|
||||
7267E5C31D3D8B2700D1BF90 /* SUInstaller.m in Sources */,
|
||||
5A6DD17123FE1FFC000AEF33 /* SUSignatures.m in Sources */,
|
||||
7267E5CE1D3D8C7500D1BF90 /* SULog.m in Sources */,
|
||||
7267E5C41D3D8B2700D1BF90 /* SUPackageInstaller.m in Sources */,
|
||||
7267E5871D3D89B300D1BF90 /* SUPipedUnarchiver.m in Sources */,
|
||||
@@ -3695,11 +3681,6 @@
|
||||
target = EA1E280E22B64522004AA304 /* bsdiff */;
|
||||
targetProxy = 37DC0CE52340667000501A67 /* PBXContainerItemProxy */;
|
||||
};
|
||||
5A06357223FE332300478A72 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = EA1E282C22B660BE004AA304 /* ed25519 */;
|
||||
targetProxy = 5A06357123FE332300478A72 /* PBXContainerItemProxy */;
|
||||
};
|
||||
61B5F91C09C4CF7200B25A18 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 8DC2EF4F0486A6940098B216 /* Sparkle */;
|
||||
|
||||
Vendored
+4
-2
@@ -65,16 +65,18 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)__unused completionBlock
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)__unused completionBlock __attribute__((noreturn))
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeInstallingUpdateWithCompletion: called on SPUAutomaticUpdateDriver");
|
||||
abort();
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)__unused resumableUpdate completion:(SPUUpdateDriverCompletion)__unused completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)__unused resumableUpdate completion:(SPUUpdateDriverCompletion)__unused completionBlock __attribute__((noreturn))
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeDownloadedUpdate:completion: called on SPUAutomaticUpdateDriver");
|
||||
abort();
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem
|
||||
|
||||
Vendored
-2
@@ -69,8 +69,6 @@
|
||||
if ([self.host isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self.delegate basicDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.", nil), [self.host name]] }]];
|
||||
} else if ([self.host isRunningTranslocated]) {
|
||||
[self.delegate basicDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningTranslocated userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can’t be updated if it’s running from the location it was downloaded to.", nil), [self.host name]] }]];
|
||||
} else {
|
||||
[self.appcastDriver loadAppcastFromURL:appcastURL userAgent:userAgent httpHeaders:httpHeaders inBackground:background includesSkippedUpdates:includesSkippedUpdates];
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+4
-2
@@ -171,13 +171,15 @@
|
||||
pathToRelaunch = relaunchPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSString *dsaSignature = (self.updateItem.DSASignature == nil) ? @"" : self.updateItem.DSASignature;
|
||||
|
||||
NSString *decryptionPassword = nil;
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(decryptionPasswordForUpdater:)]) {
|
||||
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
|
||||
}
|
||||
|
||||
SPUInstallationInputData *installationData = [[SPUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName installationType:self.updateItem.installationType signatures:self.updateItem.signatures decryptionPassword:decryptionPassword];
|
||||
SPUInstallationInputData *installationData = [[SPUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName installationType:self.updateItem.installationType dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
|
||||
NSData *archivedData = SPUArchiveRootObjectSecurely(installationData);
|
||||
if (archivedData == nil) {
|
||||
|
||||
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+1
-9
@@ -73,15 +73,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
SULog(SULogLevelError, @"Fatal updater error (%ld): %@", updaterError.code, updaterError.localizedDescription);
|
||||
|
||||
// Delay the alert four seconds so it doesn't show RIGHT as the app launches, but also doesn't interrupt the user once they really get to work.
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"Unable to Check For Updates";
|
||||
alert.informativeText = @"The update checker failed to start correctly. You should contact the app developer to report this issue and verify that you have the latest version.";
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert runModal];
|
||||
});
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUUserDriver.h>
|
||||
#import <Sparkle/SPUStandardUserDriverProtocol.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionDisplay;
|
||||
|
||||
Vendored
+4
@@ -9,7 +9,11 @@
|
||||
#ifndef SPUStatusCompletionResults_h
|
||||
#define SPUStatusCompletionResults_h
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) {
|
||||
SPUUserInitiatedCheckDone,
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+7
-3
@@ -6,7 +6,11 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SPUUserDriver.h>
|
||||
|
||||
@@ -130,9 +134,9 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
If the updater's delegate implements -[SPUUpdaterDelegate feedURLStringForUpdater:], this will return that feed URL.
|
||||
Otherwise if the feed URL has been set before, the feed URL returned will be retrieved from the host bundle's user defaults.
|
||||
Otherwise the feed URL in the host bundle's Info.plist will be returned.
|
||||
If no feed URL can be retrieved, returns nil.
|
||||
If no feed URL can be retrieved, this will raise an exception.
|
||||
|
||||
This property must be called on the main thread; calls from background threads will return nil.
|
||||
This property must be called on the main thread.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSURL *feedURL;
|
||||
|
||||
@@ -145,7 +149,7 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
Passing nil will remove any feed URL that has been set in the host bundle's user defaults.
|
||||
|
||||
This method must be called on the main thread; calls from background threads will have no effect.
|
||||
This method must be called on the main thread.
|
||||
*/
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL;
|
||||
|
||||
|
||||
Vendored
+17
-29
@@ -29,7 +29,6 @@
|
||||
#import "SPUUpdaterCycle.h"
|
||||
#import "SPUUpdaterTimer.h"
|
||||
#import "SPUResumableUpdate.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -116,24 +115,16 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
// To prevent subclasses from doing something bad based on older Sparkle code
|
||||
- (instancetype)initForBundle:(NSBundle *)__unused bundle
|
||||
{
|
||||
NSString *reason = [NSString stringWithFormat:@"-[%@ initForBundle:] is not implemented anymore in Sparkle 2.", NSStringFromClass([self class])];
|
||||
SULog(SULogLevelError, @"%@", reason);
|
||||
|
||||
NSException *exception = [NSException exceptionWithName:@"SUIncorrectAPIUsageException" reason:reason userInfo:nil];
|
||||
@throw exception;
|
||||
|
||||
SULog(SULogLevelError, @"-[%@ initForBundle:] is not implemented anymore.", NSStringFromClass([self class]));
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
// To prevent trying to stick an SUUpdater in a nib or initializing it in an incorrect way
|
||||
- (instancetype)init
|
||||
{
|
||||
NSString *reason = [NSString stringWithFormat:@"-[%@ init] is not implemented. If you want to drop an updater into a nib, see SPUStandardUpdaterController.", NSStringFromClass([self class])];
|
||||
SULog(SULogLevelError, @"%@", reason);
|
||||
|
||||
NSException *exception = [NSException exceptionWithName:@"SUIncorrectAPIUsageException" reason:reason userInfo:nil];
|
||||
@throw exception;
|
||||
|
||||
SULog(SULogLevelError, @"-[%@ init] is not implemented. If you want to drop an updater into a nib, see SPUStandardUpdaterController.", NSStringFromClass([self class]));
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -217,8 +208,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hasPublicKey = self.host.publicKeys.dsaPubKey != nil || self.host.publicKeys.ed25519PubKey != nil;
|
||||
if (!hasPublicKey) {
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
if (!hasPublicDSAKey) {
|
||||
// If we failed to retrieve a DSA key but the bundle specifies a path to one, we should consider this a configuration failure
|
||||
NSString *publicDSAKeyFileKey = [self.host publicDSAKeyFileKey];
|
||||
if (publicDSAKeyFileKey != nil) {
|
||||
@@ -228,11 +219,11 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPublicKey) {
|
||||
|
||||
if (!hasPublicDSAKey) {
|
||||
if (!servingOverHttps || ![SUCodeSigningVerifier bundleAtURLIsCodeSigned:[[self hostBundle] bundleURL]]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, updates need to be signed with an EdDSA key. See Sparkle's documentation for more information." }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, updates need to be signed with a DSA key. See Sparkle's documentation for more information." }];
|
||||
}
|
||||
return NO;
|
||||
} else {
|
||||
@@ -240,7 +231,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
// Deprecated because we pass the downloaded archive to the installer and the installer has no way of knowing where the download came from.
|
||||
// Even if it did, the server and the download on it could still be compromised. But if a DSA signature was used, the private key should
|
||||
// not be stored on the server serving the update
|
||||
SULog(SULogLevelDefault, @"DEPRECATION: Serving updates without an EdDSA key is now deprecated and may be removed from a future release. See Sparkle's documentation for more information.");
|
||||
SULog(SULogLevelDefault, @"DEPRECATION: Serving updates without a DSA key is now deprecated and may be removed from a future release. See Sparkle's documentation for more information.");
|
||||
|
||||
self.loggedDSAWarning = YES;
|
||||
}
|
||||
@@ -623,8 +614,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(SULogLevelError, @"Error: SPUUpdater -setFeedURL: must be called on the main thread. The call from a background thread was ignored.");
|
||||
return;
|
||||
SULog(SULogLevelError, @"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
// When feedURL is nil, -absoluteString will return nil and will remove the user default key
|
||||
@@ -634,11 +625,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
- (BOOL)retrieveFeedURL:(NSURL * __autoreleasing *)feedURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(SULogLevelError, @"Error: SPUUpdater -retrieveFeedURL:error: must be called on the main thread.");
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUIncorrectAPIUsageError userInfo:@{ NSLocalizedDescriptionKey: @"SUUpdater -retriveFeedURL:error: must be called on the main thread."}];
|
||||
}
|
||||
return NO;
|
||||
SULog(SULogLevelError, @"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
|
||||
@@ -669,14 +657,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return YES;
|
||||
}
|
||||
|
||||
// A client may call this method but do not invoke this method ourselves because it's unsafe
|
||||
// A client may call this method but do not invoke this method ourselves because its unsafe
|
||||
- (NSURL *)feedURL
|
||||
{
|
||||
NSURL *feedURL = nil;
|
||||
NSError *feedError = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:&feedError]) {
|
||||
SULog(SULogLevelError, @"Feed Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
return nil;
|
||||
SULog(SULogLevelError, @"Fatal Feed Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
abort();
|
||||
}
|
||||
return feedURL;
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionComparison;
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUStatusCompletionResults.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUStatusCompletionResults.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
|
||||
Vendored
+4
@@ -9,7 +9,11 @@
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+9
-19
@@ -105,14 +105,9 @@
|
||||
} else {
|
||||
SULog(SULogLevelError, @"Encountered download feed error: %@", error);
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary
|
||||
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
|
||||
forKey: NSLocalizedDescriptionKey];
|
||||
|
||||
if (error != nil) {
|
||||
NSError *assignedError = error; // Silences a Clang warning about implicit conversion from Nullable to Nonnull.
|
||||
[userInfo setObject:assignedError forKey:NSUnderlyingErrorKey];
|
||||
}
|
||||
NSDictionary *userInfo = [NSDictionary
|
||||
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
|
||||
forKey: NSLocalizedDescriptionKey];
|
||||
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUDownloadError
|
||||
@@ -263,17 +258,12 @@
|
||||
|
||||
- (void)reportError:(NSError *)error
|
||||
{
|
||||
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||
|
||||
if (!userInfo)
|
||||
{
|
||||
userInfo = [[NSMutableDictionary alloc] initWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||
NSUnderlyingErrorKey: error,
|
||||
}];
|
||||
}
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||
NSUnderlyingErrorKey: error,
|
||||
}];
|
||||
|
||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
|
||||
Vendored
+5
-2
@@ -9,16 +9,19 @@
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
@class SUSignatures;
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly) SUSignatures *signatures;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
|
||||
Vendored
+6
-7
@@ -10,7 +10,6 @@
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import "SULog.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SPUInstallationType.h"
|
||||
|
||||
|
||||
@@ -18,7 +17,7 @@
|
||||
|
||||
static NSString *SUAppcastItemDeltaUpdatesKey = @"deltaUpdates";
|
||||
static NSString *SUAppcastItemDisplayVersionStringKey = @"displayVersionString";
|
||||
static NSString *SUAppcastItemSignaturesKey = @"signatures";
|
||||
static NSString *SUAppcastItemDSASignatureKey = @"DSASignature";
|
||||
static NSString *SUAppcastItemFileURLKey = @"fileURL";
|
||||
static NSString *SUAppcastItemInfoURLKey = @"infoURL";
|
||||
static NSString *SUAppcastItemContentLengthKey = @"contentLength";
|
||||
@@ -36,7 +35,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
@synthesize dateString = _dateString;
|
||||
@synthesize deltaUpdates = _deltaUpdates;
|
||||
@synthesize displayVersionString = _displayVersionString;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize DSASignature = _DSASignature;
|
||||
@synthesize fileURL = _fileURL;
|
||||
@synthesize contentLength = _contentLength;
|
||||
@synthesize infoURL = _infoURL;
|
||||
@@ -62,7 +61,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
if (self != nil) {
|
||||
_deltaUpdates = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [SUAppcastItem class]]] forKey:SUAppcastItemDeltaUpdatesKey];
|
||||
_displayVersionString = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemDisplayVersionStringKey] copy];
|
||||
_signatures = (SUSignatures *)[decoder decodeObjectOfClass:[SUSignatures class] forKey:SUAppcastItemSignaturesKey];
|
||||
_DSASignature = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemDSASignatureKey] copy];
|
||||
_fileURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemFileURLKey];
|
||||
_infoURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemInfoURLKey];
|
||||
|
||||
@@ -95,8 +94,8 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
[encoder encodeObject:self.displayVersionString forKey:SUAppcastItemDisplayVersionStringKey];
|
||||
}
|
||||
|
||||
if (self.signatures != nil) {
|
||||
[encoder encodeObject:self.signatures forKey:SUAppcastItemSignaturesKey];
|
||||
if (self.DSASignature != nil) {
|
||||
[encoder encodeObject:self.DSASignature forKey:SUAppcastItemDSASignatureKey];
|
||||
}
|
||||
|
||||
if (self.fileURL != nil) {
|
||||
@@ -251,7 +250,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
_fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
_signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:[enclosure objectForKey:SUAppcastAttributeEDSignature]];
|
||||
_DSASignature = [(NSString *)[enclosure objectForKey:SUAppcastAttributeDSASignature] copy];
|
||||
}
|
||||
|
||||
_versionString = [(NSString *)newVersion copy];
|
||||
|
||||
Vendored
+5
-5
@@ -9,7 +9,11 @@
|
||||
#ifndef SUERRORS_H
|
||||
#define SUERRORS_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/**
|
||||
@@ -33,7 +37,6 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
SUResumeAppcastError = 1004,
|
||||
SURunningTranslocated = 1005,
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
@@ -53,10 +56,7 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCanceledError = 4007,
|
||||
SUInstallationAuthorizeLaterError = 4008,
|
||||
SUNotAllowedInteractionError = 4009,
|
||||
|
||||
// API misuse errors.
|
||||
SUIncorrectAPIUsageError = 5000
|
||||
SUNotAllowedInteractionError = 4009
|
||||
};
|
||||
|
||||
#endif
|
||||
Vendored
+1
-5
@@ -7,8 +7,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUHost : NSObject
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
@@ -20,10 +18,8 @@
|
||||
@property (readonly, copy) NSString *version;
|
||||
@property (readonly, nonatomic) BOOL validVersion;
|
||||
@property (readonly, copy) NSString *displayVersion;
|
||||
@property (readonly) SUPublicKeys *publicKeys;
|
||||
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (getter=isRunningTranslocated, readonly) BOOL runningTranslocated;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
|
||||
Vendored
+2
-21
@@ -10,7 +10,6 @@
|
||||
#import "SUConstants.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -27,7 +26,6 @@
|
||||
@property (nonatomic, readonly) BOOL isMainBundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
|
||||
@end
|
||||
|
||||
@@ -107,8 +105,7 @@
|
||||
NSString *version = [self _version];
|
||||
if (version == nil) {
|
||||
SULog(SULogLevelError, @"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey);
|
||||
// Instead of abort()-ing, return an empty string to satisfy the _Nonnull contract.
|
||||
return @"";
|
||||
abort();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
@@ -129,17 +126,6 @@
|
||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||
}
|
||||
|
||||
- (BOOL)isRunningTranslocated
|
||||
{
|
||||
NSString *path = [self.bundle bundlePath];
|
||||
return [path rangeOfString:@"/AppTranslocation/"].location != NSNotFound;
|
||||
}
|
||||
|
||||
- (NSString *_Nullable)publicEDKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicEDKeyKey];
|
||||
}
|
||||
|
||||
- (NSString *_Nullable)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
@@ -166,14 +152,9 @@
|
||||
return key;
|
||||
}
|
||||
|
||||
- (SUPublicKeys *)publicKeys
|
||||
{
|
||||
return [[SUPublicKeys alloc] initWithDsa:[self publicDSAKey] ed:[self publicEDKey]];
|
||||
}
|
||||
|
||||
- (NSString * _Nullable)publicDSAKeyFileKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];;
|
||||
}
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||
|
||||
Vendored
+3
-2
@@ -9,14 +9,14 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUSignatureVerifier)
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUSignatures : NSObject <NSSecureCoding> {
|
||||
@interface SUSignatures : NSObject {
|
||||
unsigned char ed25519_signature[64];
|
||||
}
|
||||
@property (strong, readonly, nullable) NSData *dsaSignature;
|
||||
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (readonly, nullable, nonatomic) const unsigned char *ed25519PubKey;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed;
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+9
-42
@@ -10,9 +10,6 @@
|
||||
#import <assert.h>
|
||||
#import "SULog.h"
|
||||
|
||||
static NSString *SUDSASignatureKey = @"SUDSASignature";
|
||||
static NSString *SUEDSignatureKey = @"SUEDSignature";
|
||||
|
||||
@implementation SUSignatures
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
|
||||
@@ -54,45 +51,6 @@ static NSData *decode(NSString *str) {
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSData *dsaSignature = [decoder decodeObjectOfClass:[NSData class] forKey:SUDSASignatureKey];
|
||||
if (dsaSignature) {
|
||||
_dsaSignature = dsaSignature;
|
||||
}
|
||||
|
||||
NSData *edSignature = [decoder decodeObjectOfClass:[NSData class] forKey:SUEDSignatureKey];
|
||||
if (edSignature) {
|
||||
if (edSignature.length != sizeof(self->ed25519_signature)) {
|
||||
return nil;
|
||||
}
|
||||
[edSignature getBytes:self->ed25519_signature];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
if (self.dsaSignature) {
|
||||
[coder encodeObject:self.dsaSignature forKey:SUDSASignatureKey];
|
||||
}
|
||||
if (self.ed25519Signature) {
|
||||
// Xcode may enable this in pedantic mode
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
NSData *edSignature = [NSData dataWithBytesNoCopy:&self->ed25519_signature length:sizeof(self->ed25519_signature) freeWhenDone:false];
|
||||
#pragma clang diagnostic pop
|
||||
[coder encodeObject:edSignature forKey:SUEDSignatureKey];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPublicKeys
|
||||
@@ -112,6 +70,15 @@ static NSData *decode(NSString *str) {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key {
|
||||
NSString *thisKey = self.dsaPubKey;
|
||||
NSString *thatKey = key.dsaPubKey;
|
||||
if (thisKey == nil || thatKey == nil) {
|
||||
return NO;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (const unsigned char *)ed25519PubKey {
|
||||
// Xcode may enable this in pedantic mode
|
||||
|
||||
+4
@@ -9,7 +9,11 @@
|
||||
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
|
||||
#define SUSTANDARDVERSIONCOMPARATOR_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
|
||||
Vendored
+5
-4
@@ -9,15 +9,16 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUHost;
|
||||
@class SUSignatures;
|
||||
|
||||
@interface SUUpdateValidator : NSObject
|
||||
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host;
|
||||
// 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;
|
||||
|
||||
// This is "pre" validation, before the archive has been extracted
|
||||
- (BOOL)validateDownloadPath;
|
||||
// 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;
|
||||
|
||||
|
||||
Vendored
+87
-108
@@ -7,20 +7,20 @@
|
||||
//
|
||||
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUUpdateValidator ()
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic) BOOL prevalidatedSignature;
|
||||
@property (strong, nonatomic, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, readonly) BOOL prevalidatedDsaSignature;
|
||||
@property (nonatomic, readonly) NSString *dsaSignature;
|
||||
@property (nonatomic, readonly) NSString *downloadPath;
|
||||
|
||||
@end
|
||||
@@ -28,44 +28,58 @@
|
||||
@implementation SUUpdateValidator
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize prevalidatedSignature = _prevalidatedSignature;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize canValidate = _canValidate;
|
||||
@synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize downloadPath = _downloadPath;
|
||||
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host
|
||||
- (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(SULogLevelError, @"Failed to validate update before unarchiving because no DSA key was found");
|
||||
} else if (dsaSignature == nil) {
|
||||
prevalidatedDsaSignature = NO;
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA signature was found");
|
||||
} else {
|
||||
prevalidatedDsaSignature = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:dsaSignature withPublicDSAKey:host.publicDSAKey];
|
||||
if (!prevalidatedDsaSignature) {
|
||||
SULog(SULogLevelError, @"DSA signature validation before unarchiving failed for update %@", downloadPath);
|
||||
}
|
||||
}
|
||||
|
||||
canValidate = prevalidatedDsaSignature;
|
||||
} else {
|
||||
prevalidatedDsaSignature = NO;
|
||||
canValidate = YES;
|
||||
}
|
||||
|
||||
_canValidate = canValidate;
|
||||
_prevalidatedDsaSignature = prevalidatedDsaSignature;
|
||||
_downloadPath = [downloadPath copy];
|
||||
_signatures = signatures;
|
||||
_dsaSignature = [dsaSignature copy];
|
||||
_host = host;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)validateDownloadPath {
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
SUSignatures *signatures = self.signatures;
|
||||
|
||||
if (publicKeys.dsaPubKey == nil && publicKeys.ed25519PubKey == nil) {
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no (Ed)DSA public key was found in the old app");
|
||||
} else {
|
||||
if ([SUSignatureVerifier validatePath:self.downloadPath withSignatures:signatures withPublicKeys:publicKeys]) {
|
||||
self.prevalidatedSignature = YES;
|
||||
return YES;
|
||||
}
|
||||
SULog(SULogLevelError, @"(Ed)DSA signature validation before unarchiving failed for update %@", self.downloadPath);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory
|
||||
{
|
||||
SUSignatures *signatures = self.signatures;
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
assert(self.canValidate);
|
||||
|
||||
NSString *DSASignature = self.dsaSignature;
|
||||
NSString *downloadPath = self.downloadPath;
|
||||
SUHost *host = self.host;
|
||||
|
||||
BOOL prevalidatedDsaSignature = self.prevalidatedDsaSignature;
|
||||
|
||||
BOOL isPackage = NO;
|
||||
|
||||
// install source could point to a new bundle or a package
|
||||
@@ -77,19 +91,19 @@
|
||||
|
||||
NSURL *installSourceURL = [NSURL fileURLWithPath:installSource];
|
||||
|
||||
if (!self.prevalidatedSignature) {
|
||||
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
|
||||
BOOL validationCheckSuccess = [SUSignatureVerifier validatePath:downloadPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
BOOL validationCheckSuccess = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:DSASignature withPublicDSAKey:host.publicDSAKey];
|
||||
if (!validationCheckSuccess) {
|
||||
SULog(SULogLevelError, @"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.");
|
||||
}
|
||||
return validationCheckSuccess;
|
||||
} else {
|
||||
// For application bundle updates, we check both the DSA and Apple code signing signatures
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL signatures:signatures];
|
||||
return [self validateBundleUpdateForHost:host newBundleURL:installSourceURL archivePath:downloadPath DSASignature:DSASignature];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
// We already prevalidated the package and nothing else needs to be done
|
||||
@@ -102,105 +116,70 @@
|
||||
if ([SUCodeSigningVerifier bundleAtURLIsCodeSigned:installSourceURL] && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:installSourceURL error:&error]) {
|
||||
SULog(SULogLevelError, @"Failed to validate apple code sign signature on bundle after archive validation with error: %@", error);
|
||||
return NO;
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the update is a bundle, then it must meet any one of:
|
||||
*
|
||||
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
|
||||
*
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL signatures:(SUSignatures *)signatures
|
||||
- (BOOL)validateBundleUpdateForHost:(SUHost *)host newBundleURL:(NSURL *)newBundleURL archivePath:(NSString *)archivePath DSASignature:(NSString *)DSASignature
|
||||
{
|
||||
NSBundle *newBundle = [NSBundle bundleWithURL:newBundleURL];
|
||||
if (newBundle == nil) {
|
||||
SULog(SULogLevelError, @"No suitable bundle is found in the update. The update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUPublicKeys *publicKeys = host.publicKeys;
|
||||
|
||||
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
SUPublicKeys *newPublicKeys = newHost.publicKeys;
|
||||
BOOL oldHasLegacyDSAKey = publicKeys.dsaPubKey != nil;
|
||||
BOOL oldHasEdDSAKey = publicKeys.ed25519PubKey != nil;
|
||||
BOOL oldHasAnyDSAKey = oldHasLegacyDSAKey || oldHasEdDSAKey;
|
||||
BOOL newHasLegacyDSAKey = newPublicKeys.dsaPubKey != nil;
|
||||
BOOL newHasEdDSAKey = newPublicKeys.ed25519PubKey != nil;
|
||||
BOOL newHasAnyDSAKey = newHasLegacyDSAKey || newHasEdDSAKey;
|
||||
BOOL migratesDSAKeys = oldHasLegacyDSAKey && !oldHasEdDSAKey && newHasEdDSAKey && !newHasLegacyDSAKey;
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
// This is not essential for security, only a policy
|
||||
if (oldHasAnyDSAKey && !newHasAnyDSAKey) {
|
||||
SULog(SULogLevelError, @"A public (Ed)DSA key was found in the old bundle but no public (Ed)DSA key was found in the new update. Sparkle only supports rotation, but not removal of (Ed)DSA keys. Please add an EdDSA key to the new app.");
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
// Downgrade in DSA security should not be possible
|
||||
if (publicDSAKey != nil && newPublicDSAKey == nil) {
|
||||
SULog(SULogLevelError, @"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Security-critical part starts here
|
||||
BOOL passedDSACheck = NO;
|
||||
BOOL passedCodeSigning = NO;
|
||||
|
||||
if (oldHasAnyDSAKey) {
|
||||
// it's critical to check against the old public key, rather than the new key
|
||||
passedDSACheck = [SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
}
|
||||
|
||||
if (hostIsCodeSigned) {
|
||||
NSError *error = nil;
|
||||
passedCodeSigning = [SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error];
|
||||
}
|
||||
// End of security-critical part
|
||||
|
||||
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
if (!passedDSACheck && newHasAnyDSAKey) {
|
||||
if (![SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:newPublicKeys]) {
|
||||
SULog(SULogLevelError, @"The update has a public (Ed)DSA key, but the public key shipped with the update doesn't match the signature. To prevent future problems, the update will be rejected.");
|
||||
// However if the new and old DSA keys are the same, then this is a security measure.
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:archivePath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
||||
SULog(SULogLevelError, @"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (passedDSACheck && updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive has a valid (Ed)DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Either DSA must be valid, or Apple Code Signing must be valid.
|
||||
// We allow failure of one of them, because this allows key rotation without breaking chain of trust.
|
||||
if (passedDSACheck || passedCodeSigning) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Now this just explains the failure
|
||||
|
||||
NSString *dsaStatus;
|
||||
if (migratesDSAKeys) {
|
||||
dsaStatus = @"migrates to new EdDSA keys without keeping the old DSA key for transition";
|
||||
} else if (newHasAnyDSAKey) {
|
||||
dsaStatus = @"has a new (Ed)DSA key that doesn't match the previous one";
|
||||
} else if (oldHasAnyDSAKey) {
|
||||
dsaStatus = @"removes the (Ed)DSA key";
|
||||
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newBundleURL];
|
||||
|
||||
if (dsaKeysMatch) {
|
||||
NSError *error = nil;
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newBundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
dsaStatus = @"isn't signed with an EdDSA key";
|
||||
NSURL *hostBundleURL = host.bundle.bundleURL;
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:hostBundleURL];
|
||||
|
||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(SULogLevelError, @"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:hostBundleURL matchesSignatureAtBundleURL:newBundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(SULogLevelError, @"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
} else {
|
||||
SULog(SULogLevelError, @"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
}
|
||||
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+4
@@ -9,7 +9,11 @@
|
||||
#ifndef SUUPDATER_H
|
||||
#define SUUPDATER_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import <Sparkle/SUVersionDisplayProtocol.h>
|
||||
|
||||
Vendored
+1
@@ -86,6 +86,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to start updater with error: %@", updaterError);
|
||||
abort();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionComparison, SUVersionDisplay;
|
||||
|
||||
+5
@@ -9,7 +9,12 @@
|
||||
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
|
||||
#define SUVERSIONCOMPARISONPROTOCOL_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+5
@@ -6,7 +6,12 @@
|
||||
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
|
||||
Vendored
-2
@@ -2,8 +2,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "Aplikace %1$@ nemůže být aktualizována, protože je spuštěna z média na které nelze zapisovat. Může to být CD/DVD-ROM, obraz disku nebo jen nemáte právo zápisu na disk. Přesuňte aplikaci %1$@ do vaší složky Aplikace, spusťte ji z tohoto umístěni znovu.";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "Aplikace %1$@ nemůže být aktualizována pokud je spuštěna z umístění, ve kterém je stažena.";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ je nejnovější dostupná verze";
|
||||
|
||||
/* Description text for SUUpdateAlert when the update is downloadable. */
|
||||
|
||||
Vendored
-2
@@ -4,8 +4,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "%1$@ kann nicht aktualisiert werden, da es aus dem Downloads-Order, oder von einer DMG Datei oder Laufwerk ohne Schreibzugriff gestartet wurde. Kopiere %1$@ in den Programmeordner, starte es von dort aus und versuche es erneut zu aktualisieren.";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "„%1$@“ kann nicht aktualisiert werden, wenn das Programm von dem Ort ausgeführt wird, an den es heruntergeladen wurde.";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ ist zurzeit die neueste verfügbare Version.";
|
||||
|
||||
/* Description text for SUUpdateAlert when the update is downloadable. */
|
||||
|
||||
Vendored
-1
@@ -25,7 +25,6 @@
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window identifier="SUUpdateAlert" title="Software Update" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="746" y="229" width="620" height="370"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Profile Info">
|
||||
<windowStyleMask key="styleMask" titled="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="83" y="492" width="438" height="168"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
|
||||
|
||||
Vendored
-2
@@ -4,8 +4,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "%1$@ can’t be updated if it’s running from the location it was downloaded to.";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ is currently the newest version available.";
|
||||
|
||||
/* Description text for SUUpdateAlert when the update is downloadable. */
|
||||
|
||||
Vendored
-2
@@ -4,8 +4,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "%1$@ ne peut pas être mis à jour quand il fonctionne à partir d’un volume en lecture seule, comme une image disque ou un lecteur optique. Déplacez %1$@ dans votre dossier Applications, relancez-le à partir de là et réessayez.";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "%1$@ ne peut pas être mis à jour s'il est exécuté depuis le dossier dans lequel il a été téléchargé.";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ est la version la plus récente disponible.";
|
||||
|
||||
/* Description text for SUUpdateAlert when the update is downloadable. */
|
||||
|
||||
Vendored
-2
@@ -4,8 +4,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "%1$@は読み出し専用またはテンポラリな場所で開かれているためアップデートできません。%1$@をアプリケーションフォルダに移動し、そこから再起動したあとやり直してください。";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "この場所ではダウンロードされたアップデータを %1$@ に適用できません。";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@は現在入手できる最新バージョンです。";
|
||||
|
||||
/* Description text for SUUpdateAlert when the update is downloadable. */
|
||||
|
||||
Vendored
-2
@@ -2,8 +2,6 @@
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "无法更新 %1$@,因为它运行于一个只读宗卷如磁盘映像或光盘。移动 %1$@ 到应用程序文件夹并再试一次。";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "如果在下载位置运行此程序,则无法对 %1$@ 进行更新。";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ 是当前的最新版本。";
|
||||
|
||||
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 可供下载,您现在的版本是 %3$@。要现在下载吗?";
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#import "SUFileManager.h"
|
||||
#import "SUTestWebServer.h"
|
||||
#import "TestAppHelperProtocol.h"
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
|
||||
@interface SUTestApplicationDelegate ()
|
||||
|
||||
@@ -129,18 +128,30 @@ static NSString * const UPDATED_VERSION = @"2.0";
|
||||
|
||||
// Don't ever do this at home, kids (seriously)
|
||||
// (that is, including the private key inside of your application)
|
||||
const unsigned char self_sign_demo_only_insecure_hack[64] = {200, 238, 135, 84, 10, 189, 3, 193, 61, 208, 203, 30, 133, 47, 12, 22, 19, 52, 252, 99, 110, 205, 209, 94, 215, 144, 201, 70, 27, 162, 163, 108, 0, 164, 68, 184, 226, 93, 121, 199, 172, 17, 26, 64, 89, 68, 232, 41, 2, 26, 245, 175, 158, 165, 42, 55, 5, 97, 8, 243, 251, 164, 93, 9};
|
||||
// in normal app this goes to Info.plist
|
||||
const unsigned char public_key[32] = {121, 17, 79, 45, 155, 141, 51, 169, 188, 110, 91, 102, 182, 147, 215, 225, 252, 202, 110, 231, 200, 215, 62, 171, 40, 145, 237, 128, 130, 44, 150, 89};
|
||||
unsigned char signature[64];
|
||||
|
||||
NSString *privateKeyPath = [mainBundle pathForResource:@"test_app_only_dsa_priv_dont_ever_do_this_for_real" ofType:@"pem"];
|
||||
assert(privateKeyPath != nil);
|
||||
|
||||
// Sign our update
|
||||
NSTask *signUpdateTask = [[NSTask alloc] init];
|
||||
NSString *signUpdatePath = [mainBundle pathForResource:@"sign_update" ofType:@""];
|
||||
assert(signUpdatePath != nil);
|
||||
signUpdateTask.launchPath = signUpdatePath;
|
||||
|
||||
NSURL *archiveURL = [serverDirectoryURL URLByAppendingPathComponent:zipName];
|
||||
NSData *archive = [NSData dataWithContentsOfURL:archiveURL];
|
||||
assert(archive != nil);
|
||||
|
||||
ed25519_sign(signature, archive.bytes, archive.length, public_key, self_sign_demo_only_insecure_hack);
|
||||
|
||||
NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64Encoding];
|
||||
signUpdateTask.arguments = @[(NSString *)archiveURL.path, privateKeyPath];
|
||||
|
||||
NSPipe *outputPipe = [NSPipe pipe];
|
||||
signUpdateTask.standardOutput = outputPipe;
|
||||
|
||||
[signUpdateTask launch];
|
||||
[signUpdateTask waitUntilExit];
|
||||
|
||||
assert(signUpdateTask.terminationStatus == 0);
|
||||
|
||||
NSData *signatureData = [outputPipe.fileHandleForReading readDataToEndOfFile];
|
||||
NSString *signature = [[[NSString alloc] initWithData:signatureData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
assert(signature != nil);
|
||||
|
||||
// Obtain the file attributes to get the file size of our update later
|
||||
NSError *fileAttributesError = nil;
|
||||
@@ -177,7 +188,7 @@ static NSString * const UPDATED_VERSION = @"2.0";
|
||||
NSUInteger numberOfLengthReplacements = [appcastContents replaceOccurrencesOfString:@"$INSERT_ARCHIVE_LENGTH" withString:[NSString stringWithFormat:@"%llu", archiveFileAttributes.fileSize] options:NSLiteralSearch range:NSMakeRange(0, appcastContents.length)];
|
||||
assert(numberOfLengthReplacements == 1);
|
||||
|
||||
NSUInteger numberOfSignatureReplacements = [appcastContents replaceOccurrencesOfString:@"$INSERT_EDDSA_SIGNATURE" withString:signatureString options:NSLiteralSearch range:NSMakeRange(0, appcastContents.length)];
|
||||
NSUInteger numberOfSignatureReplacements = [appcastContents replaceOccurrencesOfString:@"$INSERT_DSA_SIGNATURE" withString:signature options:NSLiteralSearch range:NSMakeRange(0, appcastContents.length)];
|
||||
assert(numberOfSignatureReplacements == 1);
|
||||
|
||||
NSError *writeAppcastError = nil;
|
||||
|
||||
@@ -56,12 +56,7 @@
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
NSLog(@"Failed to start updater with error: %@", updaterError);
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"Updater Error";
|
||||
alert.informativeText = @"The Updater failed to start. For detailed error information, check the Console.app log.";
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert runModal];
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.5.1</string>
|
||||
<string>1.5</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5.1</string>
|
||||
<string>1.5</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
@@ -28,7 +28,7 @@
|
||||
<true/>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://localhost:1337/sparkletestcast.xml</string>
|
||||
<key>SUPublicEDKey</key>
|
||||
<string>eRFPLZuNM6m8bltmtpPX4fzKbufI1z6rKJHtgIIsllk=</string>
|
||||
<key>SUPublicDSAKeyFile</key>
|
||||
<string>test_app_only_dsa_pub.pem</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -17,7 +17,7 @@
|
||||
]]>
|
||||
</description>
|
||||
<pubDate>Sat, 26 Jul 2014 15:20:11 +0000</pubDate>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="2.0" length="$INSERT_ARCHIVE_LENGTH" type="application/octet-stream" sparkle:edSignature="$INSERT_EDDSA_SIGNATURE" />
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="2.0" length="$INSERT_ARCHIVE_LENGTH" type="application/octet-stream" sparkle:dsaSignature="$INSERT_DSA_SIGNATURE" />
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -0,0 +1,36 @@
|
||||
-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIGPgIBAAKCAgEAvvs5v/Vbc6gYls5WnHUmWy9rhUsuAvf+HAuz9Tzp63fb8Cni
|
||||
8aqe+qkiL3RKuabl92BAK7Vwv4EMOXozDlNPWZS5EZUBZuiQ7vtQC9Eg3C68KWwb
|
||||
lrhSwzyVnXz8twD75CiR+oPSZEIiOQ81Ok///i1+TV17ierbLxYJ2Sd1wTRQdLeS
|
||||
7rmnL6aLka0PNtsFvFlvW9GbrlNP9PZaGmrJYadsTV5+F9XZRFnwZc6crmrIo+DA
|
||||
VNucgqBdZUNN0CWz9OJfKr/GKMw+blTF2WixDnGH2FKtNh7QSuRwlvioXBjYJbX4
|
||||
UV6jJqxZdLUMSm9iZteC8Q34cFVwrPizwRBO/8Yx/htFPrvyIkD0uvfMO55dbkld
|
||||
0nWfbHcUJRHjSEOPahOlHHGejmLWEsBtp9vD453czFXi19GhR98gEaXmcbwOr4gH
|
||||
A1WHTqOwUx6Ll+AFWG5nyZIKB9SxMUBWu0znVg9d9wqYAL0/aBWhXEFe86xYdReK
|
||||
z0RvnTRyVDbIGhMrRMviyaiTGHBbJVC62Appp/fl8o0HFSKJfTwhRSfmLupqt0XE
|
||||
C1GTbSZ9l04fsryY/dyyuO+E3e/+Q1jxyqrdJI9mhkUY2w4FWmaovScWNbekwhXb
|
||||
qy6+bsY2ZyuNGjR/S0xFyHw95l5VGiHeyXD+bWg9lYQzIULjX3zTAU6FFYMCFQCu
|
||||
tNIHrUBezHQxUxsQDgGubSZ90wKCAgAKHL/AbnSnGcoDNw2tDTrfYvQQH1CN8/yx
|
||||
0X1ryUwzn9BJYCzl6NTaHZx/LSwhSasNRmiSlp95YqhLa31xJDPaHVZH8SDLyCSn
|
||||
rBWCrKaKT8U3PKl71WUnxttYIyMTyNYh6ef+OP1uxDnOn0asWYinbDEM5E6CrRmW
|
||||
AoKx0yDgchiyOMGiwCuTN1Z7fx0AL8Y+JZ1ulOJjwd+qBaPIT/tduz5fKzEvfpHy
|
||||
6seOaRAuj/CNx1svSiCi16nlHZjlFlbzE5+IlX5iOvSEroacGbj7FHmHlRTpdgBo
|
||||
Ez6uzSV3drPDmsH9jb0nvhy/MAkBrHVOm4jj77613nD/QlO3Ilrox5+O1LuYrU6c
|
||||
gy5ZEek093QUsazHonjZc+btYIshs4FTWG9gBbZRQbJy0cOlNei0XcwIHOWqJXOJ
|
||||
LWpV1ZXu2IxLhfbg4Nt02z1CNHTm+VKD8UPyUCk8Mf9SuPUzRXeWMiLE57+8hsUs
|
||||
BcMvvURRgHZqVaNdO5ktb+i/g0zhEIFaOyfCAwZKNzLyz/JuwosbOruLMW0YCnaO
|
||||
mj9YvO0MQ+zHcd806n/9t8sig69zU/4wg9lxJrgWvf3LbjwBii143nDcSu3DGaZj
|
||||
Ti9ZAj19AbUX3PB44m9TDxFwTDTFI+xp8HSVtlWx1Pt2KXbsxD5mP1LEpHpq1GOB
|
||||
7zLcRL1F1wKCAgEAlikrAItC1I6mHKst1GQLDr9c07OuIJA+GJIJB6Iq/K/CjdUA
|
||||
Rjv/3L6l4pP33VAZySh6jqMe3Qm9W0ZZ687YSuVWRCsl2yKWAWuqXm8zaEijaHZR
|
||||
Sa6tygj9EUMZ2zbJEOPihIdWB+fHcwd01KAqUzYZEWZvw7fLZNE2QM0emQai3U1V
|
||||
3SXYney1qXW9lJ38EjB4LrYzcDFZaNKXidvXo3nI66M1MgI9lAltmRLGAOJmV6bL
|
||||
KvJEFVpSux5cubXISPQBlAw9Zb15UPc3IAe82jX7ccsI8RHe5xeIepZ0c7xnk+J8
|
||||
sFrgBrlN1swki2WfGavQOsV9kZg79rYCB3fOtxRsCBcQOasL295YWtQh5g/dCQWA
|
||||
JMx+6SVMWwr//0YSu361zJakdFz/vssVVGkaun0bM2YTOYP1ZZp6LyHwIrWEqh9m
|
||||
d2v2NAX1h4LktrJ8OHgBV/z6/YzFOlsa424Dvl1jnUozK1RDX5/z2FnX1J22hNSY
|
||||
fx2M8wTD09+xwJyFOzT8g/pjkKvYMgvnWVjvONwvM5nc2OFzuHl9JVvdF5LbSYPO
|
||||
M/KkRrtg+denjT4/fwp16gGcCsIf+RbEDN1F9rWg5hNPKteVkrMl6suuZZOu7H7E
|
||||
uZIiEcW3bxXYiN8LLXwS4G6VH+9fsUmSusJZKxhBuRThzehy0n6lfgSRRGICFBi3
|
||||
z3tWjm2F6noctsjrVH5d0jRZ
|
||||
-----END DSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,36 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIGOzCCBC0GByqGSM44BAEwggQgAoICAQC++zm/9VtzqBiWzlacdSZbL2uFSy4C
|
||||
9/4cC7P1POnrd9vwKeLxqp76qSIvdEq5puX3YEArtXC/gQw5ejMOU09ZlLkRlQFm
|
||||
6JDu+1AL0SDcLrwpbBuWuFLDPJWdfPy3APvkKJH6g9JkQiI5DzU6T//+LX5NXXuJ
|
||||
6tsvFgnZJ3XBNFB0t5LuuacvpouRrQ822wW8WW9b0ZuuU0/09loaaslhp2xNXn4X
|
||||
1dlEWfBlzpyuasij4MBU25yCoF1lQ03QJbP04l8qv8YozD5uVMXZaLEOcYfYUq02
|
||||
HtBK5HCW+KhcGNgltfhRXqMmrFl0tQxKb2Jm14LxDfhwVXCs+LPBEE7/xjH+G0U+
|
||||
u/IiQPS698w7nl1uSV3SdZ9sdxQlEeNIQ49qE6UccZ6OYtYSwG2n28PjndzMVeLX
|
||||
0aFH3yARpeZxvA6viAcDVYdOo7BTHouX4AVYbmfJkgoH1LExQFa7TOdWD133CpgA
|
||||
vT9oFaFcQV7zrFh1F4rPRG+dNHJUNsgaEytEy+LJqJMYcFslULrYCmmn9+XyjQcV
|
||||
Iol9PCFFJ+Yu6mq3RcQLUZNtJn2XTh+yvJj93LK474Td7/5DWPHKqt0kj2aGRRjb
|
||||
DgVaZqi9JxY1t6TCFdurLr5uxjZnK40aNH9LTEXIfD3mXlUaId7JcP5taD2VhDMh
|
||||
QuNffNMBToUVgwIVAK600getQF7MdDFTGxAOAa5tJn3TAoICAAocv8BudKcZygM3
|
||||
Da0NOt9i9BAfUI3z/LHRfWvJTDOf0ElgLOXo1NodnH8tLCFJqw1GaJKWn3liqEtr
|
||||
fXEkM9odVkfxIMvIJKesFYKspopPxTc8qXvVZSfG21gjIxPI1iHp5/44/W7EOc6f
|
||||
RqxZiKdsMQzkToKtGZYCgrHTIOByGLI4waLAK5M3Vnt/HQAvxj4lnW6U4mPB36oF
|
||||
o8hP+127Pl8rMS9+kfLqx45pEC6P8I3HWy9KIKLXqeUdmOUWVvMTn4iVfmI69ISu
|
||||
hpwZuPsUeYeVFOl2AGgTPq7NJXd2s8Oawf2NvSe+HL8wCQGsdU6biOPvvrXecP9C
|
||||
U7ciWujHn47Uu5itTpyDLlkR6TT3dBSxrMeieNlz5u1giyGzgVNYb2AFtlFBsnLR
|
||||
w6U16LRdzAgc5aolc4ktalXVle7YjEuF9uDg23TbPUI0dOb5UoPxQ/JQKTwx/1K4
|
||||
9TNFd5YyIsTnv7yGxSwFwy+9RFGAdmpVo107mS1v6L+DTOEQgVo7J8IDBko3MvLP
|
||||
8m7Cixs6u4sxbRgKdo6aP1i87QxD7Mdx3zTqf/23yyKDr3NT/jCD2XEmuBa9/ctu
|
||||
PAGKLXjecNxK7cMZpmNOL1kCPX0BtRfc8Hjib1MPEXBMNMUj7GnwdJW2VbHU+3Yp
|
||||
duzEPmY/UsSkemrUY4HvMtxEvUXXA4ICBgACggIBAJYpKwCLQtSOphyrLdRkCw6/
|
||||
XNOzriCQPhiSCQeiKvyvwo3VAEY7/9y+peKT991QGckoeo6jHt0JvVtGWevO2Erl
|
||||
VkQrJdsilgFrql5vM2hIo2h2UUmurcoI/RFDGds2yRDj4oSHVgfnx3MHdNSgKlM2
|
||||
GRFmb8O3y2TRNkDNHpkGot1NVd0l2J3stal1vZSd/BIweC62M3AxWWjSl4nb16N5
|
||||
yOujNTICPZQJbZkSxgDiZlemyyryRBVaUrseXLm1yEj0AZQMPWW9eVD3NyAHvNo1
|
||||
+3HLCPER3ucXiHqWdHO8Z5PifLBa4Aa5TdbMJItlnxmr0DrFfZGYO/a2Agd3zrcU
|
||||
bAgXEDmrC9veWFrUIeYP3QkFgCTMfuklTFsK//9GErt+tcyWpHRc/77LFVRpGrp9
|
||||
GzNmEzmD9WWaei8h8CK1hKofZndr9jQF9YeC5LayfDh4AVf8+v2MxTpbGuNuA75d
|
||||
Y51KMytUQ1+f89hZ19SdtoTUmH8djPMEw9PfscCchTs0/IP6Y5Cr2DIL51lY7zjc
|
||||
LzOZ3Njhc7h5fSVb3ReS20mDzjPypEa7YPnXp40+P38KdeoBnArCH/kWxAzdRfa1
|
||||
oOYTTyrXlZKzJerLrmWTrux+xLmSIhHFt28V2IjfCy18EuBulR/vX7FJkrrCWSsY
|
||||
QbkU4c3octJ+pX4EkURi
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -1,4 +0,0 @@
|
||||
# Inherits from top level config
|
||||
disabled_rules:
|
||||
- force_try
|
||||
- force_cast
|
||||
@@ -19,14 +19,14 @@
|
||||
sparkle:deltaFrom="2.0"
|
||||
length="1235"
|
||||
type="application/octet-stream"
|
||||
sparkle:edSignature="..." />
|
||||
sparkle:dsaSignature="..." />
|
||||
|
||||
<enclosure url="http://localhost:1337/3.0_from_1.0.patch"
|
||||
sparkle:version="3.0"
|
||||
sparkle:deltaFrom="1.0"
|
||||
length="1485"
|
||||
type="application/octet-stream"
|
||||
sparkle:edSignature="..." />
|
||||
sparkle:dsaSignature="..." />
|
||||
</sparkle:deltas>
|
||||
</item>
|
||||
<!-- A release testing minimumSystemVersion -->
|
||||
|
||||
+43
-43
@@ -7,82 +7,82 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Sparkle
|
||||
import Sparkle;
|
||||
|
||||
class SUAppcastTest: XCTestCase {
|
||||
|
||||
func testParseAppcast() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!
|
||||
let appcast = SUAppcast();
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!;
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
|
||||
do {
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data) as! [SUAppcastItem]
|
||||
|
||||
XCTAssertEqual(4, items.count)
|
||||
|
||||
XCTAssertEqual("Version 2.0", items[0].title)
|
||||
XCTAssertEqual("desc", items[0].itemDescription)
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data) as! [SUAppcastItem];
|
||||
|
||||
XCTAssertEqual(4, items.count);
|
||||
|
||||
XCTAssertEqual("Version 2.0", items[0].title);
|
||||
XCTAssertEqual("desc", items[0].itemDescription);
|
||||
XCTAssertEqual("Sat, 26 Jul 2014 15:20:11 +0000", items[0].dateString)
|
||||
XCTAssertTrue(items[0].isCriticalUpdate)
|
||||
|
||||
XCTAssertTrue(items[0].isCriticalUpdate);
|
||||
|
||||
// This is the best release matching our system version
|
||||
XCTAssertEqual("Version 3.0", items[1].title)
|
||||
XCTAssertNil(items[1].itemDescription)
|
||||
XCTAssertEqual("Version 3.0", items[1].title);
|
||||
XCTAssertNil(items[1].itemDescription);
|
||||
XCTAssertNil(items[1].dateString)
|
||||
XCTAssertFalse(items[1].isCriticalUpdate)
|
||||
|
||||
XCTAssertEqual("Version 4.0", items[2].title)
|
||||
XCTAssertNil(items[2].itemDescription)
|
||||
XCTAssertFalse(items[1].isCriticalUpdate);
|
||||
|
||||
XCTAssertEqual("Version 4.0", items[2].title);
|
||||
XCTAssertNil(items[2].itemDescription);
|
||||
XCTAssertEqual("Sat, 26 Jul 2014 15:20:13 +0000", items[2].dateString)
|
||||
XCTAssertFalse(items[2].isCriticalUpdate)
|
||||
|
||||
XCTAssertEqual("Version 5.0", items[3].title)
|
||||
XCTAssertNil(items[3].itemDescription)
|
||||
XCTAssertFalse(items[2].isCriticalUpdate);
|
||||
|
||||
XCTAssertEqual("Version 5.0", items[3].title);
|
||||
XCTAssertNil(items[3].itemDescription);
|
||||
XCTAssertNil(items[3].dateString)
|
||||
XCTAssertFalse(items[3].isCriticalUpdate)
|
||||
|
||||
XCTAssertFalse(items[3].isCriticalUpdate);
|
||||
|
||||
// Test best appcast item & a delta update item
|
||||
var deltaItem: SUAppcastItem?
|
||||
var deltaItem: SUAppcastItem? = nil
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator())
|
||||
|
||||
XCTAssertEqual(bestAppcastItem, items[1])
|
||||
XCTAssertEqual(deltaItem!.fileURL.lastPathComponent, "3.0_from_1.0.patch")
|
||||
|
||||
|
||||
// Test latest delta update item available
|
||||
var latestDeltaItem: SUAppcastItem?
|
||||
var latestDeltaItem: SUAppcastItem? = nil
|
||||
SUAppcastDriver.bestItem(fromAppcastItems: items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator())
|
||||
|
||||
|
||||
XCTAssertEqual(latestDeltaItem!.fileURL.lastPathComponent, "3.0_from_2.0.patch")
|
||||
|
||||
|
||||
// Test a delta item that does not exist
|
||||
var nonexistantDeltaItem: SUAppcastItem?
|
||||
var nonexistantDeltaItem: SUAppcastItem? = nil
|
||||
SUAppcastDriver.bestItem(fromAppcastItems: items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator())
|
||||
|
||||
|
||||
XCTAssertNil(nonexistantDeltaItem)
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
NSLog("%@", err);
|
||||
XCTFail(err.localizedDescription);
|
||||
}
|
||||
}
|
||||
|
||||
func testNamespaces() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!
|
||||
let appcast = SUAppcast();
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!;
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
do {
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data) as! [SUAppcastItem]
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data) as! [SUAppcastItem];
|
||||
|
||||
XCTAssertEqual(2, items.count)
|
||||
XCTAssertEqual(2, items.count);
|
||||
|
||||
XCTAssertEqual("Version 2.0", items[1].title)
|
||||
XCTAssertEqual("desc", items[1].itemDescription)
|
||||
XCTAssertNotNil(items[0].releaseNotesURL)
|
||||
XCTAssertEqual("https://sparkle-project.org/#works", items[0].releaseNotesURL!.absoluteString)
|
||||
XCTAssertEqual("Version 2.0", items[1].title);
|
||||
XCTAssertEqual("desc", items[1].itemDescription);
|
||||
XCTAssertNotNil(items[0].releaseNotesURL);
|
||||
XCTAssertEqual("https://sparkle-project.org/#works", items[0].releaseNotesURL!.absoluteString);
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
NSLog("%@", err);
|
||||
XCTFail(err.localizedDescription);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,6 @@
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#if defined(__MAC_10_15)
|
||||
// In macOS 10.15 and later, pre-installed apps are installed under the System folder
|
||||
#define CALCULATOR_PATH @"/System/Applications/Calculator.app"
|
||||
#else
|
||||
#define CALCULATOR_PATH @"/Applications/Calculator.app"
|
||||
#endif
|
||||
|
||||
@interface SUCodeSigningVerifierTest : XCTestCase
|
||||
|
||||
@property (copy) NSURL *notSignedAppURL;
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
|
||||
@interface SUDSAVerifierTest : XCTestCase
|
||||
@property NSString *testFile, *pubKeyFile;
|
||||
@@ -28,7 +27,7 @@
|
||||
|
||||
- (void)testVerifyFileAtPath
|
||||
{
|
||||
NSString *pubKey = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
NSData *pubKey = [NSData dataWithContentsOfFile:self.pubKeyFile];
|
||||
XCTAssertNotNil(pubKey, @"Public key must be readable");
|
||||
|
||||
NSString *validSig = @"MCwCFCIHCIYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
@@ -39,7 +38,7 @@
|
||||
@"Expected valid signature");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withPubKey:@"lol"
|
||||
withPubKey:[NSData dataWithBytes:"lol" length:3]
|
||||
signature:validSig],
|
||||
@"Invalid pubkey");
|
||||
|
||||
@@ -64,29 +63,23 @@
|
||||
@"Expected invalid signature");
|
||||
}
|
||||
|
||||
- (BOOL)checkFile:(NSString *)aFile withPubKey:(NSString *)pubKey signature:(NSString *)sigString
|
||||
- (BOOL)checkFile:(NSString *)aFile withPubKey:(NSData *)pubKey signature:(NSString *)sigString
|
||||
{
|
||||
SUPublicKeys *pubKeys = [[SUPublicKeys alloc] initWithDsa:pubKey ed:nil];
|
||||
SUSignatureVerifier *v = [[SUSignatureVerifier alloc] initWithPublicKeys:pubKeys];
|
||||
SUDSAVerifier *v = [[SUDSAVerifier alloc] initWithPublicKeyData:pubKey];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:sigString ed:nil];
|
||||
NSData *sig = [[NSData alloc] initWithBase64EncodedString:sigString options:(NSDataBase64DecodingOptions)0];
|
||||
|
||||
return [v verifyFileAtPath:aFile signatures:sig];
|
||||
return [v verifyFileAtPath:aFile signature:sig];
|
||||
}
|
||||
|
||||
- (void)testValidatePath
|
||||
{
|
||||
NSString *dsaStr = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
XCTAssertNotNil(dsaStr);
|
||||
SUPublicKeys *pubkeys = [[SUPublicKeys alloc] initWithDsa:dsaStr ed:nil];
|
||||
XCTAssertNotNil(pubkeys);
|
||||
XCTAssertNotNil(pubkeys.dsaPubKey);
|
||||
NSString *pubkey = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:@"MC0CFFMF3ha5kjvrJ9JTpTR8BenPN9QUAhUAzY06JRdtP17MJewxhK0twhvbKIE=" ed:nil];
|
||||
XCTAssertNotNil(sig);
|
||||
XCTAssertNotNil(sig.dsaSignature);
|
||||
|
||||
XCTAssertTrue([SUSignatureVerifier validatePath:self.testFile withSignatures:sig withPublicKeys:pubkeys], @"Expected valid signature");
|
||||
XCTAssertTrue([SUDSAVerifier validatePath:self.testFile
|
||||
withEncodedDSASignature:@"MC0CFFMF3ha5kjvrJ9JTpTR8BenPN9QUAhUAzY06JRdtP17MJewxhK0twhvbKIE="
|
||||
withPublicDSAKey:pubkey],
|
||||
@"Expected valid signature");
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -13,54 +13,54 @@ class SUFileManagerTest: XCTestCase
|
||||
func makeTempFiles(_ testBlock: (SUFileManager, URL, URL, URL, URL, URL, URL) -> Void)
|
||||
{
|
||||
let fileManager = SUFileManager()
|
||||
|
||||
|
||||
let tempDirectoryURL = try! fileManager.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory()))
|
||||
|
||||
|
||||
defer {
|
||||
try! fileManager.removeItem(at: tempDirectoryURL)
|
||||
}
|
||||
|
||||
|
||||
let ordinaryFileURL = tempDirectoryURL.appendingPathComponent("a file written by sparkles unit tests")
|
||||
try! "foo".data(using: String.Encoding.utf8)!.write(to: ordinaryFileURL, options: .atomic)
|
||||
|
||||
|
||||
let directoryURL = tempDirectoryURL.appendingPathComponent("a directory written by sparkles unit tests")
|
||||
try! FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: false, attributes: nil)
|
||||
|
||||
|
||||
let fileInDirectoryURL = directoryURL.appendingPathComponent("a file inside a directory written by sparkles unit tests")
|
||||
try! "bar baz".data(using: String.Encoding.utf8)!.write(to: fileInDirectoryURL, options: .atomic)
|
||||
|
||||
|
||||
let validSymlinkURL = tempDirectoryURL.appendingPathComponent("symlink test")
|
||||
try! FileManager.default.createSymbolicLink(at: validSymlinkURL, withDestinationURL: directoryURL)
|
||||
|
||||
|
||||
let invalidSymlinkURL = tempDirectoryURL.appendingPathComponent("symlink test 2")
|
||||
try! FileManager.default.createSymbolicLink(at: invalidSymlinkURL, withDestinationURL: (tempDirectoryURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
testBlock(fileManager, tempDirectoryURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL)
|
||||
}
|
||||
|
||||
|
||||
func testMoveFiles()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL))
|
||||
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
|
||||
XCTAssertNil(try? fileManager.moveItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
|
||||
|
||||
|
||||
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
|
||||
try! fileManager.moveItem(at: ordinaryFileURL, to: newFileURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
|
||||
|
||||
|
||||
let newValidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink"))
|
||||
try! fileManager.moveItem(at: validSymlinkURL, to: newValidSymlinkURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
|
||||
|
||||
|
||||
let newInvalidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new invalid symlink"))
|
||||
try! fileManager.moveItem(at: invalidSymlinkURL, to: newInvalidSymlinkURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: invalidSymlinkURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
|
||||
|
||||
|
||||
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
|
||||
try! fileManager.moveItem(at: directoryURL, to: newDirectoryURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
|
||||
@@ -69,23 +69,23 @@ class SUFileManagerTest: XCTestCase
|
||||
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL.appendingPathComponent(fileInDirectoryURL.lastPathComponent)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testCopyFiles()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, _, invalidSymlinkURL in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL))
|
||||
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
|
||||
XCTAssertNil(try? fileManager.copyItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
|
||||
|
||||
|
||||
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
|
||||
try! fileManager.copyItem(at: ordinaryFileURL, to: newFileURL)
|
||||
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
|
||||
|
||||
|
||||
let newSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink file"))
|
||||
try! fileManager.copyItem(at: invalidSymlinkURL, to: newSymlinkURL)
|
||||
XCTAssertTrue(fileManager._itemExists(at: newSymlinkURL))
|
||||
|
||||
|
||||
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
|
||||
try! fileManager.copyItem(at: directoryURL, to: newDirectoryURL)
|
||||
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
|
||||
@@ -97,80 +97,80 @@ class SUFileManagerTest: XCTestCase
|
||||
|
||||
func testRemoveFiles()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.removeItem(at: rootURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
try! fileManager.removeItem(at: ordinaryFileURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
|
||||
|
||||
|
||||
try! fileManager.removeItem(at: validSymlinkURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
|
||||
|
||||
|
||||
try! fileManager.removeItem(at: directoryURL)
|
||||
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
|
||||
XCTAssertFalse(fileManager._itemExists(at: fileInDirectoryURL))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testReleaseFilesFromQuarantine()
|
||||
{
|
||||
makeTempFiles() { fileManager, _, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
|
||||
|
||||
|
||||
let quarantineData = "does not really matter what is here".cString(using: String.Encoding.utf8)!
|
||||
let quarantineDataLength = Int(strlen(quarantineData))
|
||||
|
||||
|
||||
XCTAssertEqual(0, setxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
|
||||
XCTAssertGreaterThan(getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
|
||||
|
||||
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
|
||||
XCTAssertEqual(-1, getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
|
||||
|
||||
|
||||
XCTAssertEqual(0, setxattr(directoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
|
||||
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
|
||||
|
||||
|
||||
XCTAssertEqual(0, setxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
|
||||
XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
|
||||
|
||||
|
||||
// Extended attributes can't be set on symbolic links currently
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
|
||||
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
|
||||
XCTAssertEqual(-1, getxattr(validSymlinkURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
|
||||
|
||||
|
||||
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
|
||||
|
||||
|
||||
XCTAssertEqual(-1, getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
|
||||
XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func groupIDAtPath(_ path: String) -> gid_t
|
||||
{
|
||||
let attributes = try! FileManager.default.attributesOfItem(atPath: path)
|
||||
let groupID = attributes[FileAttributeKey.groupOwnerAccountID] as! NSNumber
|
||||
return groupID.uint32Value
|
||||
}
|
||||
|
||||
|
||||
// Only the super user can alter user IDs, so changing user IDs is not tested here
|
||||
// Instead we try to change the group ID - we just have to be a member of that group
|
||||
func testAlterFilesGroupID()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: rootURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: rootURL.appendingPathComponent("does not exist"), toMatch: ordinaryFileURL))
|
||||
|
||||
|
||||
let everyoneGroup = getgrnam("everyone")
|
||||
let everyoneGroupID = everyoneGroup?.pointee.gr_gid
|
||||
|
||||
|
||||
let staffGroup = getgrnam("staff")
|
||||
let staffGroupID = staffGroup?.pointee.gr_gid
|
||||
|
||||
|
||||
XCTAssertNotEqual(staffGroupID, everyoneGroupID)
|
||||
|
||||
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
|
||||
@@ -179,55 +179,55 @@ class SUFileManagerTest: XCTestCase
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: ordinaryFileURL)
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
|
||||
|
||||
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path))
|
||||
|
||||
|
||||
XCTAssertEqual(0, chown(ordinaryFileURL.path, getuid(), everyoneGroupID!))
|
||||
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(ordinaryFileURL.path))
|
||||
|
||||
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
|
||||
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
|
||||
|
||||
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: directoryURL)
|
||||
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
|
||||
|
||||
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
|
||||
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(validSymlinkURL.path))
|
||||
|
||||
|
||||
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: directoryURL, toMatch: ordinaryFileURL)
|
||||
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(directoryURL.path))
|
||||
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testUpdateFileModificationTime()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, _ in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.updateModificationAndAccessTimeOfItem(at: rootURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
let oldOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
|
||||
let oldDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
|
||||
let oldValidSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
|
||||
|
||||
|
||||
sleep(1); // wait for clock to advance
|
||||
|
||||
|
||||
try! fileManager.updateModificationAndAccessTimeOfItem(at: ordinaryFileURL)
|
||||
try! fileManager.updateModificationAndAccessTimeOfItem(at: directoryURL)
|
||||
try! fileManager.updateModificationAndAccessTimeOfItem(at: validSymlinkURL)
|
||||
|
||||
|
||||
let newOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
|
||||
XCTAssertGreaterThan((newOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
|
||||
XCTAssertGreaterThan((newDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
|
||||
XCTAssertGreaterThan((newSymlinkAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldValidSymlinkAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testUpdateFileAccessTime()
|
||||
{
|
||||
let accessTime: ((URL) -> timespec?) = { url in
|
||||
@@ -239,34 +239,34 @@ class SUFileManagerTest: XCTestCase
|
||||
return outputStat.st_atimespec
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let timespecEqual: (timespec, timespec) -> Bool = {t1, t2 in
|
||||
(t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec)
|
||||
}
|
||||
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
|
||||
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.updateAccessTimeOfItem(atRootURL: rootURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
let oldOrdinaryFileTime = accessTime(ordinaryFileURL)!
|
||||
let oldDirectoryTime = accessTime(directoryURL)!
|
||||
let oldValidSymlinkTime = accessTime(validSymlinkURL)!
|
||||
|
||||
|
||||
sleep(1); // wait for clock to advance
|
||||
|
||||
|
||||
// Make sure access time haven't changed since; lstat() shouldn't have changed the access time..
|
||||
XCTAssertTrue(timespecEqual(oldOrdinaryFileTime, accessTime(ordinaryFileURL)!))
|
||||
XCTAssertTrue(timespecEqual(oldDirectoryTime, accessTime(directoryURL)!))
|
||||
XCTAssertTrue(timespecEqual(oldValidSymlinkTime, accessTime(validSymlinkURL)!))
|
||||
|
||||
|
||||
// Test the symlink and make sure the target directory doesn't change
|
||||
try! fileManager.updateAccessTimeOfItem(atRootURL: validSymlinkURL)
|
||||
XCTAssertFalse(timespecEqual(oldValidSymlinkTime, accessTime(validSymlinkURL)!))
|
||||
XCTAssertTrue(timespecEqual(oldDirectoryTime, accessTime(directoryURL)!))
|
||||
|
||||
|
||||
// Test an ordinary file
|
||||
try! fileManager.updateAccessTimeOfItem(atRootURL: ordinaryFileURL)
|
||||
XCTAssertFalse(timespecEqual(oldOrdinaryFileTime, accessTime(ordinaryFileURL)!))
|
||||
|
||||
|
||||
// Test the directory and file inside the directory
|
||||
try! fileManager.updateAccessTimeOfItem(atRootURL: directoryURL)
|
||||
let newDirectoryTime = accessTime(directoryURL)!
|
||||
@@ -274,50 +274,50 @@ class SUFileManagerTest: XCTestCase
|
||||
XCTAssertTrue(timespecEqual(newDirectoryTime, accessTime(fileInDirectoryURL)!))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testFileExists()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, invalidSymlinkURL in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
|
||||
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
|
||||
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist")))
|
||||
|
||||
|
||||
var isOrdinaryFileDirectory: ObjCBool = false
|
||||
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL, isDirectory: &isOrdinaryFileDirectory) && !isOrdinaryFileDirectory.boolValue)
|
||||
|
||||
|
||||
var isDirectoryADirectory: ObjCBool = false
|
||||
XCTAssertTrue(fileManager._itemExists(at: directoryURL, isDirectory: &isDirectoryADirectory) && isDirectoryADirectory.boolValue)
|
||||
|
||||
|
||||
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist"), isDirectory: nil))
|
||||
|
||||
|
||||
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL))
|
||||
|
||||
|
||||
var validSymlinkIsADirectory: ObjCBool = false
|
||||
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL, isDirectory: &validSymlinkIsADirectory) && !validSymlinkIsADirectory.boolValue)
|
||||
|
||||
|
||||
// Symlink should still exist even if it doesn't point to a file that exists
|
||||
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL))
|
||||
|
||||
|
||||
var invalidSymlinkIsADirectory: ObjCBool = false
|
||||
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL, isDirectory: &invalidSymlinkIsADirectory) && !invalidSymlinkIsADirectory.boolValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testMakeDirectory()
|
||||
{
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, _ in
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.makeDirectory(at: ordinaryFileURL))
|
||||
XCTAssertNil(try? fileManager.makeDirectory(at: directoryURL))
|
||||
|
||||
|
||||
XCTAssertNil(try? fileManager.makeDirectory(at: rootURL.appendingPathComponent("this should").appendingPathComponent("be a failure")))
|
||||
|
||||
|
||||
let newDirectoryURL = rootURL.appendingPathComponent("new test directory")
|
||||
XCTAssertFalse(fileManager._itemExists(at: newDirectoryURL))
|
||||
try! fileManager.makeDirectory(at: newDirectoryURL)
|
||||
|
||||
|
||||
var isDirectory: ObjCBool = false
|
||||
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL, isDirectory: &isDirectory))
|
||||
|
||||
|
||||
try! fileManager.removeItem(at: directoryURL)
|
||||
XCTAssertNil(try? fileManager.makeDirectory(at: validSymlinkURL))
|
||||
}
|
||||
|
||||
@@ -14,47 +14,47 @@ class SUSpotlightImporterTest: XCTestCase
|
||||
{
|
||||
let fileManager = SUFileManager()
|
||||
let tempDirectoryURL = try! fileManager.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory()))
|
||||
|
||||
|
||||
let bundleDirectory = tempDirectoryURL.appendingPathComponent("bundle.app")
|
||||
try! fileManager.makeDirectory(at: bundleDirectory)
|
||||
|
||||
|
||||
let innerDirectory = bundleDirectory.appendingPathComponent("foo")
|
||||
try! fileManager.makeDirectory(at: innerDirectory)
|
||||
try! Data().write(to: (bundleDirectory.appendingPathComponent("bar")), options: .atomicWrite)
|
||||
|
||||
|
||||
let importerDirectory = innerDirectory.appendingPathComponent("baz.mdimporter")
|
||||
|
||||
|
||||
try! fileManager.makeDirectory(at: importerDirectory)
|
||||
try! fileManager.makeDirectory(at: innerDirectory.appendingPathComponent("flag"))
|
||||
|
||||
|
||||
try! Data().write(to: (importerDirectory.appendingPathComponent("file")), options: .atomicWrite)
|
||||
|
||||
|
||||
let oldFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.path)
|
||||
let oldBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory.appendingPathComponent("bar").path)
|
||||
let oldImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.path)
|
||||
let oldFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.appendingPathComponent("flag").path)
|
||||
let oldFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.appendingPathComponent("file").path)
|
||||
|
||||
|
||||
sleep(1) // wait for clock to advance
|
||||
|
||||
|
||||
// Update spotlight bundles
|
||||
SUBinaryDeltaUnarchiver.updateSpotlightImporters(atBundlePath: bundleDirectory.path)
|
||||
|
||||
|
||||
let newFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.path)
|
||||
XCTAssertEqual((newFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory.appendingPathComponent("bar").path)
|
||||
XCTAssertEqual((newBarFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldBarFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.path)
|
||||
XCTAssertGreaterThan((newImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.appendingPathComponent("flag").path)
|
||||
XCTAssertEqual((newFlagAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFlagAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
let newFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.appendingPathComponent("file").path)
|
||||
XCTAssertEqual((newFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
|
||||
|
||||
|
||||
try! fileManager.removeItem(at: tempDirectoryURL)
|
||||
}
|
||||
}
|
||||
@@ -13,85 +13,84 @@ class SUUnarchiverTest: XCTestCase
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, password: String? = nil) {
|
||||
let appName = "SparkleTestCodeSignApp"
|
||||
let archiveResourceURL = Bundle(for: type(of: self)).url(forResource: appName, withExtension: archiveExtension)!
|
||||
|
||||
|
||||
let fileManager = FileManager.default
|
||||
|
||||
|
||||
// Do not remove this temporary directory
|
||||
// If we do want to clean up and remove it (which isn't necessary but nice), we'd have to remove it
|
||||
// after *both* our unarchive success and failure calls below finish (they both have async completion blocks inside their implementation)
|
||||
let tempDirectoryURL = try! fileManager.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: URL(fileURLWithPath: NSHomeDirectory()), create: true)
|
||||
|
||||
|
||||
let unarchivedSuccessExpectation = super.expectation(description: "Unarchived Success (format: \(archiveExtension))")
|
||||
let unarchivedFailureExpectation = super.expectation(description: "Unarchived Failure (format: \(archiveExtension))")
|
||||
|
||||
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
|
||||
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
|
||||
|
||||
self.unarchiveTestSuccessAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, testExpectation: unarchivedSuccessExpectation)
|
||||
self.unarchiveTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
|
||||
|
||||
|
||||
self.unarchiveTestSuccessAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, testExpectation: unarchivedSuccessExpectation);
|
||||
self.unarchiveTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation);
|
||||
|
||||
super.waitForExpectations(timeout: 7.0, handler: nil)
|
||||
|
||||
|
||||
XCTAssertTrue(fileManager.fileExists(atPath: extractedAppURL.path))
|
||||
|
||||
|
||||
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path))
|
||||
}
|
||||
|
||||
|
||||
func unarchiveTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension)
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension);
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
|
||||
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
|
||||
XCTAssertNotNil(error)
|
||||
XCTAssertNotNil(error);
|
||||
testExpectation.fulfill()
|
||||
}, progressBlock: nil)
|
||||
}, progressBlock: nil);
|
||||
}
|
||||
|
||||
// swiftlint:disable function_parameter_count
|
||||
|
||||
func unarchiveTestSuccessAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
|
||||
|
||||
let fileManager = FileManager.default
|
||||
|
||||
|
||||
try! fileManager.copyItem(at: archiveResourceURL, to: tempArchiveURL)
|
||||
|
||||
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
|
||||
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
|
||||
XCTAssertNil(error)
|
||||
XCTAssertNil(error);
|
||||
testExpectation.fulfill()
|
||||
}, progressBlock: nil)
|
||||
}, progressBlock: nil);
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingZip()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("zip")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingTarDotGz()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("tar.gz")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingTar()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("tar")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingTarDotBz2()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("tar.bz2")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingTarDotXz()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("tar.xz")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingDmg()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("dmg")
|
||||
}
|
||||
|
||||
|
||||
func testUnarchivingEncryptedDmg()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("enc.dmg", password: "testpass")
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# Inherits from top level config
|
||||
disabled_rules:
|
||||
- force_try
|
||||
- force_cast
|
||||
@@ -10,10 +10,10 @@ import XCTest
|
||||
|
||||
class SUTestApplicationTest: XCTestCase
|
||||
{
|
||||
var testApplicationURL: URL?
|
||||
var testApplicationBackupURL: URL?
|
||||
var tempDirectoryURL: URL?
|
||||
|
||||
var testApplicationURL: URL? = nil
|
||||
var testApplicationBackupURL: URL? = nil
|
||||
var tempDirectoryURL: URL? = nil
|
||||
|
||||
func runningTestApplication() -> NSRunningApplication
|
||||
{
|
||||
// TODO: don't hardcode bundle ID?
|
||||
@@ -21,91 +21,91 @@ class SUTestApplicationTest: XCTestCase
|
||||
XCTAssertEqual(runningApplications.count, 1, "More than one or zero running instances of the Test Application are found")
|
||||
return runningApplications[0]
|
||||
}
|
||||
|
||||
|
||||
override func setUp()
|
||||
{
|
||||
super.setUp()
|
||||
|
||||
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
|
||||
|
||||
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
|
||||
|
||||
|
||||
// We need to grab the app URL so we can back up the app
|
||||
// When a successful test is over we'll revert the update
|
||||
let testApplicationURL = self.runningTestApplication().bundleURL!
|
||||
|
||||
|
||||
let tempDirectoryURL = try! FileManager.default.url(for: .itemReplacementDirectory, in: FileManager.SearchPathDomainMask.userDomainMask, appropriateFor: testApplicationURL, create: true)
|
||||
|
||||
|
||||
let testApplicationBackupURL = tempDirectoryURL.appendingPathComponent(testApplicationURL.lastPathComponent)
|
||||
|
||||
|
||||
try! FileManager.default.copyItem(at: testApplicationURL, to: testApplicationBackupURL)
|
||||
|
||||
|
||||
self.testApplicationURL = testApplicationURL
|
||||
self.testApplicationBackupURL = testApplicationBackupURL
|
||||
self.tempDirectoryURL = tempDirectoryURL
|
||||
|
||||
|
||||
// when we add more tests we don't want to continue after a failure
|
||||
// since a test can fail after the new app has been placed in
|
||||
self.continueAfterFailure = false
|
||||
}
|
||||
|
||||
|
||||
override func tearDown()
|
||||
{
|
||||
// Terminate just in case the app hasn't already quit
|
||||
XCUIApplication().terminate()
|
||||
|
||||
|
||||
// Revert our update with the original test application
|
||||
|
||||
var resultingURL: NSURL?
|
||||
|
||||
var resultingURL: NSURL? = nil
|
||||
try! FileManager.default.replaceItem(at: self.testApplicationURL!, withItemAt: self.testApplicationBackupURL!, backupItemName: nil, options: .usingNewMetadataOnly, resultingItemURL: &resultingURL)
|
||||
|
||||
|
||||
do {
|
||||
try FileManager.default.removeItem(at: self.tempDirectoryURL!)
|
||||
} catch let error as NSError {
|
||||
NSLog("Failed to remove temporary directory \(self.tempDirectoryURL) with error: \(error)")
|
||||
}
|
||||
|
||||
|
||||
// The URL we get back from NSFileManager should be the same..
|
||||
XCTAssertEqual(self.testApplicationURL, resultingURL as URL?, "Test application was replaced, but at a different location")
|
||||
|
||||
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
|
||||
func testRegularUpdate()
|
||||
{
|
||||
let app = XCUIApplication()
|
||||
let menuBarsQuery = app.menuBars
|
||||
|
||||
menuBarsQuery.menuBarItems["Sparkle Test App"].click()
|
||||
|
||||
|
||||
// If the update window already showed up automatically, this option will be disabled.
|
||||
// Even if it's disabled, attempting to click it will do no harm and continue on
|
||||
menuBarsQuery.menuItems["Check for Updates…"].click()
|
||||
|
||||
|
||||
// Workaround to make sure we can click the install update button later
|
||||
// This workaround is needed if the alert prompts up automatically *before* we manually check for updates
|
||||
// I'm not sure why this workaround works or is necessary
|
||||
app.dialogs["SUUpdateAlert"].staticTexts["Software Update"].click()
|
||||
|
||||
|
||||
app.dialogs["SUUpdateAlert"].buttons["Install Update"].click()
|
||||
app.windows["SUStatus"].buttons["Install and Relaunch"].click()
|
||||
|
||||
|
||||
// Wait for the new updated app to finish launching so we can test if it's the frontmost app
|
||||
sleep(3)
|
||||
|
||||
|
||||
// Our new updated app should be launched now. Test if it's the active app
|
||||
// We used to run into timing issues where the updated app sometimes may not show up as the frontmost one
|
||||
XCTAssertTrue(self.runningTestApplication().isActive)
|
||||
|
||||
|
||||
// Grab another XCUIApplication instance rather than using the old one, just in case
|
||||
let updatedApp = XCUIApplication()
|
||||
|
||||
|
||||
// Check if we can click the "Update succeeded!" label rather than using the exists property
|
||||
// Checking the exists property doesn't reload the "cache" and as such the UI tests still would think we are
|
||||
// referring to the older app. Clicking does force the UI tests to find the new app however
|
||||
updatedApp.dialogs["alert"].staticTexts["Update succeeded!"].click()
|
||||
|
||||
|
||||
updatedApp.dialogs["alert"].buttons["OK"].click()
|
||||
}
|
||||
}
|
||||
@@ -6,159 +6,159 @@
|
||||
import Foundation
|
||||
|
||||
// Maximum number of delta updates (per OS).
|
||||
let maxDeltas = 5
|
||||
let maxDeltas = 5;
|
||||
|
||||
func makeError(code: SUError, _ description: String) -> NSError {
|
||||
return NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(code.rawValue)), userInfo: [
|
||||
NSLocalizedDescriptionKey: description,
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String: [ArchiveItem]] {
|
||||
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast")
|
||||
let comparator = SUStandardVersionComparator()
|
||||
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String:[ArchiveItem]] {
|
||||
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast");
|
||||
let comparator = SUStandardVersionComparator();
|
||||
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose: verbose))
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose:verbose))
|
||||
.sorted(by: {
|
||||
.orderedDescending == comparator.compareVersion($0.version, toVersion: $1.version)
|
||||
.orderedDescending == comparator.compareVersion($0.version, toVersion:$1.version)
|
||||
})
|
||||
|
||||
if allUpdates.count == 0 {
|
||||
throw makeError(code: .noUpdateError, "No usable archives found in \(archivesSourceDir.path)")
|
||||
throw makeError(code: .noUpdateError, "No usable archives found in \(archivesSourceDir.path)");
|
||||
}
|
||||
|
||||
var updatesByAppcast: [String: [ArchiveItem]] = [:]
|
||||
var updatesByAppcast:[String:[ArchiveItem]] = [:];
|
||||
|
||||
let group = DispatchGroup()
|
||||
let group = DispatchGroup();
|
||||
|
||||
for update in allUpdates {
|
||||
group.enter()
|
||||
group.enter();
|
||||
DispatchQueue.global().async {
|
||||
if let privateDSAKey = keys.privateDSAKey {
|
||||
do {
|
||||
update.dsaSignature = try dsaSignature(path: update.archivePath, privateDSAKey: privateDSAKey)
|
||||
update.dsaSignature = try dsaSignature(path: update.archivePath, privateDSAKey: privateDSAKey);
|
||||
} catch {
|
||||
print(update, error)
|
||||
print(update, error);
|
||||
}
|
||||
} else if update.supportsDSA {
|
||||
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified")
|
||||
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified");
|
||||
}
|
||||
if let publicEdKey = update.publicEdKey {
|
||||
if let privateEdKey = keys.privateEdKey, let expectedPublicKey = keys.publicEdKey {
|
||||
if publicEdKey == expectedPublicKey {
|
||||
do {
|
||||
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey)
|
||||
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
|
||||
} catch {
|
||||
print(update, error)
|
||||
print(update, error);
|
||||
}
|
||||
} else {
|
||||
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match")
|
||||
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match");
|
||||
}
|
||||
} else {
|
||||
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key")
|
||||
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key");
|
||||
}
|
||||
}
|
||||
|
||||
group.leave()
|
||||
group.leave();
|
||||
}
|
||||
|
||||
let appcastFile = update.feedURL?.lastPathComponent ?? "appcast.xml"
|
||||
let appcastFile = update.feedURL?.lastPathComponent ?? "appcast.xml";
|
||||
if updatesByAppcast[appcastFile] == nil {
|
||||
updatesByAppcast[appcastFile] = []
|
||||
updatesByAppcast[appcastFile] = [];
|
||||
}
|
||||
updatesByAppcast[appcastFile]!.append(update)
|
||||
updatesByAppcast[appcastFile]!.append(update);
|
||||
}
|
||||
|
||||
for (_, updates) in updatesByAppcast {
|
||||
var latestUpdatePerOS: [String: ArchiveItem] = [:]
|
||||
var latestUpdatePerOS:[String:ArchiveItem] = [:];
|
||||
|
||||
for update in updates {
|
||||
// items are ordered starting latest first
|
||||
let os = update.minimumSystemVersion
|
||||
let os = update.minimumSystemVersion;
|
||||
if latestUpdatePerOS[os] == nil {
|
||||
latestUpdatePerOS[os] = update
|
||||
latestUpdatePerOS[os] = update;
|
||||
}
|
||||
}
|
||||
|
||||
for (_, latestItem) in latestUpdatePerOS {
|
||||
var numDeltas = 0
|
||||
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent
|
||||
for (_,latestItem) in latestUpdatePerOS {
|
||||
var numDeltas = 0;
|
||||
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent;
|
||||
for item in updates {
|
||||
if numDeltas > maxDeltas {
|
||||
break
|
||||
break;
|
||||
}
|
||||
|
||||
// No downgrades
|
||||
if .orderedAscending != comparator.compareVersion(item.version, toVersion: latestItem.version) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
// Old version will not be able to verify the new version
|
||||
if !item.supportsDSA && item.publicEdKey == nil {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version
|
||||
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta")
|
||||
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version;
|
||||
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta");
|
||||
|
||||
var delta: DeltaUpdate
|
||||
let ignoreMarkerPath = cacheDir.appendingPathComponent(deltaPath.lastPathComponent).appendingPathExtension(".ignore")
|
||||
let fm = FileManager.default
|
||||
var delta:DeltaUpdate;
|
||||
let ignoreMarkerPath = cacheDir.appendingPathComponent(deltaPath.lastPathComponent).appendingPathExtension(".ignore");
|
||||
let fm = FileManager.default;
|
||||
if fm.fileExists(atPath: ignoreMarkerPath.path) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
if !fm.fileExists(atPath: deltaPath.path) {
|
||||
do {
|
||||
delta = try DeltaUpdate.create(from: item, to: latestItem, archivePath: deltaPath)
|
||||
delta = try DeltaUpdate.create(from: item, to: latestItem, archivePath: deltaPath);
|
||||
} catch {
|
||||
print("Could not create delta update", deltaPath.path, error)
|
||||
continue
|
||||
print("Could not create delta update", deltaPath.path, error);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
delta = DeltaUpdate(fromVersion: item.version, archivePath: deltaPath)
|
||||
delta = DeltaUpdate(fromVersion: item.version, archivePath: deltaPath);
|
||||
}
|
||||
|
||||
numDeltas += 1
|
||||
numDeltas += 1;
|
||||
|
||||
// Require delta to be a bit smaller
|
||||
if delta.fileSize / 7 > latestItem.fileSize / 8 {
|
||||
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
group.enter()
|
||||
group.enter();
|
||||
DispatchQueue.global().async {
|
||||
if item.supportsDSA, let privateDSAKey = keys.privateDSAKey {
|
||||
do {
|
||||
delta.dsaSignature = try dsaSignature(path: deltaPath, privateDSAKey: privateDSAKey)
|
||||
delta.dsaSignature = try dsaSignature(path: deltaPath, privateDSAKey: privateDSAKey);
|
||||
} catch {
|
||||
print(delta.archivePath.lastPathComponent, error)
|
||||
print(delta.archivePath.lastPathComponent, error);
|
||||
}
|
||||
}
|
||||
if let publicEdKey = item.publicEdKey, let privateEdKey = keys.privateEdKey {
|
||||
do {
|
||||
delta.edSignature = try edSignature(path: deltaPath, publicEdKey: publicEdKey, privateEdKey: privateEdKey)
|
||||
delta.edSignature = try edSignature(path: deltaPath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
|
||||
} catch {
|
||||
print(delta.archivePath.lastPathComponent, error)
|
||||
print(delta.archivePath.lastPathComponent, error);
|
||||
}
|
||||
}
|
||||
if delta.dsaSignature != nil || delta.edSignature != nil {
|
||||
latestItem.deltas.append(delta)
|
||||
latestItem.deltas.append(delta);
|
||||
} else {
|
||||
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
|
||||
print("Delta \(delta.archivePath.path) ignored, because it could not be signed")
|
||||
print("Delta \(delta.archivePath.path) ignored, because it could not be signed");
|
||||
}
|
||||
group.leave()
|
||||
group.leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group.wait()
|
||||
group.wait();
|
||||
|
||||
return updatesByAppcast
|
||||
return updatesByAppcast;
|
||||
}
|
||||
|
||||
func markDeltaAsIgnored(delta: DeltaUpdate, markerPath: URL) {
|
||||
_ = try? FileManager.default.removeItem(at: delta.archivePath)
|
||||
_ = try? Data.init().write(to: markerPath); // 0-sized file
|
||||
let _ = try? FileManager.default.removeItem(at: delta.archivePath)
|
||||
let _ = try? Data.init().write(to: markerPath); // 0-sized file
|
||||
}
|
||||
@@ -6,63 +6,62 @@
|
||||
import Foundation
|
||||
|
||||
class DeltaUpdate {
|
||||
let fromVersion: String
|
||||
let archivePath: URL
|
||||
var dsaSignature: String?
|
||||
var edSignature: String?
|
||||
let fromVersion: String;
|
||||
let archivePath: URL;
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
|
||||
init(fromVersion: String, archivePath: URL) {
|
||||
self.archivePath = archivePath
|
||||
self.fromVersion = fromVersion
|
||||
self.archivePath = archivePath;
|
||||
self.fromVersion = fromVersion;
|
||||
}
|
||||
|
||||
var fileSize: Int64 {
|
||||
let archiveFileAttributes = try! FileManager.default.attributesOfItem(atPath: self.archivePath.path)
|
||||
return (archiveFileAttributes[.size] as! NSNumber).int64Value
|
||||
var fileSize : Int64 {
|
||||
let archiveFileAttributes = try! FileManager.default.attributesOfItem(atPath: self.archivePath.path);
|
||||
return (archiveFileAttributes[.size] as! NSNumber).int64Value;
|
||||
}
|
||||
|
||||
class func create(from: ArchiveItem, to: ArchiveItem, archivePath: URL) throws -> DeltaUpdate {
|
||||
var applyDiffError: NSError?
|
||||
var applyDiffError: NSError? = nil;
|
||||
|
||||
if !createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, .beigeMajorVersion, false, &applyDiffError) {
|
||||
throw applyDiffError!
|
||||
if (!createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, .beigeMajorVersion, false, &applyDiffError)) {
|
||||
throw applyDiffError!;
|
||||
}
|
||||
|
||||
return DeltaUpdate(fromVersion: from.version, archivePath: archivePath)
|
||||
return DeltaUpdate(fromVersion: from.version, archivePath: archivePath);
|
||||
}
|
||||
}
|
||||
|
||||
class ArchiveItem: CustomStringConvertible {
|
||||
let version: String
|
||||
// swiftlint:disable identifier_name
|
||||
let _shortVersion: String?
|
||||
let minimumSystemVersion: String
|
||||
let archivePath: URL
|
||||
let appPath: URL
|
||||
let feedURL: URL?
|
||||
let publicEdKey: Data?
|
||||
let supportsDSA: Bool
|
||||
let archiveFileAttributes: [FileAttributeKey: Any]
|
||||
var deltas: [DeltaUpdate]
|
||||
let version: String;
|
||||
let _shortVersion: String?;
|
||||
let minimumSystemVersion: String;
|
||||
let archivePath: URL;
|
||||
let appPath: URL;
|
||||
let feedURL: URL?;
|
||||
let publicEdKey: Data?;
|
||||
let supportsDSA: Bool;
|
||||
let archiveFileAttributes: [FileAttributeKey:Any];
|
||||
var deltas: [DeltaUpdate];
|
||||
|
||||
var dsaSignature: String?
|
||||
var edSignature: String?
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
|
||||
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
|
||||
self.version = version
|
||||
self._shortVersion = shortVersion
|
||||
self.feedURL = feedURL
|
||||
self.minimumSystemVersion = minimumSystemVersion ?? "10.7"
|
||||
self.archivePath = archivePath
|
||||
self.appPath = appPath
|
||||
self.supportsDSA = supportsDSA
|
||||
self.version = version;
|
||||
self._shortVersion = shortVersion;
|
||||
self.feedURL = feedURL;
|
||||
self.minimumSystemVersion = minimumSystemVersion ?? "10.7";
|
||||
self.archivePath = archivePath;
|
||||
self.appPath = appPath;
|
||||
self.supportsDSA = supportsDSA;
|
||||
if let publicEdKey = publicEdKey {
|
||||
self.publicEdKey = Data(base64Encoded: publicEdKey)
|
||||
self.publicEdKey = Data(base64Encoded: publicEdKey);
|
||||
} else {
|
||||
self.publicEdKey = nil
|
||||
self.publicEdKey = nil;
|
||||
}
|
||||
self.archiveFileAttributes = try FileManager.default.attributesOfItem(atPath: self.archivePath.path)
|
||||
self.deltas = []
|
||||
self.archiveFileAttributes = try FileManager.default.attributesOfItem(atPath: self.archivePath.path);
|
||||
self.deltas = [];
|
||||
}
|
||||
|
||||
convenience init(fromArchive archivePath: URL, unarchivedDir: URL) throws {
|
||||
@@ -75,26 +74,26 @@ class ArchiveItem: CustomStringConvertible {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
});
|
||||
if bundles.count > 0 {
|
||||
if bundles.count > 1 {
|
||||
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(bundles)")
|
||||
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(bundles)");
|
||||
}
|
||||
|
||||
let appPath = bundles[0]
|
||||
let appPath = bundles[0];
|
||||
guard let infoPlist = NSDictionary(contentsOf: appPath.appendingPathComponent("Contents/Info.plist")) else {
|
||||
throw makeError(code: .unarchivingError, "No plist \(appPath.path)")
|
||||
throw makeError(code: .unarchivingError, "No plist \(appPath.path)");
|
||||
}
|
||||
guard let version = infoPlist[kCFBundleVersionKey] as? String else {
|
||||
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)")
|
||||
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)");
|
||||
}
|
||||
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String
|
||||
let publicEdKey = infoPlist[SUPublicEDKeyKey] as? String
|
||||
let supportsDSA = infoPlist[SUPublicDSAKeyKey] != nil || infoPlist[SUPublicDSAKeyFileKey] != nil
|
||||
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String;
|
||||
let publicEdKey = infoPlist[SUPublicEDKeyKey] as? String;
|
||||
let supportsDSA = infoPlist[SUPublicDSAKeyKey] != nil || infoPlist[SUPublicDSAKeyFileKey] != nil;
|
||||
|
||||
var feedURL: URL?
|
||||
var feedURL:URL? = nil;
|
||||
if let feedURLStr = infoPlist["SUFeedURL"] as? String {
|
||||
feedURL = URL(string: feedURLStr)
|
||||
feedURL = URL(string: feedURLStr);
|
||||
}
|
||||
|
||||
try self.init(version: version,
|
||||
@@ -104,23 +103,23 @@ class ArchiveItem: CustomStringConvertible {
|
||||
publicEdKey: publicEdKey,
|
||||
supportsDSA: supportsDSA,
|
||||
appPath: appPath,
|
||||
archivePath: archivePath)
|
||||
archivePath: archivePath);
|
||||
} else {
|
||||
throw makeError(code: .missingUpdateError, "No supported items in \(unarchivedDir) \(items) [note: only .app bundles are supported]")
|
||||
throw makeError(code: .missingUpdateError, "No supported items in \(unarchivedDir) \(items) [note: only .app bundles are supported]");
|
||||
}
|
||||
}
|
||||
|
||||
var shortVersion: String {
|
||||
return self._shortVersion ?? self.version
|
||||
return self._shortVersion ?? self.version;
|
||||
}
|
||||
|
||||
var description: String {
|
||||
var description : String {
|
||||
return "\(self.archivePath) \(self.version)"
|
||||
}
|
||||
|
||||
var archiveURL: URL? {
|
||||
guard let escapedFilename = self.archivePath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
if let relative = self.feedURL {
|
||||
return URL(string: escapedFilename, relativeTo: relative)
|
||||
@@ -128,27 +127,27 @@ class ArchiveItem: CustomStringConvertible {
|
||||
return URL(string: escapedFilename)
|
||||
}
|
||||
|
||||
var pubDate: String {
|
||||
let date = self.archiveFileAttributes[.creationDate] as! Date
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZ"
|
||||
return formatter.string(from: date)
|
||||
var pubDate : String {
|
||||
let date = self.archiveFileAttributes[.creationDate] as! Date;
|
||||
let formatter = DateFormatter();
|
||||
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZ";
|
||||
return formatter.string(from: date);
|
||||
}
|
||||
|
||||
var fileSize: Int64 {
|
||||
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value
|
||||
var fileSize : Int64 {
|
||||
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value;
|
||||
}
|
||||
|
||||
private var releaseNotesPath: URL? {
|
||||
var basename = self.archivePath.deletingPathExtension()
|
||||
private var releaseNotesPath : URL? {
|
||||
var basename = self.archivePath.deletingPathExtension();
|
||||
if basename.pathExtension == "tar" { // tar.gz
|
||||
basename = basename.deletingPathExtension()
|
||||
basename = basename.deletingPathExtension();
|
||||
}
|
||||
let releaseNotes = basename.appendingPathExtension("html")
|
||||
let releaseNotes = basename.appendingPathExtension("html");
|
||||
if !FileManager.default.fileExists(atPath: releaseNotes.path) {
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
return releaseNotes
|
||||
return releaseNotes;
|
||||
}
|
||||
|
||||
private func getReleaseNotesAsHTMLFragment(_ path: URL) -> String? {
|
||||
@@ -156,29 +155,29 @@ class ArchiveItem: CustomStringConvertible {
|
||||
if html.utf8.count < 1000 &&
|
||||
!html.localizedCaseInsensitiveContains("<!DOCTYPE") &&
|
||||
!html.localizedCaseInsensitiveContains("<body") {
|
||||
return html
|
||||
return html;
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
|
||||
var releaseNotesHTML: String? {
|
||||
var releaseNotesHTML : String? {
|
||||
if let path = self.releaseNotesPath {
|
||||
return self.getReleaseNotesAsHTMLFragment(path)
|
||||
return self.getReleaseNotesAsHTMLFragment(path);
|
||||
}
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
|
||||
var releaseNotesURL: URL? {
|
||||
var releaseNotesURL : URL? {
|
||||
guard let path = self.releaseNotesPath else {
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
// The file is already used as inline description
|
||||
if self.getReleaseNotesAsHTMLFragment(path) != nil {
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
guard let escapedFilename = path.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
if let relative = self.feedURL {
|
||||
return URL(string: escapedFilename, relativeTo: relative)
|
||||
@@ -186,5 +185,5 @@ class ArchiveItem: CustomStringConvertible {
|
||||
return URL(string: escapedFilename)
|
||||
}
|
||||
|
||||
let mimeType = "application/octet-stream"
|
||||
let mimeType = "application/octet-stream";
|
||||
}
|
||||
@@ -5,149 +5,150 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
let maxVersionsInFeed = 5
|
||||
let maxVersionsInFeed = 5;
|
||||
|
||||
func findElement(name: String, parent: XMLElement) -> XMLElement? {
|
||||
if let found = try? parent.nodes(forXPath: name) {
|
||||
if found.count > 0 {
|
||||
if let element = found[0] as? XMLElement {
|
||||
return element
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return nil;
|
||||
}
|
||||
|
||||
func findOrCreateElement(name: String, parent: XMLElement) -> XMLElement {
|
||||
if let element = findElement(name: name, parent: parent) {
|
||||
return element
|
||||
return element;
|
||||
}
|
||||
let element = XMLElement(name: name)
|
||||
parent.addChild(element)
|
||||
return element
|
||||
let element = XMLElement(name: name);
|
||||
parent.addChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
func text(_ text: String) -> XMLNode {
|
||||
return XMLNode.text(withStringValue: text) as! XMLNode
|
||||
}
|
||||
|
||||
|
||||
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
|
||||
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent;
|
||||
|
||||
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
|
||||
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle";
|
||||
|
||||
var doc: XMLDocument
|
||||
var doc: XMLDocument;
|
||||
do {
|
||||
let options: XMLNode.Options = [
|
||||
XMLNode.Options.nodeLoadExternalEntitiesNever,
|
||||
XMLNode.Options.nodePreserveCDATA,
|
||||
XMLNode.Options.nodePreserveWhitespace,
|
||||
]
|
||||
doc = try XMLDocument(contentsOf: appcastDestPath, options: options)
|
||||
];
|
||||
doc = try XMLDocument(contentsOf: appcastDestPath, options: options);
|
||||
} catch {
|
||||
let root = XMLElement(name: "rss")
|
||||
root.addAttribute(XMLNode.attribute(withName: "xmlns:sparkle", stringValue: sparkleNS) as! XMLNode)
|
||||
root.addAttribute(XMLNode.attribute(withName: "version", stringValue: "2.0") as! XMLNode)
|
||||
doc = XMLDocument(rootElement: root)
|
||||
doc.isStandalone = true
|
||||
let root = XMLElement(name: "rss");
|
||||
root.addAttribute(XMLNode.attribute(withName: "xmlns:sparkle", stringValue: sparkleNS) as! XMLNode);
|
||||
root.addAttribute(XMLNode.attribute(withName: "version", stringValue: "2.0") as! XMLNode);
|
||||
doc = XMLDocument(rootElement: root);
|
||||
doc.isStandalone = true;
|
||||
}
|
||||
|
||||
var channel: XMLElement
|
||||
var channel: XMLElement;
|
||||
|
||||
let rootNodes = try doc.nodes(forXPath: "/rss")
|
||||
let rootNodes = try doc.nodes(forXPath: "/rss");
|
||||
if rootNodes.count != 1 {
|
||||
throw makeError(code: .appcastError, "Weird XML? \(appcastDestPath.path)")
|
||||
throw makeError(code: .appcastError, "Weird XML? \(appcastDestPath.path)");
|
||||
}
|
||||
let root = rootNodes[0] as! XMLElement
|
||||
let channelNodes = try root.nodes(forXPath: "channel")
|
||||
let channelNodes = try root.nodes(forXPath: "channel");
|
||||
if channelNodes.count > 0 {
|
||||
channel = channelNodes[0] as! XMLElement
|
||||
channel = channelNodes[0] as! XMLElement;
|
||||
} else {
|
||||
channel = XMLElement(name: "channel")
|
||||
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement)
|
||||
root.addChild(channel)
|
||||
channel = XMLElement(name: "channel");
|
||||
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement);
|
||||
root.addChild(channel);
|
||||
}
|
||||
|
||||
var numItems = 0
|
||||
var numItems = 0;
|
||||
for update in updates {
|
||||
var item: XMLElement
|
||||
let existingItems = try channel.nodes(forXPath: "item[enclosure[@sparkle:version=\"\(update.version)\"]]")
|
||||
let createNewItem = existingItems.count == 0
|
||||
var item: XMLElement;
|
||||
let existingItems = try channel.nodes(forXPath: "item[enclosure[@sparkle:version=\"\(update.version)\"]]");
|
||||
let createNewItem = existingItems.count == 0;
|
||||
|
||||
// Update all old items, but aim for less than 5 in new feeds
|
||||
if createNewItem && numItems >= maxVersionsInFeed {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
numItems += 1
|
||||
numItems += 1;
|
||||
|
||||
if createNewItem {
|
||||
item = XMLElement.element(withName: "item") as! XMLElement
|
||||
channel.addChild(item)
|
||||
item = XMLElement.element(withName: "item") as! XMLElement;
|
||||
channel.addChild(item);
|
||||
} else {
|
||||
item = existingItems[0] as! XMLElement
|
||||
item = existingItems[0] as! XMLElement;
|
||||
}
|
||||
|
||||
if nil == findElement(name: "title", parent: item) {
|
||||
item.addChild(XMLElement.element(withName: "title", stringValue: update.shortVersion) as! XMLElement)
|
||||
item.addChild(XMLElement.element(withName: "title", stringValue: update.shortVersion) as! XMLElement);
|
||||
}
|
||||
if nil == findElement(name: "pubDate", parent: item) {
|
||||
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement)
|
||||
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement);
|
||||
}
|
||||
|
||||
if let html = update.releaseNotesHTML {
|
||||
let descElement = findOrCreateElement(name: "description", parent: item)
|
||||
let cdata = XMLNode(kind: .text, options: .nodeIsCDATA)
|
||||
cdata.stringValue = html
|
||||
descElement.setChildren([cdata])
|
||||
let descElement = findOrCreateElement(name: "description", parent: item);
|
||||
let cdata = XMLNode(kind:.text, options:.nodeIsCDATA);
|
||||
cdata.stringValue = html;
|
||||
descElement.setChildren([cdata]);
|
||||
}
|
||||
|
||||
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item)
|
||||
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item);
|
||||
if nil == minVer {
|
||||
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement
|
||||
item.addChild(minVer!)
|
||||
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement;
|
||||
item.addChild(minVer!);
|
||||
}
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)])
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)]);
|
||||
|
||||
let relElement = findElement(name: SUAppcastElementReleaseNotesLink, parent: item)
|
||||
let relElement = findElement(name: SUAppcastElementReleaseNotesLink, parent: item);
|
||||
if let url = update.releaseNotesURL {
|
||||
if nil == relElement {
|
||||
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement)
|
||||
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement);
|
||||
}
|
||||
} else if let childIndex = relElement?.index {
|
||||
item.removeChild(at: childIndex)
|
||||
item.removeChild(at: childIndex);
|
||||
}
|
||||
|
||||
var enclosure = findElement(name: "enclosure", parent: item)
|
||||
var enclosure = findElement(name: "enclosure", parent: item);
|
||||
if nil == enclosure {
|
||||
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement
|
||||
item.addChild(enclosure!)
|
||||
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement;
|
||||
item.addChild(enclosure!);
|
||||
}
|
||||
|
||||
guard let archiveURL = update.archiveURL?.absoluteString else {
|
||||
throw makeError(code: .appcastError, "Bad archive name or feed URL")
|
||||
}
|
||||
throw makeError(code: .appcastError, "Bad archive name or feed URL");
|
||||
};
|
||||
var attributes = [
|
||||
XMLNode.attribute(withName: "url", stringValue: archiveURL) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeVersion, uri: sparkleNS, stringValue: update.version) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeShortVersionString, uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "length", stringValue: String(update.fileSize)) as! XMLNode,
|
||||
XMLNode.attribute(withName: "type", stringValue: update.mimeType) as! XMLNode,
|
||||
]
|
||||
];
|
||||
if let sig = update.edSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
if let sig = update.dsaSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
enclosure!.attributes = attributes
|
||||
enclosure!.attributes = attributes;
|
||||
|
||||
if update.deltas.count > 0 {
|
||||
var deltas = findElement(name: SUAppcastElementDeltas, parent: item)
|
||||
var deltas = findElement(name: SUAppcastElementDeltas, parent: item);
|
||||
if nil == deltas {
|
||||
deltas = XMLElement.element(withName: SUAppcastElementDeltas, uri: sparkleNS) as? XMLElement
|
||||
item.addChild(deltas!)
|
||||
deltas = XMLElement.element(withName: SUAppcastElementDeltas, uri: sparkleNS) as? XMLElement;
|
||||
item.addChild(deltas!);
|
||||
} else {
|
||||
deltas!.setChildren([])
|
||||
deltas!.setChildren([]);
|
||||
}
|
||||
for delta in update.deltas {
|
||||
var attributes = [
|
||||
@@ -157,20 +158,20 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
XMLNode.attribute(withName: SUAppcastAttributeDeltaFrom, uri: sparkleNS, stringValue: delta.fromVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "length", stringValue: String(delta.fileSize)) as! XMLNode,
|
||||
XMLNode.attribute(withName: "type", stringValue: "application/octet-stream") as! XMLNode,
|
||||
]
|
||||
];
|
||||
if let sig = delta.edSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
if let sig = delta.dsaSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
deltas!.addChild(XMLNode.element(withName: "enclosure", children: nil, attributes: attributes) as! XMLElement)
|
||||
deltas!.addChild(XMLNode.element(withName: "enclosure", children: nil, attributes: attributes) as! XMLElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let options: XMLNode.Options = [.nodeCompactEmptyElement, .nodePrettyPrint]
|
||||
let docData = doc.xmlData(options: options)
|
||||
_ = try XMLDocument(data: docData, options: XMLNode.Options()); // Verify that it was generated correctly, which does not always happen!
|
||||
try docData.write(to: appcastDestPath)
|
||||
let options: XMLNode.Options = [.nodeCompactEmptyElement, .nodePrettyPrint];
|
||||
let docData = doc.xmlData(options:options);
|
||||
let _ = try XMLDocument(data: docData, options:XMLNode.Options()); // Verify that it was generated correctly, which does not always happen!
|
||||
try docData.write(to: appcastDestPath);
|
||||
}
|
||||
@@ -6,39 +6,39 @@
|
||||
import Foundation
|
||||
|
||||
struct PrivateKeys {
|
||||
var privateDSAKey: SecKey?
|
||||
var privateEdKey: Data?
|
||||
var publicEdKey: Data?
|
||||
var privateDSAKey: SecKey?;
|
||||
var privateEdKey: Data?;
|
||||
var publicEdKey: Data?;
|
||||
|
||||
init(privateDSAKey: SecKey?, privateEdKey: Data?, publicEdKey: Data?) {
|
||||
self.privateDSAKey = privateDSAKey
|
||||
self.privateEdKey = privateEdKey
|
||||
self.publicEdKey = publicEdKey
|
||||
self.privateDSAKey = privateDSAKey;
|
||||
self.privateEdKey = privateEdKey;
|
||||
self.publicEdKey = publicEdKey;
|
||||
}
|
||||
}
|
||||
|
||||
func loadPrivateDSAKey(at privateKeyURL: URL) throws -> SecKey {
|
||||
let data = try Data(contentsOf: privateKeyURL)
|
||||
let data = try Data(contentsOf: privateKeyURL);
|
||||
|
||||
var cfitems: CFArray?
|
||||
var format = SecExternalFormat.formatOpenSSL
|
||||
var type = SecExternalItemType.itemTypePrivateKey
|
||||
var cfitems: CFArray? = nil;
|
||||
var format = SecExternalFormat.formatOpenSSL;
|
||||
var type = SecExternalItemType.itemTypePrivateKey;
|
||||
|
||||
let status = SecItemImport(data as CFData, nil, &format, &type, SecItemImportExportFlags(rawValue: UInt32(0)), nil, nil, &cfitems)
|
||||
if status != errSecSuccess || cfitems == nil {
|
||||
print("Private DSA key file", privateKeyURL.path, "exists, but it could not be read. SecItemImport error", status)
|
||||
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
|
||||
let status = SecItemImport(data as CFData, nil, &format, &type, SecItemImportExportFlags(rawValue: UInt32(0)), nil, nil, &cfitems);
|
||||
if (status != errSecSuccess || cfitems == nil) {
|
||||
print("Private DSA key file", privateKeyURL.path, "exists, but it could not be read. SecItemImport error", status);
|
||||
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil);
|
||||
}
|
||||
|
||||
if format != SecExternalFormat.formatOpenSSL || type != SecExternalItemType.itemTypePrivateKey {
|
||||
throw makeError(code: .signatureError, "Not an OpensSSL private key \(format) \(type)")
|
||||
if (format != SecExternalFormat.formatOpenSSL || type != SecExternalItemType.itemTypePrivateKey) {
|
||||
throw makeError(code: .signatureError, "Not an OpensSSL private key \(format) \(type)");
|
||||
}
|
||||
|
||||
return (cfitems! as NSArray)[0] as! SecKey
|
||||
return (cfitems! as NSArray)[0] as! SecKey;
|
||||
}
|
||||
|
||||
func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) throws -> SecKey {
|
||||
var keychain: SecKeychain?
|
||||
var keychain: SecKeychain? = nil
|
||||
|
||||
guard SecKeychainOpen(keychainURL.path, &keychain) == errSecSuccess, keychain != nil else {
|
||||
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
|
||||
@@ -50,10 +50,10 @@ func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) t
|
||||
kSecAttrLabel: keyName as CFString,
|
||||
kSecMatchLimit: kSecMatchLimitOne,
|
||||
kSecUseKeychain: keychain!,
|
||||
kSecReturnRef: kCFBooleanTrue,
|
||||
kSecReturnRef: kCFBooleanTrue
|
||||
]
|
||||
|
||||
var item: CFTypeRef?
|
||||
var item: CFTypeRef? = nil
|
||||
guard SecItemCopyMatching(query as CFDictionary, &item) == errSecSuccess, item != nil else {
|
||||
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
|
||||
}
|
||||
@@ -63,52 +63,52 @@ func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) t
|
||||
|
||||
func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
|
||||
|
||||
var error: Unmanaged<CFError>?
|
||||
var error: Unmanaged<CFError>?;
|
||||
|
||||
let stream = InputStream(fileAtPath: path.path)!
|
||||
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream)
|
||||
let stream = InputStream(fileAtPath:path.path)!;
|
||||
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream);
|
||||
|
||||
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil)
|
||||
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil);
|
||||
guard let dataSignTransform = SecSignTransformCreate(privateDSAKey, &error) else {
|
||||
print("can't use the key")
|
||||
throw error!.takeRetainedValue()
|
||||
print("can't use the key");
|
||||
throw error!.takeRetainedValue();
|
||||
}
|
||||
|
||||
let group = SecTransformCreateGroupTransform()
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error)
|
||||
if error != nil {
|
||||
throw error!.takeRetainedValue()
|
||||
let group = SecTransformCreateGroupTransform();
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error != nil) {
|
||||
throw error!.takeRetainedValue();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataSignTransform, kSecTransformInputAttributeName, group, &error)
|
||||
if error != nil {
|
||||
throw error!.takeRetainedValue()
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataSignTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error != nil) {
|
||||
throw error!.takeRetainedValue();
|
||||
}
|
||||
|
||||
let result = SecTransformExecute(group, &error)
|
||||
if error != nil {
|
||||
throw error!.takeRetainedValue()
|
||||
let result = SecTransformExecute(group, &error);
|
||||
if (error != nil) {
|
||||
throw error!.takeRetainedValue();
|
||||
}
|
||||
guard let resultData = result as? Data else {
|
||||
throw makeError(code: .signatureError, "SecTransformExecute returned non-data")
|
||||
throw makeError(code: .signatureError, "SecTransformExecute returned non-data");
|
||||
}
|
||||
return resultData.base64EncodedString()
|
||||
return resultData.base64EncodedString();
|
||||
}
|
||||
|
||||
func edSignature(path: URL, publicEdKey: Data, privateEdKey: Data) throws -> String {
|
||||
assert(publicEdKey.count == 32)
|
||||
assert(privateEdKey.count == 64)
|
||||
let data = try Data.init(contentsOf: path, options: .mappedIfSafe)
|
||||
let len = data.count
|
||||
var output = Data(count: 64)
|
||||
let data = try Data.init(contentsOf: path, options: .mappedIfSafe);
|
||||
let len = data.count;
|
||||
var output = Data(count: 64);
|
||||
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
|
||||
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
|
||||
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
return output.base64EncodedString()
|
||||
});
|
||||
return output.base64EncodedString();
|
||||
}
|
||||
@@ -5,105 +5,105 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
|
||||
let fileManager = FileManager.default
|
||||
let tempDir = archiveDestDir.appendingPathExtension("tmp")
|
||||
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent)
|
||||
func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
|
||||
let fileManager = FileManager.default;
|
||||
let tempDir = archiveDestDir.appendingPathExtension("tmp");
|
||||
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent);
|
||||
|
||||
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:])
|
||||
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:]);
|
||||
|
||||
do {
|
||||
do {
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy)
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy);
|
||||
} catch {
|
||||
try fileManager.copyItem(at: itemPath, to: itemCopy)
|
||||
try fileManager.copyItem(at: itemPath, to: itemCopy);
|
||||
}
|
||||
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath: nil, decryptionPassword: nil) {
|
||||
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath:nil, decryptionPassword:nil) {
|
||||
unarchiver.unarchive(completionBlock: { (error: Error?) in
|
||||
if error != nil {
|
||||
callback(error)
|
||||
return
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
|
||||
_ = try? fileManager.removeItem(at: itemCopy)
|
||||
_ = try? fileManager.removeItem(at: itemCopy);
|
||||
do {
|
||||
try fileManager.moveItem(at: tempDir, to: archiveDestDir)
|
||||
callback(nil)
|
||||
try fileManager.moveItem(at: tempDir, to: archiveDestDir);
|
||||
callback(nil);
|
||||
} catch {
|
||||
callback(error)
|
||||
callback(error);
|
||||
}
|
||||
}, progressBlock: nil)
|
||||
} else {
|
||||
_ = try? fileManager.removeItem(at: itemCopy)
|
||||
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"))
|
||||
_ = try? fileManager.removeItem(at: itemCopy);
|
||||
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"));
|
||||
}
|
||||
} catch {
|
||||
_ = try? fileManager.removeItem(at: tempDir)
|
||||
callback(error)
|
||||
_ = try? fileManager.removeItem(at: tempDir);
|
||||
callback(error);
|
||||
}
|
||||
}
|
||||
|
||||
func unarchiveUpdates(archivesSourceDir: URL, archivesDestDir: URL, verbose: Bool) throws -> [ArchiveItem] {
|
||||
if verbose {
|
||||
print("Unarchiving to temp directory", archivesDestDir.path)
|
||||
print("Unarchiving to temp directory", archivesDestDir.path);
|
||||
}
|
||||
|
||||
let group = DispatchGroup()
|
||||
let group = DispatchGroup();
|
||||
|
||||
let fileManager = FileManager.default
|
||||
let fileManager = FileManager.default;
|
||||
|
||||
var unarchived: [ArchiveItem] = []
|
||||
var unarchived:[ArchiveItem] = [];
|
||||
|
||||
let dir = try fileManager.contentsOfDirectory(atPath: archivesSourceDir.path)
|
||||
var running = 0
|
||||
let dir = try fileManager.contentsOfDirectory(atPath: archivesSourceDir.path);
|
||||
var running = 0;
|
||||
for item in dir.filter({ !$0.hasPrefix(".") && !$0.hasSuffix(".delta") && !$0.hasSuffix(".xml") && !$0.hasSuffix(".html") }) {
|
||||
let itemPath = archivesSourceDir.appendingPathComponent(item)
|
||||
let archiveDestDir = archivesDestDir.appendingPathComponent(itemPath.lastPathComponent)
|
||||
let itemPath = archivesSourceDir.appendingPathComponent(item);
|
||||
let archiveDestDir = archivesDestDir.appendingPathComponent(itemPath.lastPathComponent);
|
||||
|
||||
var isDir: ObjCBool = false
|
||||
if fileManager.fileExists(atPath: itemPath.path, isDirectory: &isDir) && isDir.boolValue {
|
||||
continue
|
||||
var isDir:ObjCBool = false;
|
||||
if (fileManager.fileExists(atPath: itemPath.path, isDirectory: &isDir) && isDir.boolValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let addItem = {
|
||||
do {
|
||||
let item = try ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir)
|
||||
let item = try ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir);
|
||||
if verbose {
|
||||
print("Found archive", item)
|
||||
print("Found archive", item);
|
||||
}
|
||||
objc_sync_enter(unarchived)
|
||||
unarchived.append(item)
|
||||
objc_sync_exit(unarchived)
|
||||
objc_sync_enter(unarchived);
|
||||
unarchived.append(item);
|
||||
objc_sync_exit(unarchived);
|
||||
} catch {
|
||||
if verbose {
|
||||
print("Skipped", item, error)
|
||||
print("Skipped", item, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if fileManager.fileExists(atPath: archiveDestDir.path) {
|
||||
addItem()
|
||||
addItem();
|
||||
} else {
|
||||
group.enter()
|
||||
group.enter();
|
||||
unarchive(itemPath: itemPath, archiveDestDir: archiveDestDir) { (error: Error?) in
|
||||
if let error = error {
|
||||
print("Could not unarchive", itemPath.path, error)
|
||||
print("Could not unarchive", itemPath.path, error);
|
||||
} else {
|
||||
addItem()
|
||||
addItem();
|
||||
}
|
||||
group.leave()
|
||||
group.leave();
|
||||
}
|
||||
}
|
||||
|
||||
// Crude limit of concurrency
|
||||
running += 1
|
||||
running += 1;
|
||||
if running >= 8 {
|
||||
running = 0
|
||||
group.wait()
|
||||
running = 0;
|
||||
group.wait();
|
||||
}
|
||||
}
|
||||
|
||||
group.wait()
|
||||
group.wait();
|
||||
|
||||
return unarchived
|
||||
return unarchived;
|
||||
}
|
||||
+26
-24
@@ -8,10 +8,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
var verbose = false
|
||||
var verbose = false;
|
||||
|
||||
func printUsage() {
|
||||
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent
|
||||
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent;
|
||||
print("Generate appcast from a directory of Sparkle update archives\n",
|
||||
"Usage:\n",
|
||||
" \(command) <directory with update files>\n",
|
||||
@@ -26,33 +26,33 @@ func printUsage() {
|
||||
}
|
||||
|
||||
func loadPrivateKeys(_ privateDSAKey: SecKey?) -> PrivateKeys {
|
||||
var privateEdKey: Data?
|
||||
var publicEdKey: Data?
|
||||
var item: CFTypeRef?
|
||||
var privateEdKey: Data?;
|
||||
var publicEdKey: Data?;
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item)
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
privateEdKey = keys[0..<64]
|
||||
publicEdKey = keys[64...]
|
||||
privateEdKey = keys[0..<64];
|
||||
publicEdKey = keys[64...];
|
||||
} else {
|
||||
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool")
|
||||
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool");
|
||||
}
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey)
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey);
|
||||
}
|
||||
|
||||
func main() {
|
||||
let args = CommandLine.arguments
|
||||
let args = CommandLine.arguments;
|
||||
if args.count < 2 {
|
||||
printUsage()
|
||||
exit(1)
|
||||
}
|
||||
|
||||
var privateDSAKey: SecKey?
|
||||
var privateDSAKey: SecKey? = nil;
|
||||
|
||||
// this was typical usage for DSA keys
|
||||
if args.count == 3 || (args.count == 4 && args[1] == "-f") {
|
||||
@@ -80,7 +80,8 @@ func main() {
|
||||
|
||||
keyName = args[2]
|
||||
keychainURL = URL(fileURLWithPath: args[4])
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if args[3] != "-n" {
|
||||
printUsage()
|
||||
exit(1)
|
||||
@@ -96,7 +97,8 @@ func main() {
|
||||
print("Unable to load DSA private key '\(keyName)' from keychain at", keychainURL.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
} else if args.count != 2 {
|
||||
}
|
||||
else if args.count != 2 {
|
||||
printUsage()
|
||||
exit(1)
|
||||
}
|
||||
@@ -105,22 +107,22 @@ func main() {
|
||||
let keys = loadPrivateKeys(privateDSAKey)
|
||||
|
||||
do {
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose: verbose)
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose:verbose);
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir)
|
||||
try writeAppcast(appcastDestPath: appcastDestPath, updates: updates)
|
||||
print("Written", appcastDestPath.path, "based on", updates.count, "updates")
|
||||
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
|
||||
try writeAppcast(appcastDestPath:appcastDestPath, updates:updates);
|
||||
print("Written", appcastDestPath.path, "based on", updates.count, "updates");
|
||||
}
|
||||
} catch {
|
||||
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error)
|
||||
exit(1)
|
||||
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.global().async(execute: {
|
||||
main()
|
||||
CFRunLoopStop(CFRunLoopGetMain())
|
||||
})
|
||||
main();
|
||||
CFRunLoopStop(CFRunLoopGetMain());
|
||||
});
|
||||
|
||||
CFRunLoopRun()
|
||||
CFRunLoopRun();
|
||||
+36
-32
@@ -10,49 +10,52 @@ import Foundation
|
||||
import Security
|
||||
|
||||
func findPublicKey() -> Data? {
|
||||
var item: CFTypeRef?
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item)
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
print("OK! Read the existing key saved in the Keychain.")
|
||||
print("OK! Read the existing key saved in the Keychain.");
|
||||
return keys[64...]
|
||||
} else if res == errSecItemNotFound {
|
||||
return nil
|
||||
} else if res == errSecAuthFailed {
|
||||
print("\nERROR! Access denied. Can't check existing keys in the keychain.")
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
|
||||
} else if res == errSecUserCanceled {
|
||||
print("\nABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.")
|
||||
}
|
||||
else if res == errSecItemNotFound {
|
||||
return nil;
|
||||
}
|
||||
else if res == errSecAuthFailed {
|
||||
print("\nERROR! Access denied. Can't check existing keys in the keychain.");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
}
|
||||
else if res == errSecUserCanceled {
|
||||
print("\nABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
|
||||
} else if res == errSecInteractionNotAllowed {
|
||||
print("\nERROR! The operating system has blocked access to the Keychain.")
|
||||
print("\nERROR! The operating system has blocked access to the Keychain.");
|
||||
} else {
|
||||
print("\nERROR! Unable to access existing item in the Keychain", res, "(you can look it up at osstatus.com)")
|
||||
print("\nERROR! Unable to access existing item in the Keychain", res, "(you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
|
||||
func generateKeyPair() -> Data {
|
||||
var seed = Data(count: 32)
|
||||
var publicEdKey = Data(count: 32)
|
||||
var privateEdKey = Data(count: 64)
|
||||
var seed = Data(count: 32);
|
||||
var publicEdKey = Data(count: 32);
|
||||
var privateEdKey = Data(count: 64);
|
||||
|
||||
if !seed.withUnsafeMutableBytes { (seed: UnsafeMutablePointer<UInt8>) in 0 == ed25519_create_seed(seed)} {
|
||||
print("\nERROR: Unable to initialize random seed")
|
||||
print("\nERROR: Unable to initialize random seed");
|
||||
exit(1)
|
||||
}
|
||||
|
||||
seed.withUnsafeBytes({(seed: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeMutableBytes({(publicEdKey: UnsafeMutablePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeMutableBytes({(privateEdKey: UnsafeMutablePointer<UInt8>) in
|
||||
ed25519_create_keypair(publicEdKey, privateEdKey, seed)
|
||||
})
|
||||
})
|
||||
})
|
||||
ed25519_create_keypair(publicEdKey, privateEdKey, seed);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
let bothKeys = privateEdKey + publicEdKey; // public key can't be derived from the private one
|
||||
let query = [
|
||||
@@ -68,23 +71,24 @@ func generateKeyPair() -> Data {
|
||||
kSecAttrLabel as String: "Private key for signing Sparkle updates",
|
||||
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(publicEdKey.base64EncodedString())",
|
||||
kSecAttrDescription as String: "private key",
|
||||
] as CFDictionary
|
||||
let res = SecItemAdd(query, nil)
|
||||
] as CFDictionary;
|
||||
let res = SecItemAdd(query, nil);
|
||||
|
||||
if res == errSecSuccess {
|
||||
print("OK! A new key has been generated and saved in the Keychain.")
|
||||
} else if res == errSecDuplicateItem {
|
||||
print("\nERROR: You already have a previously generated key in the Keychain")
|
||||
} else if res == errSecAuthFailed {
|
||||
print("\nERROR: System denied access to the Keychain. Unable to save the new key")
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
|
||||
} else {
|
||||
print("\nERROR: The key could not be saved to the Keychain. error: \(res) (you can look it up at osstatus.com)")
|
||||
print("OK! A new key has been generated and saved in the Keychain.");
|
||||
}
|
||||
exit(1)
|
||||
else if res == errSecDuplicateItem {
|
||||
print("\nERROR: You already have a previously generated key in the Keychain");
|
||||
} else if res == errSecAuthFailed {
|
||||
print("\nERROR: System denied access to the Keychain. Unable to save the new key");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
} else {
|
||||
print("\nERROR: The key could not be saved to the Keychain. error: \(res) (you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print("This tool uses macOS Keychain to store the Sparkle private key.")
|
||||
print("If the Keychain prompts you for permission, please allow it.")
|
||||
let pubKey = findPublicKey() ?? generateKeyPair()
|
||||
let pubKey = findPublicKey() ?? generateKeyPair();
|
||||
print("\nIn your app's Info.plist set SUPublicEDKey to:\n\(pubKey.base64EncodedString())\n")
|
||||
+26
-23
@@ -10,27 +10,30 @@ import Foundation
|
||||
import Security
|
||||
|
||||
func findKeys() -> (Data, Data) {
|
||||
var item: CFTypeRef?
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item)
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
return (keys[0..<64], keys[64..<(64+32)])
|
||||
} else if res == errSecItemNotFound {
|
||||
print("ERROR! Signing key not found. Please run generate_keys tool first.")
|
||||
} else if res == errSecAuthFailed {
|
||||
print("ERROR! Access denied. Can't get keys from the keychain.")
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
|
||||
} else if res == errSecUserCanceled {
|
||||
print("ABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.")
|
||||
}
|
||||
else if res == errSecItemNotFound {
|
||||
print("ERROR! Signing key not found. Please run generate_keys tool first.");
|
||||
}
|
||||
else if res == errSecAuthFailed {
|
||||
print("ERROR! Access denied. Can't get keys from the keychain.");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
}
|
||||
else if res == errSecUserCanceled {
|
||||
print("ABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
|
||||
} else if res == errSecInteractionNotAllowed {
|
||||
print("ERROR! The operating system has blocked access to the Keychain.")
|
||||
print("ERROR! The operating system has blocked access to the Keychain.");
|
||||
} else {
|
||||
print("ERROR! Unable to access required key in the Keychain", res, "(you can look it up at osstatus.com)")
|
||||
print("ERROR! Unable to access required key in the Keychain", res, "(you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
@@ -38,32 +41,32 @@ func findKeys() -> (Data, Data) {
|
||||
func edSignature(data: Data, publicEdKey: Data, privateEdKey: Data) -> String {
|
||||
assert(publicEdKey.count == 32)
|
||||
assert(privateEdKey.count == 64)
|
||||
let len = data.count
|
||||
var output = Data(count: 64)
|
||||
let len = data.count;
|
||||
var output = Data(count: 64);
|
||||
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
|
||||
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
|
||||
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
return output.base64EncodedString()
|
||||
});
|
||||
return output.base64EncodedString();
|
||||
}
|
||||
|
||||
let args = CommandLine.arguments
|
||||
let args = CommandLine.arguments;
|
||||
if args.count != 2 {
|
||||
print("Usage: \(args[0]) <archive to sign>\nPrivavte EdDSA (ed25519) key is automatically read from the Keychain.\n")
|
||||
print("Usage: \(args[0]) <archive to sign>\nPrivavte EdDSA (ed25519) key is automatically read from the Keychain.\n");
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let(priv, pub) = findKeys()
|
||||
let(priv, pub) = findKeys();
|
||||
|
||||
do {
|
||||
let data = try Data.init(contentsOf: URL.init(fileURLWithPath: args[1]), options: .mappedIfSafe)
|
||||
let sig = edSignature(data: data, publicEdKey: pub, privateEdKey: priv)
|
||||
print("sparkle:edSignature=\"\(sig)\" length=\"\(data.count)\"")
|
||||
let data = try Data.init(contentsOf: URL.init(fileURLWithPath: args[1]), options: .mappedIfSafe);
|
||||
let sig = edSignature(data:data , publicEdKey: pub, privateEdKey: priv);
|
||||
print("sparkle:edSignature=\"\(sig)\" length=\"\(data.count)\"");
|
||||
} catch {
|
||||
print("ERROR: ", error)
|
||||
}
|
||||
Reference in new issue
Block a user