Compare commits

..
15 changed files with 177 additions and 53 deletions

No files matched your search

+3 -3
View File
@@ -71,7 +71,7 @@ jobs:
run: |
git config user.name Sparkle-Bot
git config user.email sparkle.project.bot@gmail.com
git tag "${{ github.event.inputs.marketingVersion }}"
git tag "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
- name: "Build release distribution"
run: make release
@@ -90,8 +90,8 @@ jobs:
with:
draft: true
prerelease: ${{ env.PRERELEASE_VERSION }}
name: "Sparkle ${{ github.event.inputs.marketingVersion }}"
tag_name: ${{ github.event.inputs.marketingVersion }}
name: "Sparkle ${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
fail_on_unmatched_files: true
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
body_path: latest-changes.txt
+3
View File
@@ -52,6 +52,9 @@ If you are migrating from earlier alpha versions of Sparkle 2, please re-familia
* Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut)
* Add safer handling of applying binary delta files from #1990 (Zorg)
* Don't use current date unless necessary when scheduling next update to be more resilient against rapid polling from #1991 (Zorg)
* Prevent potential rapid update checks from sleep/wake events using a minimum monotonic delay from #2000 (Zorg)
* Whitelist about:srcdoc as a safe web URL from #1938, #2007 (Louis Pontoise, Zorg)
* Backport not hiding update window on deactivation from #2008 (Zorg)
# 1.27.0
+2 -2
View File
@@ -39,8 +39,8 @@ SPARKLE_VERSION_PATCH = 0
// This should be in SemVer format or empty, ie. "-beta.1"
// These variables must have a space after the '=' too
SPARKLE_VERSION_SUFFIX = -beta.4
CURRENT_PROJECT_VERSION = 2004
SPARKLE_VERSION_SUFFIX = -beta.5
CURRENT_PROJECT_VERSION = 2005
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
ALWAYS_SEARCH_USER_PATHS = NO
+3 -3
View File
@@ -2,10 +2,10 @@
import PackageDescription
// Version is technically not required here, SPM doesn't check
let version = "2.0.0-beta.4"
let version = "2.0.0-beta.5"
// Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it.
let tag = "2.0.0-beta.4"
let checksum = "4f863dc048e8c4170e0c3fdbdb9a9b03af605adbd778aa11799db3f34068202d"
let tag = "2.0.0-beta.5"
let checksum = "a53a83db87a5e705d58227f6d9088c76425ddb00e0a9eded87ae845ce5903529"
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
let package = Package(
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "2.0.0-beta.4"
s.version = "2.0.0-beta.5"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for macOS."
s.homepage = "https://sparkle-project.org"
+3 -1
View File
@@ -279,12 +279,14 @@ SU_EXPORT @interface SPUUpdater : NSObject
/**
Appropriately schedules or cancels the update checking timer according to the preferences for time interval and automatic checks.
If you change the `updateCheckInterval` or `automaticallyChecksForUpdates` properties, the update cycle will be reset automatically after a short delay.
The update cycle is also started automatically after the updater is started. In these cases, this method should not be called directly.
This call does not change the date of the next check, but only the internal timer.
*/
- (void)resetUpdateCycle;
/**
The system profile information that is sent when checking for updates.
*/
+71 -20
View File
@@ -62,6 +62,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@property (nonatomic) BOOL showingPermissionRequest;
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
@property (nonatomic) NSTimeInterval lastMonotonicUpdateCheckTime;
@property (nonatomic) BOOL loggedATSWarning;
@property (nonatomic) BOOL loggedNoSecureKeyWarning;
@@ -87,6 +88,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize canCheckForUpdates = _canCheckForUpdates;
@synthesize showingPermissionRequest = _showingPermissionRequest;
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
@synthesize lastMonotonicUpdateCheckTime = _lastMonotonicUpdateCheckTime;
@synthesize loggedATSWarning = _loggedATSWarning;
@synthesize loggedNoSecureKeyWarning = _loggedNoSecureKeyWarning;
@@ -258,7 +260,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
}
}
BOOL test;
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
if (feedURL != nil) {
@@ -403,7 +404,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// We start the update checks and register as observer for changes after the prompt finishes
} else {
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:YES];
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:YES];
}
}
@@ -423,17 +424,27 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
return [self updateLastCheckedDate];
}
- (NSTimeInterval)currentMonotonicTimeInterval
{
// This is monotonic system time while the system is not asleep
return [[NSProcessInfo processInfo] systemUptime];
}
- (void)updateLastUpdateCheckDate
{
[self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
// We use an intermediate property for last update check date due to https://github.com/sparkle-project/Sparkle/pull/1135
[self setUpdateLastCheckedDate:[NSDate date]];
[self.host setObject:[self updateLastCheckedDate] forUserDefaultsKey:SULastCheckTimeKey];
self.lastMonotonicUpdateCheckTime = [self currentMonotonicTimeInterval];
[self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
}
// Note this method is never called when sessionInProgress is YES
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately usingCurrentTime:(BOOL)usingCurrentTime
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately usingCurrentDate:(BOOL)usingCurrentDate
{
[self.updaterTimer invalidate];
@@ -480,34 +491,74 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// This callback is asynchronous, so the timer may be set. Invalidate to make sure it isn't.
[self.updaterTimer invalidate];
NSTimeInterval intervalSinceCheck;
if (usingCurrentTime) {
NSTimeInterval dateIntervalSinceCheck;
NSTimeInterval minimumMonotonicEnforcedDelay;
if (usingCurrentDate) {
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [self lastUpdateCheckDate];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
if (intervalSinceCheck < 0) {
NSTimeInterval wallTimeInterval = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
if (wallTimeInterval < 0) {
// Last update check date is in the future and bogus, so reset it to current date
[self updateLastUpdateCheckDate];
intervalSinceCheck = 0;
// And assume a full update interval is needed
dateIntervalSinceCheck = 0;
minimumMonotonicEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
} else {
// Check the monotonic clock for an enforced minimum delay
NSTimeInterval lastMonotonicUpdateCheckTime = self.lastMonotonicUpdateCheckTime;
if (lastMonotonicUpdateCheckTime <= 0) {
// When the updater is first started, the last monotonic time may not have been updated yet.
// In this case there is no enforced minimum delay.
minimumMonotonicEnforcedDelay = 0;
} else {
// Compute an enforced minimum delay based on elapsed monotonic time
// The elapsed monotonic time is more stable than wall time interval and does not include the
// amount of time while the system is asleep
NSTimeInterval currentMonotonicTime = [self currentMonotonicTimeInterval];
NSTimeInterval elapsedMonotonicTime = (currentMonotonicTime - lastMonotonicUpdateCheckTime);
if (elapsedMonotonicTime < SUMinimumMonotonicUpdateCheckInterval) {
minimumMonotonicEnforcedDelay = (SUMinimumMonotonicUpdateCheckInterval - elapsedMonotonicTime);
} else {
minimumMonotonicEnforcedDelay = 0;
}
}
dateIntervalSinceCheck = wallTimeInterval;
}
} else {
intervalSinceCheck = 0;
// Without using the current date, we assume a full update interval is needed
dateIntervalSinceCheck = 0;
minimumMonotonicEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
}
if (updateCheckInterval < SUMinimumUpdateCheckInterval) {
updateCheckInterval = SUMinimumUpdateCheckInterval;
}
// Now we want to figure out how long until we check again.
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
updateCheckInterval = SUMinimumUpdateCheckInterval;
if (intervalSinceCheck < updateCheckInterval) {
NSTimeInterval delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
if ([self.delegate respondsToSelector:@selector(updater:willScheduleUpdateCheckAfterDelay:)]) {
[self.delegate updater:self willScheduleUpdateCheckAfterDelay:delayUntilCheck];
}
[self.updaterTimer startAndFireAfterDelay:delayUntilCheck];
NSTimeInterval wallDelayUntilCheck;
if (dateIntervalSinceCheck < updateCheckInterval) {
// It hasn't been long enough.
wallDelayUntilCheck = (updateCheckInterval - dateIntervalSinceCheck);
} else {
wallDelayUntilCheck = 0;
}
// Now compute delay with enforced minimum delay requirement
// The minimum delay (based on monotonic clock) is an extra layer of defense to prevent too frequent update checks
// in case the wall clock is not working properly (eg from too many system wake events, system date changes, NTP..)
NSTimeInterval finalDelayUntilCheck = MAX(wallDelayUntilCheck, minimumMonotonicEnforcedDelay);
if (finalDelayUntilCheck <= 0) {
// We're overdue! Run one now.
[self checkForUpdatesInBackground];
} else {
if ([self.delegate respondsToSelector:@selector(updater:willScheduleUpdateCheckAfterDelay:)]) {
[self.delegate updater:self willScheduleUpdateCheckAfterDelay:finalDelayUntilCheck];
}
[self.updaterTimer startTimerWithWallTimeDelay:wallDelayUntilCheck monotonicTimeDelay:minimumMonotonicEnforcedDelay];
}
});
}
@@ -689,7 +740,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
if (!strongSelf.sessionInProgress) {
if (shouldScheduleNextUpdateCheck) {
[strongSelf scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:NO];
[strongSelf scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:NO];
} else {
SULog(SULogLevelDefault, @"Disabling scheduled updates..");
}
@@ -740,7 +791,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
if (!strongSelf.sessionInProgress) {
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately usingCurrentTime:NO];
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately usingCurrentDate:NO];
}
}
}];
@@ -785,7 +836,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
if (!self.sessionInProgress) {
[self cancelNextUpdateCycle];
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:YES];
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:YES];
}
}
+1 -1
View File
@@ -366,7 +366,7 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
Automatic update checks need to be enabled for this to trigger.
@param delay The delay in seconds until the next scheduled update will occur.
@param delay The delay in seconds until the next scheduled update will occur. This is an approximation and may vary due to system state.
@param updater The updater instance.
*/
+1 -1
View File
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate;
- (void)startAndFireAfterDelay:(NSTimeInterval)delay;
- (void)startTimerWithWallTimeDelay:(NSTimeInterval)wallDelayUntilCheck monotonicTimeDelay:(NSTimeInterval)minimumEnforcedDelay;
- (void)invalidate;
+67 -17
View File
@@ -15,14 +15,16 @@
@interface SPUUpdaterTimer ()
@property (nonatomic, readonly, weak) id<SPUUpdaterTimerDelegate> delegate;
@property (nonatomic) dispatch_source_t source;
@property (nonatomic) dispatch_source_t wallTimeSource;
@property (nonatomic) dispatch_source_t monotonicTimeSource;
@end
@implementation SPUUpdaterTimer
@synthesize delegate = _delegate;
@synthesize source = _source;
@synthesize wallTimeSource = _wallTimeSource;
@synthesize monotonicTimeSource = _monotonicTimeSource;
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate
{
@@ -33,28 +35,76 @@
return self;
}
- (void)startAndFireAfterDelay:(NSTimeInterval)delay
- (void)startTimerWithWallTimeDelay:(NSTimeInterval)wallTimeDelay monotonicTimeDelay:(NSTimeInterval)monotonicTimeDelay
{
self.source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
// We use the wall time instead of cpu time for our dispatch timer
// So eg if the computer sleeps we want to include that time spent in our timer
dispatch_time_t timeToFire = dispatch_walltime(NULL, (int64_t)(delay * NSEC_PER_SEC));
dispatch_source_set_timer(self.source, timeToFire, DISPATCH_TIME_FOREVER, SULeewayUpdateCheckInterval * NSEC_PER_SEC);
__weak __typeof__(self) weakSelf = self;
dispatch_source_set_event_handler(self.source, ^{
[weakSelf.delegate updaterTimerDidFire];
});
// When timersFired reaches 2, both wall/monotonic timers have been fired, and the delegate is ready to receive the notification
__block uint8_t timersFired = 0;
dispatch_resume(self.source);
if (wallTimeDelay <= 0) {
timersFired++;
self.wallTimeSource = nil;
} else {
// We use the wall time instead of cpu time for a large date interval
// So eg if the computer sleeps we want to include that time spent in our timer
self.wallTimeSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
dispatch_time_t wallTime = dispatch_walltime(NULL, (int64_t)(wallTimeDelay * NSEC_PER_SEC));
dispatch_source_set_timer(self.wallTimeSource, wallTime, DISPATCH_TIME_FOREVER, SULeewayWallUpdateCheckInterval * NSEC_PER_SEC);
dispatch_source_set_event_handler(self.wallTimeSource, ^{
timersFired++;
if (timersFired > 1) {
[weakSelf.delegate updaterTimerDidFire];
}
});
}
if (monotonicTimeDelay <= 0) {
timersFired++;
self.monotonicTimeSource = nil;
} else {
// We also use monotonic time to enforce a minimum delay interval
// This ensures we don't fire the wall clock based timer too frequently if the real clock changes
self.monotonicTimeSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
dispatch_time_t monotonicTime = dispatch_time(DISPATCH_TIME_NOW , (int64_t)(monotonicTimeDelay * NSEC_PER_SEC));
dispatch_source_set_timer(self.monotonicTimeSource, monotonicTime, DISPATCH_TIME_FOREVER, SULeewayMonotonicUpdateCheckInterval * NSEC_PER_SEC);
dispatch_source_set_event_handler(self.monotonicTimeSource, ^{
timersFired++;
if (timersFired > 1) {
[weakSelf.delegate updaterTimerDidFire];
}
});
}
// Have both timers already ran? (this should be unlikely)
if (timersFired > 1) {
[self.delegate updaterTimerDidFire];
} else {
// Resume available timers
if (self.wallTimeSource != nil) {
dispatch_resume(self.wallTimeSource);
}
if (self.monotonicTimeSource != nil) {
dispatch_resume(self.monotonicTimeSource);
}
}
}
- (void)invalidate
{
if (self.source != nil) {
dispatch_source_cancel(self.source);
self.source = nil;
if (self.wallTimeSource != nil) {
dispatch_source_cancel(self.wallTimeSource);
self.wallTimeSource = nil;
}
if (self.monotonicTimeSource != nil) {
dispatch_source_cancel(self.monotonicTimeSource);
self.monotonicTimeSource = nil;
}
}
+3 -1
View File
@@ -19,7 +19,9 @@
extern const NSTimeInterval SUDefaultUpdatePermissionPromptInterval;
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
extern const uint64_t SULeewayUpdateCheckInterval;
extern const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval;
extern const uint64_t SULeewayWallUpdateCheckInterval;
extern const uint64_t SULeewayMonotonicUpdateCheckInterval;
extern const NSTimeInterval SUImpatientUpdateCheckInterval;
extern NSString *const SUBundleIdentifier;
+4 -1
View File
@@ -18,8 +18,11 @@
// 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);
const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval = DEBUG ? 30 : (60 * 5);
// The amount of time the system can defer our update check (for improved performance)
const uint64_t SULeewayUpdateCheckInterval = DEBUG ? 1 : 15;
const uint64_t SULeewayWallUpdateCheckInterval = DEBUG ? 1 : 60;
const uint64_t SULeewayMonotonicUpdateCheckInterval = DEBUG ? 1 : 5;
// If the update has already been automatically downloaded, we normally don't want to bug the user about the update
// However if the user has gone a very long time without quitting an application, we will bug them
+4
View File
@@ -26,6 +26,10 @@ class SUTestApplicationTest: XCTestCase
func testRegularUpdate()
{
let app = XCUIApplication()
app.launchArguments = [
"-AppleLanguages",
"(en)"
]
app.launch()
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
+7 -1
View File
@@ -49,7 +49,7 @@ func extractVersion(parent: XMLNode) -> String? {
return nil
}
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set<String>?, maxNewVersionsInFeed: Int, link: String?, newChannel: String?, majorVersion: String?, phasedRolloutInterval: Int?, criticalUpdateVersion: String?, informationalUpdateVersions: [String]?) throws -> (numNewUpdates: Int, numExistingUpdates: Int) {
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set<String>?, maxNewVersionsInFeed: Int, fullReleaseNotesLink: String?, link: String?, newChannel: String?, majorVersion: String?, phasedRolloutInterval: Int?, criticalUpdateVersion: String?, informationalUpdateVersions: [String]?) throws -> (numNewUpdates: Int, numExistingUpdates: Int) {
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
@@ -168,6 +168,12 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set
item.addChild(linkElement)
}
if let fullReleaseNotesLink = fullReleaseNotesLink,
let fullReleaseNotesElement = XMLElement.element(withName: SUAppcastElementFullReleaseNotesLink, uri: sparkleNS) as? XMLElement {
fullReleaseNotesElement.setChildren([text(fullReleaseNotesLink)])
item.addChild(fullReleaseNotesElement)
}
// Set new channel name
if let newChannelName = newChannel,
let channelNameElement = XMLElement.element(withName: SUAppcastElementChannel, uri: sparkleNS) as? XMLElement {
+4 -1
View File
@@ -72,6 +72,9 @@ struct GenerateAppcast: ParsableCommand {
@Option(name: .customLong("release-notes-url-prefix"), help: ArgumentHelp("A URL that will be used as prefix for constructing URLs for release notes.", valueName: "url"), transform: { URL(string: $0) })
var releaseNotesURLPrefix : URL?
@Option(name: .customLong("full-release-notes-url"), help: ArgumentHelp("A URL that will be used for the full release notes.", valueName: "url"))
var fullReleaseNotesURL: String?
@Option(name: .long, help: ArgumentHelp("A URL to the application's website which Sparkle may use for directing users to if they cannot download a new update from within the application. This will be used for new generated update items. By default, no product link is used.", valueName: "link"))
var link: String?
@@ -220,7 +223,7 @@ struct GenerateAppcast: ParsableCommand {
relativeTo: archivesSourceDir)
// Write the appcast
let (numNewUpdates, numExistingUpdates) = try writeAppcast(appcastDestPath: appcastDestPath, updates: updates, newVersions: versions, maxNewVersionsInFeed: maxNewVersionsInFeed, link: link, newChannel: channel, majorVersion: majorVersion, phasedRolloutInterval: phasedRolloutInterval, criticalUpdateVersion: criticalUpdateVersion, informationalUpdateVersions: informationalUpdateVersions)
let (numNewUpdates, numExistingUpdates) = try writeAppcast(appcastDestPath: appcastDestPath, updates: updates, newVersions: versions, maxNewVersionsInFeed: maxNewVersionsInFeed, fullReleaseNotesLink: fullReleaseNotesURL, link: link, newChannel: channel, majorVersion: majorVersion, phasedRolloutInterval: phasedRolloutInterval, criticalUpdateVersion: criticalUpdateVersion, informationalUpdateVersions: informationalUpdateVersions)
// Inform the user, pluralizing "update" if necessary
let pluralizeUpdates = { $0 == 1 ? "update" : "updates" }