From 4eb518de7e44c3595ae32c395286ee41784d4be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 4 Sep 2016 16:07:11 +0100 Subject: [PATCH 1/2] Test nullability --- Tests/SUCodeSigningVerifierTest.m | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Tests/SUCodeSigningVerifierTest.m b/Tests/SUCodeSigningVerifierTest.m index f4147e10..918b0550 100644 --- a/Tests/SUCodeSigningVerifierTest.m +++ b/Tests/SUCodeSigningVerifierTest.m @@ -80,16 +80,13 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *signedAndValid = [tempDir URLByAppendingPathComponent:@"valid-signed.app"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:signedAndValid.path]) { - [[NSFileManager defaultManager] removeItemAtURL:signedAndValid error:NULL]; - } - + [[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); } self.validSignedAppURL = signedAndValid; - + if (![self codesignAppURL:self.validSignedAppURL]) { XCTFail(@"Failed to codesign %@", self.validSignedAppURL); } @@ -100,9 +97,7 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *calculatorCopy = [tempDir URLByAppendingPathComponent:@"calc.app"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:calculatorCopy.path]) { - [[NSFileManager defaultManager] removeItemAtURL:calculatorCopy error:NULL]; - } + [[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 @@ -111,14 +106,16 @@ // which sounds like some kind of (SIP / attribute?) bug [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:CALCULATOR_PATH] toURL:calculatorCopy error:©Error]; - if (![[NSFileManager defaultManager] fileExistsAtPath:calculatorCopy.path]) { + 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; - if (![[NSFileManager defaultManager] removeItemAtURL:[[calculatorCopy URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"PkgInfo"] error:&removeError]) { + 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); } @@ -131,9 +128,7 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *signedAndInvalid = [tempDir URLByAppendingPathComponent:@"invalid-signed.app"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:signedAndInvalid.path]) { - [[NSFileManager defaultManager] removeItemAtURL:signedAndInvalid error:NULL]; - } + [[NSFileManager defaultManager] removeItemAtURL:signedAndInvalid error:NULL]; if ([[NSFileManager defaultManager] copyItemAtURL:self.notSignedAppURL toURL:signedAndInvalid error:&error]) { self.invalidSignedAppURL = signedAndInvalid; if ([self codesignAppURL:self.invalidSignedAppURL]) { From c3d8e4bbc5d158172e667cce60deb05b430cee94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 4 Sep 2016 17:02:56 +0100 Subject: [PATCH 2/2] Changelog --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8d1558e0..717c8bf1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,8 @@ * Removed SUEnableAutomaticChecksKeyOld and SUCheckAtStartup constants (Eitot) * Updated Sparkle framework headers to use modules if modules are available (B. Kevin Hardman) * Fixed warnings, fixed uses of SULocalizedString (Jerry Krinock) +* Improved signing verifier to take any host and s/application/bundle/ (Zorg) +* Improved Spotlight updates after delta extraction (Zorg) # 1.14.0 (Mar 11, 2016)