mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f70c2a15b1 | ||
|
|
4eb518de7e | ||
|
|
077c64419f | ||
|
|
1195d4b5d2 | ||
|
|
c7a7704f3b | ||
|
|
64af6d04c2 | ||
|
|
0af27ea783 | ||
|
|
c36413ce46 | ||
|
|
13b9081873 | ||
|
|
3dccca8044 | ||
|
|
ed3eab64d2 | ||
|
|
ee257c4070 | ||
|
|
bfec7a82c0 | ||
|
|
4cd472abe6 | ||
|
|
39268a13e5 | ||
|
|
4864dfb5aa | ||
|
|
71125e3d16 | ||
|
|
779d16e5a7 | ||
|
|
ee2e7fb46b | ||
|
|
d350cf33e0 | ||
|
|
09889d01b1 |
No files matched your search
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at kornel+sparkle@geekhood.net. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
+8
-4
@@ -1,4 +1,4 @@
|
||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) [](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) [](https://github.com/Carthage/Carthage) []() <a href="https://www.maxcdn.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-MaxCDN-orange.svg" alt="sponsored by: MaxCDN"></a>
|
||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) [](https://github.com/Carthage/Carthage) []() <a href="https://www.maxcdn.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-MaxCDN-orange.svg" alt="sponsored by: MaxCDN"></a>
|
||||
|
||||
An easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
@@ -7,8 +7,8 @@ An easy-to-use software update framework for Cocoa developers.
|
||||
## Changes since 1.5b
|
||||
|
||||
* Up-to-date with 10.11 SDK and Xcode 7. Supports macOS 10.7+.
|
||||
* Important security fixes.
|
||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
@@ -17,15 +17,15 @@ An easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
## Features
|
||||
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* True self-updating—the user can choose to automatically download and install all updates.
|
||||
* Displays a detailed progress window to the user.
|
||||
* Supports authentication for installing in secure locations.
|
||||
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
|
||||
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
|
||||
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Uses RSS-based appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Deep delegate support to make Sparkle work exactly as you need.
|
||||
* Optionally sends system information to the server when checking for updates.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
||||
@@ -48,6 +48,10 @@ If you are adding a symbol to the public API you must decorate the declaration w
|
||||
|
||||
Alternatively, build the Distribution scheme in the Xcode UI.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
We pledge to have an open and welcoming environment. See our [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Project Sponsor
|
||||
|
||||
[MaxCDN](https://www.maxcdn.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.14.0"
|
||||
s.version = "1.15.0"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "http://sparkle-project.org"
|
||||
|
||||
@@ -189,6 +189,7 @@
|
||||
722954CA1D04EA6000ECF9CA /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
722954CB1D04EA6900ECF9CA /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
|
||||
722954CC1D04EA7000ECF9CA /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; };
|
||||
723A920E1D722438004A9DED /* SUSpotlightImporterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 723A920D1D722438004A9DED /* SUSpotlightImporterTest.swift */; };
|
||||
723B252D1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
|
||||
723B252E1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
|
||||
723B252F1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
|
||||
@@ -677,6 +678,7 @@
|
||||
722954C21D04E66F00ECF9CA /* SUFileOperationConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileOperationConstants.h; sourceTree = "<group>"; };
|
||||
722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileOperationConstants.m; sourceTree = "<group>"; };
|
||||
722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigFileop.xcconfig; sourceTree = "<group>"; };
|
||||
723A920D1D722438004A9DED /* SUSpotlightImporterTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUSpotlightImporterTest.swift; sourceTree = "<group>"; };
|
||||
723B252B1CEAB3A600909873 /* bscommon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bscommon.c; sourceTree = "<group>"; };
|
||||
723B252C1CEAB3A600909873 /* bscommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bscommon.h; sourceTree = "<group>"; };
|
||||
7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = "<group>"; };
|
||||
@@ -1024,6 +1026,7 @@
|
||||
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */,
|
||||
72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */,
|
||||
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */,
|
||||
723A920D1D722438004A9DED /* SUSpotlightImporterTest.swift */,
|
||||
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */,
|
||||
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */,
|
||||
61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */,
|
||||
@@ -1727,6 +1730,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
723A920E1D722438004A9DED /* SUSpotlightImporterTest.swift in Sources */,
|
||||
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */,
|
||||
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */,
|
||||
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */,
|
||||
|
||||
Vendored
+10
-8
@@ -284,7 +284,7 @@
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
|
||||
@@ -293,6 +293,8 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
// Modern packages are not distributed as bundles and are code signed differently than regular applications
|
||||
if (isPackage) {
|
||||
if (nil == publicDSAKey) {
|
||||
@@ -335,17 +337,17 @@
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath];
|
||||
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
|
||||
|
||||
if (dsaKeysMatch) {
|
||||
NSError *error = nil;
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) {
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(@"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 {
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
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) {
|
||||
@@ -355,7 +357,7 @@
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) {
|
||||
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(@"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;
|
||||
}
|
||||
@@ -404,7 +406,7 @@
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath] withPassword:self.updater.decryptionPassword];
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:self.updater.decryptionPassword];
|
||||
if (!unarchiver) {
|
||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
@@ -475,7 +477,7 @@
|
||||
{
|
||||
assert(self.updateItem);
|
||||
|
||||
if (![self validateUpdateDownloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature publicDSAKey:self.host.publicDSAKey])
|
||||
if (![self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature])
|
||||
{
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
|
||||
Vendored
+38
@@ -10,6 +10,7 @@
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@@ -20,6 +21,41 @@
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
// According to https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/MDImporters/Concepts/Troubleshooting.html
|
||||
// We should make sure mdimporter bundles have an up to date time in the event they were delta updated.
|
||||
// We used to invoke mdimport on the bundle but this is not a very good approach.
|
||||
// There's no need to do that for non-delta updates and for updates that contain no mdimporters.
|
||||
// Moreover, updating the timestamp on the mdimporter bundles is what developers have to do anyway when shipping their new update outside of Sparkle
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath
|
||||
{
|
||||
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:targetPath error:nil];
|
||||
NSString *rootType = [rootAttributes objectForKey:NSFileType];
|
||||
|
||||
if ([rootType isEqualToString:NSFileTypeDirectory]) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
|
||||
NSMutableArray *filesToUpdate = [[NSMutableArray alloc] init];
|
||||
for (NSURL *file in directoryEnumerator) {
|
||||
if ([file.pathExtension isEqualToString:@"mdimporter"]) {
|
||||
[filesToUpdate addObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
for (NSURL *file in filesToUpdate) {
|
||||
NSError *error = nil;
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:file error:&error]) {
|
||||
SULog(@"Error: During delta unarchiving, failed to touch %@", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
@autoreleasepool {
|
||||
@@ -29,6 +65,8 @@
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError);
|
||||
if (success) {
|
||||
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
|
||||
Vendored
+3
-4
@@ -12,10 +12,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
||||
+ (BOOL)hostApplicationIsCodeSigned;
|
||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath;
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
+29
-66
@@ -13,53 +13,46 @@
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecCodeRef hostCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
SecStaticCodeRef oldCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy host code %d", result);
|
||||
goto finally;
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle for update");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
|
||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
// Aditionally, there are several reasons to stay away from deep verification and to prefer DSA signing the download archive instead.
|
||||
// See https://github.com/sparkle-project/Sparkle/pull/523#commitcomment-17549302 and https://github.com/sparkle-project/Sparkle/issues/543
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
||||
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
@@ -70,61 +63,52 @@
|
||||
SULog(@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
CFRelease(requirementString);
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:hostCode label:@"host info"];
|
||||
|
||||
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
finally:
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (oldCode) CFRelease(oldCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == noErr);
|
||||
}
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not passed
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", applicationPath);
|
||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
finally:
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
return (result == noErr);
|
||||
@@ -150,35 +134,14 @@ static id valueOrNSNull(id value) {
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
{
|
||||
OSStatus result;
|
||||
SecCodeRef hostCode = NULL;
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) return NO;
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle");
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
@@ -190,7 +153,7 @@ static id valueOrNSNull(id value) {
|
||||
CFRelease(requirement);
|
||||
}
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
Vendored
+29
-1
@@ -11,6 +11,7 @@
|
||||
#import "SUSystemProfiler.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
@interface NSProcessInfo ()
|
||||
@@ -74,7 +75,34 @@
|
||||
// Note it's very well possible to have the bundle be writable but not be able to write into the parent directory
|
||||
// And if the bundle isn't writable, but we can write into the parent directory, we will still need to authorize to replace it
|
||||
NSString *bundlePath = [self bundlePath];
|
||||
return [[NSFileManager defaultManager] isWritableFileAtPath:bundlePath.stringByDeletingLastPathComponent] && [[NSFileManager defaultManager] isWritableFileAtPath:bundlePath];
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath.stringByDeletingLastPathComponent] || ![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Just because we have writability access does not mean we can set the correct owner/group silently
|
||||
// Test if we can set the owner/group on a temporarily created file
|
||||
// If we can, then we can probably perform an update without authorization
|
||||
// One place where this matters is if you copy and run an app from /tmp/
|
||||
|
||||
NSString *tempFilename = @"permission_test" ;
|
||||
|
||||
SUFileManager *suFileManager = [SUFileManager defaultManager];
|
||||
NSURL *tempDirectoryURL = [suFileManager makeTemporaryDirectoryWithPreferredName:tempFilename appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:NULL];
|
||||
|
||||
if (tempDirectoryURL == nil) {
|
||||
// I don't imagine this ever happening but in case it does, requesting authorization may be the better option
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSURL *tempFileURL = [tempDirectoryURL URLByAppendingPathComponent:tempFilename];
|
||||
|
||||
BOOL changeOwnerAndGroupSuccess =
|
||||
[[NSData data] writeToURL:tempFileURL atomically:NO] &&
|
||||
[suFileManager changeOwnerAndGroupOfItemAtRootURL:tempFileURL toMatchURL:self.bundle.bundleURL error:NULL];
|
||||
|
||||
[suFileManager removeItemAtURL:tempDirectoryURL error:NULL];
|
||||
|
||||
return changeOwnerAndGroupSuccess;
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
|
||||
Vendored
+1
-22
@@ -122,30 +122,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
SULog(@"mdimporting");
|
||||
|
||||
NSTask *mdimport = [[NSTask alloc] init];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:@[installationPath]];
|
||||
@try {
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException *launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Error: %@", [launchException description]);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
||||
+ (void)finishInstallationToPath:(NSString *)__unused installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
if (result) {
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completionHandler(nil);
|
||||
});
|
||||
|
||||
Vendored
+2
-1
@@ -98,8 +98,9 @@
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
[self showAlert:alert];
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
|
||||
Vendored
+1
-1
@@ -122,7 +122,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
-(void)checkIfConfiguredProperly {
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
BOOL isMainBundle = [self.host.bundle isEqualTo:[NSBundle mainBundle]];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.host.bundle.bundleURL];
|
||||
NSURL *feedURL = [self feedURL];
|
||||
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
|
||||
|
||||
@@ -11,19 +11,23 @@
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#define CALCULATOR_PATH @"/Applications/Calculator.app"
|
||||
|
||||
@interface SUCodeSigningVerifierTest : XCTestCase
|
||||
|
||||
@property (copy) NSString *notSignedAppPath;
|
||||
@property (copy) NSString *validSignedAppPath;
|
||||
@property (copy) NSString *invalidSignedAppPath;
|
||||
@property (copy) NSURL *notSignedAppURL;
|
||||
@property (copy) NSURL *validSignedAppURL;
|
||||
@property (copy) NSURL *invalidSignedAppURL;
|
||||
@property (copy) NSURL *calculatorCopyURL;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUCodeSigningVerifierTest
|
||||
|
||||
@synthesize notSignedAppPath = _notSignedAppPath;
|
||||
@synthesize validSignedAppPath = _validSignedAppPath;
|
||||
@synthesize invalidSignedAppPath = _invalidSignedAppPath;
|
||||
@synthesize notSignedAppURL = _notSignedAppURL;
|
||||
@synthesize validSignedAppURL = _validSignedAppURL;
|
||||
@synthesize invalidSignedAppURL = _invalidSignedAppURL;
|
||||
@synthesize calculatorCopyURL = _calculatorCopyURL;
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
@@ -31,30 +35,28 @@
|
||||
|
||||
NSBundle *unitTestBundle = [NSBundle bundleForClass:[self class]];
|
||||
NSString *unitTestBundleIdentifier = unitTestBundle.bundleIdentifier;
|
||||
NSString *zippedAppPath = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"];
|
||||
|
||||
NSString *zippedAppURL = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"];
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
|
||||
NSError *tempError = nil;
|
||||
NSURL *tempDir = [fileManager makeTemporaryDirectoryWithPreferredName:unitTestBundleIdentifier appropriateForDirectoryURL:[NSURL fileURLWithPath:zippedAppPath] error:&tempError];
|
||||
|
||||
NSURL *tempDir = [fileManager makeTemporaryDirectoryWithPreferredName:unitTestBundleIdentifier appropriateForDirectoryURL:[NSURL fileURLWithPath:zippedAppURL] error:&tempError];
|
||||
|
||||
if (tempDir == nil) {
|
||||
XCTFail(@"Failed to create temporary directory with error: %@", tempError);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *tempDirPath = tempDir.path;
|
||||
XCTAssertNotNil(tempDirPath);
|
||||
|
||||
|
||||
NSError *error = nil;
|
||||
if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDirPath withIntermediateDirectories:YES attributes:nil error:&error]) {
|
||||
if ([self unzip:zippedAppPath toPath:tempDirPath]) {
|
||||
self.notSignedAppPath = [tempDirPath stringByAppendingPathComponent:@"SparkleTestCodeSignApp.app"];
|
||||
if ([[NSFileManager defaultManager] createDirectoryAtURL:tempDir withIntermediateDirectories:YES attributes:nil error:&error]) {
|
||||
if ([self unzip:zippedAppURL toPath:tempDir.path]) {
|
||||
self.notSignedAppURL = [tempDir URLByAppendingPathComponent:@"SparkleTestCodeSignApp.app"];
|
||||
[self setupValidSignedApp];
|
||||
[self setupCalculatorCopy];
|
||||
[self setupInvalidSignedApp];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to unzip %@", zippedAppPath);
|
||||
NSLog(@"Failed to unzip %@", zippedAppURL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -65,56 +67,82 @@
|
||||
- (void)tearDown
|
||||
{
|
||||
[super tearDown];
|
||||
|
||||
if (self.notSignedAppPath) {
|
||||
NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:tempDir error:nil];
|
||||
|
||||
if (self.notSignedAppURL) {
|
||||
NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent];
|
||||
[[NSFileManager defaultManager] removeItemAtURL:tempDir error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupValidSignedApp
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent];
|
||||
NSString *signedAndValid = [tempDir stringByAppendingPathComponent:@"valid-signed.app"];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:signedAndValid]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:signedAndValid error:NULL];
|
||||
NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent];
|
||||
NSURL *signedAndValid = [tempDir URLByAppendingPathComponent:@"valid-signed.app"];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtURL:signedAndValid error:NULL];
|
||||
if (![[NSFileManager defaultManager] copyItemAtURL:self.notSignedAppURL toURL:signedAndValid error:&error]) {
|
||||
XCTFail("Failed to copy %@ to %@ with error: %@", self.notSignedAppURL, signedAndValid, error);
|
||||
}
|
||||
if ([[NSFileManager defaultManager] copyItemAtPath:self.notSignedAppPath toPath:signedAndValid error:&error]) {
|
||||
self.validSignedAppPath = signedAndValid;
|
||||
if (![self codesignAppPath:self.validSignedAppPath]) {
|
||||
NSLog(@"Failed to codesign %@", self.validSignedAppPath);
|
||||
}
|
||||
|
||||
self.validSignedAppURL = signedAndValid;
|
||||
|
||||
if (![self codesignAppURL:self.validSignedAppURL]) {
|
||||
XCTFail(@"Failed to codesign %@", self.validSignedAppURL);
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to copy %@ to %@ with error %@", self.notSignedAppPath, signedAndValid, error);
|
||||
}
|
||||
|
||||
- (void)setupCalculatorCopy
|
||||
{
|
||||
NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent];
|
||||
NSURL *calculatorCopy = [tempDir URLByAppendingPathComponent:@"calc.app"];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtURL:calculatorCopy error:NULL];
|
||||
|
||||
// Make a copy of the signed calculator app so we can match signatures later
|
||||
// Matching signatures on ad-hoc signed apps does *not* work
|
||||
NSError *copyError = nil;
|
||||
// Don't check the return value of this operation - seems like on 10.11 the API can say it fails even though the operation really succeeds,
|
||||
// which sounds like some kind of (SIP / attribute?) bug
|
||||
[[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:CALCULATOR_PATH] toURL:calculatorCopy error:©Error];
|
||||
|
||||
if (![calculatorCopy checkResourceIsReachableAndReturnError:nil]) {
|
||||
XCTFail(@"Copied calculator application does not exist");
|
||||
}
|
||||
|
||||
// Alter the signed copy slightly, this won't invalidate signature matching (although it will invalidate the integrity part of the signature)
|
||||
// Which is what we want. If a user alters an app bundle, we should still be able to update as long as its identity is still valid
|
||||
NSError *removeError = nil;
|
||||
NSURL *calculatorPkgInfo = [[calculatorCopy URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"PkgInfo"];
|
||||
XCTAssertNotNil(calculatorPkgInfo);
|
||||
if (![[NSFileManager defaultManager] removeItemAtURL:calculatorPkgInfo error:&removeError]) {
|
||||
XCTFail(@"Failed to remove file in calculator copy with error: %@", removeError);
|
||||
}
|
||||
|
||||
self.calculatorCopyURL = calculatorCopy;
|
||||
}
|
||||
|
||||
- (void)setupInvalidSignedApp
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent];
|
||||
NSString *signedAndInvalid = [tempDir stringByAppendingPathComponent:@"invalid-signed.app"];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:signedAndInvalid]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:signedAndInvalid error:NULL];
|
||||
}
|
||||
if ([[NSFileManager defaultManager] copyItemAtPath:self.notSignedAppPath toPath:signedAndInvalid error:&error]) {
|
||||
self.invalidSignedAppPath = signedAndInvalid;
|
||||
if ([self codesignAppPath:self.invalidSignedAppPath]) {
|
||||
NSString *fileInAppBundleToRemove = [self.invalidSignedAppPath stringByAppendingPathComponent:@"Contents/Resources/test_app_only_dsa_pub.pem"];
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:fileInAppBundleToRemove error:&error]) {
|
||||
NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent];
|
||||
NSURL *signedAndInvalid = [tempDir URLByAppendingPathComponent:@"invalid-signed.app"];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtURL:signedAndInvalid error:NULL];
|
||||
if ([[NSFileManager defaultManager] copyItemAtURL:self.notSignedAppURL toURL:signedAndInvalid error:&error]) {
|
||||
self.invalidSignedAppURL = signedAndInvalid;
|
||||
if ([self codesignAppURL:self.invalidSignedAppURL]) {
|
||||
NSURL *fileInAppBundleToRemove = [self.invalidSignedAppURL URLByAppendingPathComponent:@"Contents/Resources/test_app_only_dsa_pub.pem"];
|
||||
if (![[NSFileManager defaultManager] removeItemAtURL:fileInAppBundleToRemove error:&error]) {
|
||||
NSLog(@"Failed to remove %@ with error %@", fileInAppBundleToRemove, error);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to codesign %@", self.invalidSignedAppPath);
|
||||
NSLog(@"Failed to codesign %@", self.invalidSignedAppURL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to copy %@ to %@ with error %@", self.notSignedAppPath, signedAndInvalid, error);
|
||||
NSLog(@"Failed to copy %@ to %@ with error %@", self.notSignedAppURL, signedAndInvalid, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +155,7 @@
|
||||
task.launchPath = @"/usr/bin/unzip";
|
||||
task.currentDirectoryPath = destPath;
|
||||
task.arguments = @[zipPath];
|
||||
|
||||
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
success = (task.terminationStatus == 0);
|
||||
@@ -139,7 +167,7 @@
|
||||
return success;
|
||||
}
|
||||
|
||||
- (BOOL)codesignAppPath:(NSString *)appPath
|
||||
- (BOOL)codesignAppURL:(NSURL *)appPath
|
||||
{
|
||||
BOOL success = NO;
|
||||
@try
|
||||
@@ -159,38 +187,61 @@
|
||||
|
||||
- (void)testUnsignedApp
|
||||
{
|
||||
XCTAssertFalse([SUCodeSigningVerifier applicationAtPathIsCodeSigned:self.notSignedAppPath], @"App not expected to be code signed");
|
||||
XCTAssertFalse([SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.notSignedAppURL], @"App not expected to be code signed");
|
||||
|
||||
NSError *error = nil;
|
||||
XCTAssertFalse([SUCodeSigningVerifier codeSignatureIsValidAtPath:self.notSignedAppPath error:&error], @"signature should not be valid as it's not code signed");
|
||||
XCTAssertFalse([SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:self.notSignedAppURL error:&error], @"signature should not be valid as it's not code signed");
|
||||
XCTAssertNotNil(error, @"error should not be nil");
|
||||
}
|
||||
|
||||
- (void)testValidSignedApp
|
||||
{
|
||||
XCTAssertTrue([SUCodeSigningVerifier applicationAtPathIsCodeSigned:self.validSignedAppPath], @"App expected to be code signed");
|
||||
XCTAssertTrue([SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.validSignedAppURL], @"App expected to be code signed");
|
||||
|
||||
NSError *error = nil;
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureIsValidAtPath:self.validSignedAppPath error:&error], @"signature should be valid");
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:self.validSignedAppURL error:&error], @"signature should be valid");
|
||||
XCTAssertNil(error, @"error should be nil");
|
||||
}
|
||||
|
||||
- (void)testValidSignedCalculatorApp
|
||||
{
|
||||
NSString *appPath = @"/Applications/Calculator.app";
|
||||
XCTAssertTrue([SUCodeSigningVerifier applicationAtPathIsCodeSigned:appPath], @"App expected to be code signed");
|
||||
NSURL *appPath = [NSURL fileURLWithPath:CALCULATOR_PATH];
|
||||
XCTAssertTrue([SUCodeSigningVerifier bundleAtURLIsCodeSigned:appPath], @"App expected to be code signed");
|
||||
|
||||
NSError *error = nil;
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureIsValidAtPath:appPath error:&error], @"signature should be valid");
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:appPath error:&error], @"signature should be valid");
|
||||
XCTAssertNil(error, @"error should be nil");
|
||||
}
|
||||
|
||||
- (void)testValidMatchingSelf
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSURL *appPath = [NSURL fileURLWithPath:CALCULATOR_PATH];
|
||||
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureAtBundleURL:appPath matchesSignatureAtBundleURL:appPath error:&error], @"Our valid signed app expected to having matching signature to itself");
|
||||
}
|
||||
|
||||
- (void)testValidMatching
|
||||
{
|
||||
// We can't test our own app because matching with ad-hoc signed apps understandably does not succeed
|
||||
NSError *error = nil;
|
||||
NSURL *appPath = [NSURL fileURLWithPath:CALCULATOR_PATH];
|
||||
XCTAssertTrue([SUCodeSigningVerifier codeSignatureAtBundleURL:appPath matchesSignatureAtBundleURL:self.calculatorCopyURL error:&error], @"The calculator app is expected to have matching identity signature to its altered copy");
|
||||
}
|
||||
|
||||
- (void)testInvalidMatching
|
||||
{
|
||||
NSURL *appPath = [NSURL fileURLWithPath:CALCULATOR_PATH];
|
||||
NSError *error = nil;
|
||||
XCTAssertFalse([SUCodeSigningVerifier codeSignatureAtBundleURL:appPath matchesSignatureAtBundleURL:self.validSignedAppURL error:&error], @"Calculator app bundle expected to have different signature than our valid signed app");
|
||||
}
|
||||
|
||||
- (void)testInvalidSignedApp
|
||||
{
|
||||
XCTAssertTrue([SUCodeSigningVerifier applicationAtPathIsCodeSigned:self.invalidSignedAppPath], @"App expected to be code signed, but signature is invalid");
|
||||
XCTAssertTrue([SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.invalidSignedAppURL], @"App expected to be code signed, but signature is invalid");
|
||||
|
||||
NSError *error = nil;
|
||||
XCTAssertFalse([SUCodeSigningVerifier codeSignatureIsValidAtPath:self.invalidSignedAppPath error:&error], @"signature should not be valid");
|
||||
XCTAssertFalse([SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:self.invalidSignedAppURL error:&error], @"signature should not be valid");
|
||||
XCTAssertNotNil(error, @"error should not be nil");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// SUSpotlightImporterTest.swift
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/27/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SUSpotlightImporterTest: XCTestCase
|
||||
{
|
||||
func testUpdatingSpotlightBundles()
|
||||
{
|
||||
let fileManager = SUFileManager.defaultManager()
|
||||
let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory()))
|
||||
|
||||
let bundleDirectory = tempDirectoryURL.URLByAppendingPathComponent("bundle.app")
|
||||
try! fileManager.makeDirectoryAtURL(bundleDirectory)
|
||||
|
||||
let innerDirectory = bundleDirectory.URLByAppendingPathComponent("foo")
|
||||
try! fileManager.makeDirectoryAtURL(innerDirectory)
|
||||
try! NSData().writeToURL(bundleDirectory.URLByAppendingPathComponent("bar"), options: .AtomicWrite)
|
||||
|
||||
let importerDirectory = innerDirectory.URLByAppendingPathComponent("baz.mdimporter")
|
||||
|
||||
try! fileManager.makeDirectoryAtURL(importerDirectory)
|
||||
try! fileManager.makeDirectoryAtURL(innerDirectory.URLByAppendingPathComponent("flag"))
|
||||
|
||||
try! NSData().writeToURL(importerDirectory.URLByAppendingPathComponent("file"), options: .AtomicWrite)
|
||||
|
||||
let oldFooDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.path!)
|
||||
let oldBarFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(bundleDirectory.URLByAppendingPathComponent("bar").path!)
|
||||
let oldImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.path!)
|
||||
let oldFlagAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.URLByAppendingPathComponent("flag").path!)
|
||||
let oldFileInImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.URLByAppendingPathComponent("file").path!)
|
||||
|
||||
sleep(1) // wait for clock to advance
|
||||
|
||||
// Update spotlight bundles
|
||||
SUBinaryDeltaUnarchiver.updateSpotlightImportersAtBundlePath(bundleDirectory.path!)
|
||||
|
||||
let newFooDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.path!)
|
||||
XCTAssertEqual((newFooDirectoryAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFooDirectoryAttributes[NSFileModificationDate] as! NSDate), 0)
|
||||
|
||||
let newBarFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(bundleDirectory.URLByAppendingPathComponent("bar").path!)
|
||||
XCTAssertEqual((newBarFileAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldBarFileAttributes[NSFileModificationDate] as! NSDate), 0)
|
||||
|
||||
let newImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.path!)
|
||||
XCTAssertGreaterThan((newImporterAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldImporterAttributes[NSFileModificationDate] as! NSDate), 0)
|
||||
|
||||
let newFlagAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.URLByAppendingPathComponent("flag").path!)
|
||||
XCTAssertEqual((newFlagAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFlagAttributes[NSFileModificationDate] as! NSDate), 0)
|
||||
|
||||
let newFileInImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.URLByAppendingPathComponent("file").path!)
|
||||
XCTAssertEqual((newFileInImporterAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFileInImporterAttributes[NSFileModificationDate] as! NSDate), 0)
|
||||
|
||||
try! fileManager.removeItemAtURL(tempDirectoryURL)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUFileManager.h"
|
||||
@@ -35,3 +36,8 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine";
|
||||
- (NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp;
|
||||
@end
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver (Private)
|
||||
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath;
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user