Harden state integrity: Dry-Run rollback, profile import, batch apply (v1.121.11)#79
Merged
Merged
Conversation
… (v1.121.11) Fixes from an adversarial audit of the Dry-Run engine, config-profile import/export, and the batch (scripted) apply. 70-DryRun.ps1: - Atomic rollback now resets each reverted step to Queued. It was left "Applied", so a retry's pending filter skipped it (and the queue view showed it green) -- silently dropping rolled-back changes while reporting "all steps applied". 45-ConfigExport.ps1: - Profile-import + drift-remediation network apply capture the prior IP/gateway and restore them if New-NetIPAddress fails, instead of leaving the host with no IPv4 address / default route (remote box drops off the network, no in-band recovery). - Declining the network sub-step (or an invalid domain name) skips only that step and continues; a bare return previously aborted the entire profile import. - Export leaves DNS null when the source has none rather than fabricating 8.8.8.8; import skips DNS when null. - Interactive text export write uses -ErrorAction Stop (no truncated-file success). 50-EntryPoint.ps1 (batch) + 14-WindowsUpdates.ps1: - Batch shared-storage honors Initialize-StorageBackendBatch's boolean result. - Batch Windows-Updates checks a status flag (Install-WindowsUpdates returns, not throws, on no-network/gallery/scan failure) instead of always counting success. - Batch power-plan failure counts as an error, not a skip. - Batch DNS-only fast path registers a DNS-restore undo entry. Tests: Section 198 (14 asserts) + widened one distance-tight remediation assertion. Structural 5332/5332; full Pester 312/312; PSSA 0. Version stamps -> 1.121.11.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Fixes from an adversarial audit of the Dry-Run engine, configuration-profile import/export, and the batch (scripted) apply. Verified findings only; 1 finder finding was refuted and dropped.
Dry-Run (
70-DryRun.ps1)Invoke-DryRunCommitAtomiccorrectly reverses the applied steps — but left themStatus = "Applied", so a retry'sStatus -ne "Applied"filter skipped them (and the queue view rendered them green[A]). The reverted steps are now reset toQueued, so a retry re-applies them instead of reporting "all steps applied" with changes missing.Config profile import / export (
45-ConfigExport.ps1)New-NetIPAddress(duplicate IP, off-subnet gateway) left the box with no IPv4 and no gateway. They now capture the prior IP + gateway and restore it on failure, then re-throw so the outer handler still logs it.returnon the network-reconfig decline (and on an invalid domain name) skipped every remaining step and the summary. Now scoped to skip just that step.8.8.8.8; it now leaves DNS null (like Hostname/IP/Gateway), and import skips DNS when null.-ErrorAction Stop(LOW) so a truncated write isn't renamed into place and reported as success.Batch apply (
50-EntryPoint.ps1+14-WindowsUpdates.ps1)Initialize-StorageBackendBatchwas counted as an applied change.Install-WindowsUpdatessignals no-network/gallery/scan failure byreturn(not throw), so the batch was counting a failed run as applied. It now reads$script:LastWindowsUpdateStatus.$errors).Verification