From c56694382eb7f545c44f2808949a73a28557d534 Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 16 Jan 2017 21:17:25 -0500 Subject: [PATCH] Add AppKit prevention guards to modules that shouldn't import it --- Sparkle/SUAppcast.m | 4 ++++ Sparkle/SUAppcastItem.m | 4 ++++ Sparkle/SUBinaryDeltaApply.m | 4 ++++ Sparkle/SUBinaryDeltaCommon.m | 4 ++++ Sparkle/SUBinaryDeltaCreate.m | 4 ++++ Sparkle/SUBinaryDeltaTool.m | 4 ++++ Sparkle/SUBinaryDeltaUnarchiver.m | 4 ++++ Sparkle/SUBundleIcon.m | 4 ++++ Sparkle/SUCodeSigningVerifier.m | 4 ++++ Sparkle/SUConstants.m | 4 ++++ Sparkle/SUDSAVerifier.m | 4 ++++ Sparkle/SUDiskImageUnarchiver.m | 4 ++++ Sparkle/SUFileManager.m | 4 ++++ Sparkle/SUGuidedPackageInstaller.m | 4 ++++ Sparkle/SUHost.m | 4 ++++ Sparkle/SUInstaller.m | 4 ++++ Sparkle/SULog.m | 3 +++ Sparkle/SUOperatingSystem.m | 4 ++++ Sparkle/SUPackageInstaller.m | 4 ++++ Sparkle/SUPipedUnarchiver.m | 4 ++++ Sparkle/SUPlainInstaller.m | 4 ++++ Sparkle/SUStandardVersionComparator.m | 4 ++++ Sparkle/SUSystemProfiler.m | 4 ++++ Sparkle/SUSystemUpdateInfo.m | 4 ++++ Sparkle/SUUnarchiver.m | 4 ++++ Sparkle/SUUnarchiverNotifier.m | 4 ++++ Sparkle/SUUpdatePermissionResponse.m | 4 ++++ Sparkle/SUUpdateValidator.m | 4 ++++ fileop/SUFileOperationConstants.m | 4 ++++ fileop/fileop.m | 4 ++++ 30 files changed, 119 insertions(+) diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 70b56f0a..2341222e 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -12,6 +12,10 @@ #import "SULocalizations.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface NSXMLElement (SUAppcastExtensions) @property (readonly, copy) NSDictionary *attributesAsDictionary; @end diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 164b5bad..0e1acd92 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -10,6 +10,10 @@ #import "SULog.h" #import "SUConstants.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUAppcastItem () @property (copy, readwrite) NSString *title; @property (copy, readwrite) NSString *dateString; diff --git a/Sparkle/SUBinaryDeltaApply.m b/Sparkle/SUBinaryDeltaApply.m index eac297b4..da6c6f85 100644 --- a/Sparkle/SUBinaryDeltaApply.m +++ b/Sparkle/SUBinaryDeltaApply.m @@ -15,6 +15,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath) { NSString *patchFile = temporaryFilename(@"apply-binary-delta"); diff --git a/Sparkle/SUBinaryDeltaCommon.m b/Sparkle/SUBinaryDeltaCommon.m index 5f6ce079..7d2cd316 100644 --- a/Sparkle/SUBinaryDeltaCommon.m +++ b/Sparkle/SUBinaryDeltaCommon.m @@ -18,6 +18,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + int compareFiles(const FTSENT **a, const FTSENT **b) { return strcoll((*a)->fts_name, (*b)->fts_name); diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 0a8fbc52..00807cf5 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -21,6 +21,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + extern int bsdiff(int argc, const char **argv); @interface CreateBinaryDeltaOperation : NSOperation diff --git a/Sparkle/SUBinaryDeltaTool.m b/Sparkle/SUBinaryDeltaTool.m index ea83fdd0..2dce1d54 100644 --- a/Sparkle/SUBinaryDeltaTool.m +++ b/Sparkle/SUBinaryDeltaTool.m @@ -20,6 +20,10 @@ #define VERSION_COMMAND @"version" #define VERSION_ALTERNATE_COMMAND @"--version" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static void printUsage(NSString *programName) { fprintf(stderr, "Usage:\n"); diff --git a/Sparkle/SUBinaryDeltaUnarchiver.m b/Sparkle/SUBinaryDeltaUnarchiver.m index 6dc2a666..aed4a07e 100644 --- a/Sparkle/SUBinaryDeltaUnarchiver.m +++ b/Sparkle/SUBinaryDeltaUnarchiver.m @@ -13,6 +13,10 @@ #import "SULog.h" #import "SUFileManager.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUBinaryDeltaUnarchiver () @property (nonatomic, copy, readonly) NSString *archivePath; diff --git a/Sparkle/SUBundleIcon.m b/Sparkle/SUBundleIcon.m index a3d86a80..30a831a8 100644 --- a/Sparkle/SUBundleIcon.m +++ b/Sparkle/SUBundleIcon.m @@ -8,6 +8,10 @@ #import "SUBundleIcon.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUBundleIcon + (NSURL *)iconURLForBundle:(NSBundle *)bundle diff --git a/Sparkle/SUCodeSigningVerifier.m b/Sparkle/SUCodeSigningVerifier.m index 1da556f2..7fa84625 100644 --- a/Sparkle/SUCodeSigningVerifier.m +++ b/Sparkle/SUCodeSigningVerifier.m @@ -11,6 +11,10 @@ #import "SUCodeSigningVerifier.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUCodeSigningVerifier + (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index f5e73fda..09faeabb 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -13,6 +13,10 @@ #define DEBUG 0 #endif +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + // Define some minimum intervals to avoid DoS-like checking attacks const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60); const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24); diff --git a/Sparkle/SUDSAVerifier.m b/Sparkle/SUDSAVerifier.m index fa5f9934..5542e3cf 100644 --- a/Sparkle/SUDSAVerifier.m +++ b/Sparkle/SUDSAVerifier.m @@ -16,6 +16,10 @@ #import "SULog.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUDSAVerifier { SecKeyRef _secKey; } diff --git a/Sparkle/SUDiskImageUnarchiver.m b/Sparkle/SUDiskImageUnarchiver.m index 60f59780..dfd0c011 100644 --- a/Sparkle/SUDiskImageUnarchiver.m +++ b/Sparkle/SUDiskImageUnarchiver.m @@ -10,6 +10,10 @@ #import "SUUnarchiverNotifier.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUDiskImageUnarchiver () @property (nonatomic, copy, readonly) NSString *archivePath; diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 26369b63..64a1aa66 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -15,6 +15,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static char SUAppleQuarantineIdentifier[] = "com.apple.quarantine"; static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) { diff --git a/Sparkle/SUGuidedPackageInstaller.m b/Sparkle/SUGuidedPackageInstaller.m index 308b186c..5093c5e5 100644 --- a/Sparkle/SUGuidedPackageInstaller.m +++ b/Sparkle/SUGuidedPackageInstaller.m @@ -9,6 +9,10 @@ #import "SUGuidedPackageInstaller.h" #import "SUFileManager.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUGuidedPackageInstaller () @property (nonatomic, readonly, copy) NSString *packagePath; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 8470ae22..0094d669 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -11,6 +11,10 @@ #include // For statfs for isRunningOnReadOnlyVolume #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + // This class should not rely on AppKit and should also be process independent // For example, it should not have code that tests writabilty to somewhere on disk, // as that may depend on the privileges of the process owner. Or code that depends on diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 3ef0c5ff..383754fc 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -15,6 +15,10 @@ #import "SULog.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUInstaller + (BOOL)isAliasFolderAtPath:(NSString *)path diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index 5941aac7..c6519e49 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -13,6 +13,9 @@ #include "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif // ----------------------------------------------------------------------------- // Constants: diff --git a/Sparkle/SUOperatingSystem.m b/Sparkle/SUOperatingSystem.m index 4a7d73aa..edaae13a 100644 --- a/Sparkle/SUOperatingSystem.m +++ b/Sparkle/SUOperatingSystem.m @@ -7,6 +7,10 @@ #import "SUOperatingSystem.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 @interface NSProcessInfo () - (NSOperatingSystemVersion)operatingSystemVersion; diff --git a/Sparkle/SUPackageInstaller.m b/Sparkle/SUPackageInstaller.m index 226cde20..15a463d8 100644 --- a/Sparkle/SUPackageInstaller.m +++ b/Sparkle/SUPackageInstaller.m @@ -11,6 +11,10 @@ #import "SUErrors.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUPackageInstaller () @property (nonatomic, readonly, copy) NSString *packagePath; diff --git a/Sparkle/SUPipedUnarchiver.m b/Sparkle/SUPipedUnarchiver.m index b155b408..8b4efb66 100644 --- a/Sparkle/SUPipedUnarchiver.m +++ b/Sparkle/SUPipedUnarchiver.m @@ -11,6 +11,10 @@ #import "SULog.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUPipedUnarchiver () @property (nonatomic, copy, readonly) NSString *archivePath; diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 586ce47f..7d3ad419 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -14,6 +14,10 @@ #import "SULog.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUPlainInstaller () @property (nonatomic, readonly) SUHost *host; diff --git a/Sparkle/SUStandardVersionComparator.m b/Sparkle/SUStandardVersionComparator.m index 7bc68181..fc87e65a 100644 --- a/Sparkle/SUStandardVersionComparator.m +++ b/Sparkle/SUStandardVersionComparator.m @@ -9,6 +9,10 @@ #import "SUVersionComparisonProtocol.h" #import "SUStandardVersionComparator.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUStandardVersionComparator - (instancetype)init diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index 83a93cee..822da49b 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -14,6 +14,10 @@ #import "SUOperatingSystem.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static NSString *const SUSystemProfilerApplicationNameKey = @"appName"; static NSString *const SUSystemProfilerApplicationVersionKey = @"appVersion"; static NSString *const SUSystemProfilerCPU64bitKey = @"cpu64bit"; diff --git a/Sparkle/SUSystemUpdateInfo.m b/Sparkle/SUSystemUpdateInfo.m index 7ef2dd8f..e06cb747 100644 --- a/Sparkle/SUSystemUpdateInfo.m +++ b/Sparkle/SUSystemUpdateInfo.m @@ -11,6 +11,10 @@ #import "SUConstants.h" #import "SUFileManager.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUSystemUpdateInfo + (BOOL)systemAllowsAutomaticUpdatesForHost:(SUHost *)host diff --git a/Sparkle/SUUnarchiver.m b/Sparkle/SUUnarchiver.m index 7b808814..d91159f9 100644 --- a/Sparkle/SUUnarchiver.m +++ b/Sparkle/SUUnarchiver.m @@ -12,6 +12,10 @@ #import "SUDiskImageUnarchiver.h" #import "SUBinaryDeltaUnarchiver.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUUnarchiver + (nullable id )unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword diff --git a/Sparkle/SUUnarchiverNotifier.m b/Sparkle/SUUnarchiverNotifier.m index 727ac7da..914a08e7 100644 --- a/Sparkle/SUUnarchiverNotifier.m +++ b/Sparkle/SUUnarchiverNotifier.m @@ -10,6 +10,10 @@ #import "SULocalizations.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUUnarchiverNotifier () @property (nonatomic, readonly, copy) void (^completionBlock)(NSError * _Nullable); diff --git a/Sparkle/SUUpdatePermissionResponse.m b/Sparkle/SUUpdatePermissionResponse.m index 02c89acd..6636a2f8 100644 --- a/Sparkle/SUUpdatePermissionResponse.m +++ b/Sparkle/SUUpdatePermissionResponse.m @@ -8,6 +8,10 @@ #import "SUUpdatePermissionResponse.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUUpdatePermissionResponse @synthesize automaticUpdateChecks = _automaticUpdateChecks; diff --git a/Sparkle/SUUpdateValidator.m b/Sparkle/SUUpdateValidator.m index 164da998..efd8ace3 100644 --- a/Sparkle/SUUpdateValidator.m +++ b/Sparkle/SUUpdateValidator.m @@ -13,6 +13,10 @@ #import "SUHost.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUUpdateValidator () @property (nonatomic, readonly) SUHost *host; diff --git a/fileop/SUFileOperationConstants.m b/fileop/SUFileOperationConstants.m index 5ece5917..8a90d30b 100644 --- a/fileop/SUFileOperationConstants.m +++ b/fileop/SUFileOperationConstants.m @@ -8,6 +8,10 @@ #import "SUFileOperationConstants.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + char * const SUFileOpRemoveQuarantineCommand = "xattr-d-apple-quarantine"; char * const SUFileOpCopyCommand = "cp"; char * const SUFileOpMoveCommand = "mv"; diff --git a/fileop/fileop.m b/fileop/fileop.m index 044f2abc..d254439a 100644 --- a/fileop/fileop.m +++ b/fileop/fileop.m @@ -10,6 +10,10 @@ #import "SUFileManager.h" #import "SUFileOperationConstants.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + // If we fail, we exit with a unique status code // We don't try to NSLog because the logs can't be seen anywhere, // and we don't want to log to a file irresponsibly (especially as root),