Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System profiler privacy and transparency #1690

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add filtering of system profile keys
- Added SPUDelegate method to allow filtering of system profile array
- Expose SUSystemProfiler key constants for cleaner use of the delegate method
  • Loading branch information
pilky committed Nov 3, 2020
commit 1bbcba282b4ec9e85a1ba4ff6a050303f6dc232f
18 changes: 15 additions & 3 deletions Sparkle/SPUUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ - (NSURL * _Nullable)parameterizedFeedURL
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);

NSArray<NSDictionary<NSString *, NSString *> *> *parameters = @[];
NSArray<NSDictionary<NSString *, id> *> *parameters = @[];
if ([self.delegate respondsToSelector:@selector((feedParametersForUpdater:sendingSystemProfile:))]) {
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile];
if (feedParameters != nil) {
Expand All @@ -748,7 +748,7 @@ - (NSURL * _Nullable)parameterizedFeedURL
}
if (sendingSystemProfile)
{
parameters = [parameters arrayByAddingObjectsFromArray:[SUSystemProfiler systemProfileArrayForHost:self.host]];
parameters = [parameters arrayByAddingObjectsFromArray:self.systemProfileArray];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
}
if ([parameters count] == 0) { return baseFeedURL; }
Expand All @@ -774,7 +774,19 @@ - (NSURL * _Nullable)parameterizedFeedURL
}

- (NSArray<NSDictionary<NSString *, id> *> *)systemProfileArray {
return [SUSystemProfiler systemProfileArrayForHost:self.host];
NSArray *systemProfile = [SUSystemProfiler systemProfileArrayForHost:self.host];
if ([self.delegate respondsToSelector:@selector(allowedSystemProfileKeysForUpdater:)]) {
NSArray * allowedKeys = [self.delegate allowedSystemProfileKeysForUpdater:self];
NSMutableArray *filteredProfile = [NSMutableArray array];
for (NSDictionary *profileElement in systemProfile) {
NSString *key = [profileElement objectForKey:@"key"];
if (key && [allowedKeys containsObject:key]) {
[filteredProfile addObject:profileElement];
}
}
systemProfile = [filteredProfile copy];
}
return systemProfile;
}

- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
Expand Down
31 changes: 31 additions & 0 deletions Sparkle/SPUUpdaterDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;

// -----------------------------------------------------------------------------
// System Profile Keys
// -----------------------------------------------------------------------------

SU_EXPORT extern NSString *const SUSystemProfilerApplicationNameKey;
SU_EXPORT extern NSString *const SUSystemProfilerApplicationVersionKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPU64bitKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUCountKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUFrequencyKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUTypeKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUSubtypeKey;
SU_EXPORT extern NSString *const SUSystemProfilerHardwareModelKey;
SU_EXPORT extern NSString *const SUSystemProfilerMemoryKey;
SU_EXPORT extern NSString *const SUSystemProfilerOperatingSystemVersionKey;
SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;

// -----------------------------------------------------------------------------
// SPUUpdater Delegate:
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -99,6 +115,21 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck)
- (NSArray *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
#endif

/*!
Returns a list of system profile keys to be appended to the appcast URL's query string.

If this is unimplemented then all keys will be included.

\param updater The updater instance.

\return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the SUSystemProfiler*Key constants
*/
#if __has_feature(objc_generics)
- (NSArray<NSString *> *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater;
#else
- (NSArray *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater;
#endif

/*!
Returns a custom appcast URL.

Expand Down
23 changes: 12 additions & 11 deletions Sparkle/SUSystemProfiler.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@
#import "SUHost.h"
#import "SUOperatingSystem.h"
#include <sys/sysctl.h>
#import "SPUUpdaterDelegate.h"


#include "AppKitPrevention.h"

static NSString *const SUSystemProfilerApplicationNameKey = @"appName";
static NSString *const SUSystemProfilerApplicationVersionKey = @"appVersion";
static NSString *const SUSystemProfilerCPU64bitKey = @"cpu64bit";
static NSString *const SUSystemProfilerCPUCountKey = @"ncpu";
static NSString *const SUSystemProfilerCPUFrequencyKey = @"cpuFreqMHz";
static NSString *const SUSystemProfilerCPUTypeKey = @"cputype";
static NSString *const SUSystemProfilerCPUSubtypeKey = @"cpusubtype";
static NSString *const SUSystemProfilerHardwareModelKey = @"model";
static NSString *const SUSystemProfilerMemoryKey = @"ramMB";
static NSString *const SUSystemProfilerOperatingSystemVersionKey = @"osVersion";
static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
NSString *const SUSystemProfilerApplicationNameKey = @"appName";
NSString *const SUSystemProfilerApplicationVersionKey = @"appVersion";
NSString *const SUSystemProfilerCPU64bitKey = @"cpu64bit";
NSString *const SUSystemProfilerCPUCountKey = @"ncpu";
NSString *const SUSystemProfilerCPUFrequencyKey = @"cpuFreqMHz";
NSString *const SUSystemProfilerCPUTypeKey = @"cputype";
NSString *const SUSystemProfilerCPUSubtypeKey = @"cpusubtype";
NSString *const SUSystemProfilerHardwareModelKey = @"model";
NSString *const SUSystemProfilerMemoryKey = @"ramMB";
NSString *const SUSystemProfilerOperatingSystemVersionKey = @"osVersion";
NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";

@implementation SUSystemProfiler

Expand Down