fix: gate Scheduled Maintenance commands on busy + pin explicit task principal#1160
Merged
Merged
Conversation
…principal - Save / Remove / Refresh had no !IsBusy CanExecute gate, so a fast double-click (or Save-then-Remove) could start overlapping async operations and desync IsBusy. All three are now gated on !IsBusy and re-evaluated when IsBusy changes (observed via PropertyChanged, since IsBusy lives in ViewModelBase). Save/Remove now refresh status via a non-IsBusy-toggling LoadStatusAsync so they don't report not-busy mid-operation. - The RegisterScript comment claimed a -User $env:USERNAME principal that the Register-ScheduledTask call never passed (it relied on the cmdlet default). Now it builds an explicit New-ScheduledTaskPrincipal (current user, Interactive logon, Limited run level) — making the 'current user, no admin, only when logged on' posture deliberate and matching the doc. Tests: MaintenanceSchedulerService (previously 0) — RegisterAsync passes only whitelisted args (security invariant), daily flag, null-exe -> false + no run, empty results -> false, PS throws -> false; GetStatusAsync no-rows/maps/throws.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two fixes for Scheduled Maintenance (#10), from the post-feature audit (Batch 5 of 6).
Fixes
!IsBusyCanExecutegate, so a fast double-click (or Save-then-Remove) could start overlapping async operations and desyncIsBusy. All three are now gated on!IsBusy, re-evaluated whenIsBusychanges (observed viaPropertyChanged, sinceIsBusylives inViewModelBase). Save/Remove refresh status via a new non-IsBusy-togglingLoadStatusAsync, so they no longer report not-busy mid-operation.RegisterScriptcomment claimed a-User $env:USERNAMEprincipal theRegister-ScheduledTaskcall never passed (it relied on the cmdlet default). It now builds an explicitNew-ScheduledTaskPrincipal(current user, Interactive logon, Limited run level) — making the "current user, no admin, only when logged on" posture deliberate and matching the docs.Tests
MaintenanceSchedulerServiceTests(the service previously had zero):RegisterAsyncpasses only whitelisted args (the "no free-form text reaches the scheduler" security invariant), daily-flag mapping, null-exe → false + no run, empty results → false, PowerShell throws → false;GetStatusAsyncno-rows / maps state+runs+result / throws → ExistsFalse.Docs
CHANGELOG 1.51.5, version bump to 1.51.5.
Part of the post-feature audit remediation (Batch 5 of 6).