diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da9dc42..bd5b01b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.0.7] - 2024-08-08 Requires macOS 12.0 and higher. +### Added +- If using `utilizeSOFAFeed`, you can now set the `aboutUpdateURL` to `sofa` + - If a URL is found in the relevant `SecurityInfo` key for the corresponding update, this value will be used. + - If no URL is found, the aboutUpdateURL button will not be shown to the user + - [Feature Request 629](https://github.com/macadmins/nudge/issues/629) + ### Changed - The `SMAppService` logic logs have been moved to debug logs - When an updated Managed Preference is sent for `com.github.macadmins.Nudge`, if the values are different, [Nudge will exit](https://github.com/macadmins/nudge/commit/f13a697dd61400f7f0d73dc38226f7769ed8e4f4) diff --git a/Example Assets/com.github.macadmins.Nudge.tester.json b/Example Assets/com.github.macadmins.Nudge.tester.json index 8ea8d003..b6fd09b5 100644 --- a/Example Assets/com.github.macadmins.Nudge.tester.json +++ b/Example Assets/com.github.macadmins.Nudge.tester.json @@ -5,7 +5,7 @@ }, "osVersionRequirements": [ { - "aboutUpdateURL": "https://apple.com", + "aboutUpdateURL": "sofa", "requiredMinimumOSVersion": "latest", "unsupportedURL": "https://google.com" } diff --git a/Nudge/UI/Common/InformationButton.swift b/Nudge/UI/Common/InformationButton.swift index 37384ada..3c9ca48b 100644 --- a/Nudge/UI/Common/InformationButton.swift +++ b/Nudge/UI/Common/InformationButton.swift @@ -20,9 +20,19 @@ struct InformationButton: View { private var informationButton: some View { guard OSVersionRequirementVariables.aboutUpdateURL != "" else { return AnyView(EmptyView()) } + var selectedURL = OSVersionRequirementVariables.aboutUpdateURL + if OSVersionRequirementVariables.aboutUpdateURL == "sofa" && OptionalFeatureVariables.utilizeSOFAFeed { + if nudgePrimaryState.sofaAboutUpdateURL.hasPrefix("https://") { + selectedURL = nudgePrimaryState.sofaAboutUpdateURL + } else { + return AnyView(EmptyView()) + } + } return AnyView( - Button(action: UIUtilities().openMoreInfo) { + Button(action: { + UIUtilities().openMoreInfo(infoURL: selectedURL) + }) { Text(.init(UserInterfaceVariables.informationButtonText.localized(desiredLanguage: getDesiredLanguage(locale: appState.locale)))) .foregroundColor(dynamicTextColor) } diff --git a/Nudge/UI/Defaults.swift b/Nudge/UI/Defaults.swift index e54a35aa..42d912c2 100644 --- a/Nudge/UI/Defaults.swift +++ b/Nudge/UI/Defaults.swift @@ -83,6 +83,7 @@ class AppState: ObservableObject { @Published var requireDualQuitButtons = false @Published var requiredMinimumOSVersion = OSVersionRequirementVariables.requiredMinimumOSVersion @Published var shouldExit = false + @Published var sofaAboutUpdateURL: String = "" @Published var timerCycle = 0 @Published var userDeferrals = Globals.nudgeDefaults.object(forKey: "userDeferrals") as? Int ?? 0 @Published var userQuitDeferrals = Globals.nudgeDefaults.object(forKey: "userQuitDeferrals") as? Int ?? 0 diff --git a/Nudge/UI/Main.swift b/Nudge/UI/Main.swift index 29dc78cd..c941e0c9 100644 --- a/Nudge/UI/Main.swift +++ b/Nudge/UI/Main.swift @@ -282,6 +282,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Start setting UI fields nudgePrimaryState.requiredMinimumOSVersion = selectedOS!.productVersion + nudgePrimaryState.sofaAboutUpdateURL = selectedOS!.securityInfo nudgePrimaryState.activelyExploitedCVEs = activelyExploitedCVEs releaseDate = selectedOS!.releaseDate ?? Date() if requiredInstallationDate == Date(timeIntervalSince1970: 0) { diff --git a/Nudge/Utilities/Utils.swift b/Nudge/Utilities/Utils.swift index ceab386a..6b4e2ebc 100644 --- a/Nudge/Utilities/Utils.swift +++ b/Nudge/Utilities/Utils.swift @@ -1423,13 +1423,11 @@ struct UIUtilities { return shellCommands.contains(where: path.hasPrefix) } - func openMoreInfo() { - guard let url = URL(string: OSVersionRequirementVariables.aboutUpdateURL) else { + func openMoreInfo(infoURL: String) { + guard let url = URL(string: infoURL) else { return } LogManager.notice("User clicked moreInfo button", logger: uiLog) - // TODO: Flesh this out once we understand what to do when there isn't a url in SOFA feed - // if OSVersionRequirementVariables.aboutUpdateURL == "sofa" { NSWorkspace.shared.open(url) } NSWorkspace.shared.open(url) }