Skip to content

Commit 2e5c7eb

Browse files
committed
correct SLA computation for major upgrades
1 parent 24a49f9 commit 2e5c7eb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Nudge/UI/Main.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
257257

258258
let presentCVEs = selectedOS!.cves.count > 0
259259
let slaExtension: TimeInterval
260+
// Start setting UI fields
261+
nudgePrimaryState.requiredMinimumOSVersion = selectedOS!.productVersion
262+
nudgePrimaryState.sofaAboutUpdateURL = selectedOS!.securityInfo
263+
nudgePrimaryState.activelyExploitedCVEs = activelyExploitedCVEs
260264
switch (activelyExploitedCVEs, presentCVEs, AppStateManager().requireMajorUpgrade()) {
261265
case (false, true, true):
262266
slaExtension = TimeInterval(OSVersionRequirementVariables.nonActivelyExploitedCVEsMajorUpgradeSLA * 86400)
263267
case (false, true, false):
264268
slaExtension = TimeInterval(OSVersionRequirementVariables.nonActivelyExploitedCVEsMinorUpdateSLA * 86400)
269+
case (true, false, true): // The selected major upgrade does not have CVEs, but the old OS does
270+
slaExtension = TimeInterval(OSVersionRequirementVariables.activelyExploitedCVEsMajorUpgradeSLA * 86400)
265271
case (true, true, true):
266272
slaExtension = TimeInterval(OSVersionRequirementVariables.activelyExploitedCVEsMajorUpgradeSLA * 86400)
267273
case (true, true, false):
@@ -271,6 +277,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
271277
case (false, false, false):
272278
slaExtension = TimeInterval(OSVersionRequirementVariables.standardMinorUpdateSLA * 86400)
273279
default: // If we get here, something is wrong, use 90 days as a safety
280+
LogManager.warning("SLA Extension logic failed, using 90 days as a safety", logger: sofaLog)
274281
slaExtension = TimeInterval(90 * 86400)
275282
}
276283

@@ -280,10 +287,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
280287
}
281288
LogManager.notice("SOFA Actively Exploited CVEs: \(activelyExploitedCVEs)", logger: sofaLog)
282289

283-
// Start setting UI fields
284-
nudgePrimaryState.requiredMinimumOSVersion = selectedOS!.productVersion
285-
nudgePrimaryState.sofaAboutUpdateURL = selectedOS!.securityInfo
286-
nudgePrimaryState.activelyExploitedCVEs = activelyExploitedCVEs
287290
releaseDate = selectedOS!.releaseDate ?? Date()
288291
if requiredInstallationDate == Date(timeIntervalSince1970: 0) {
289292
if OSVersionRequirementVariables.minorVersionRecalculationThreshold > 0 {

0 commit comments

Comments
 (0)