Harden backup/undo safety nets in security-feature modules (v1.121.12)#80
Merged
Conversation
Fixes from an adversarial audit of the security-feature modules (GPO, JEA, NPS, SIEM). Common class: a backup/snapshot taken with -EA SilentlyContinue (or its result discarded), then trusted downstream as if it exists. 76-SIEMForwarder.ps1: - Write-SIEMConfigFile fails closed if it can't back up an existing config, so Restore-SIEMConfig (undo) can never fall through and DELETE the live config when the backup silently failed -- which was silently stopping log forwarding. 71-GPOManager.ps1: - GPO backup returns $null (CLI exit 1) when GPOs were enumerated but every Backup-GPO failed, instead of exiting 0 with an empty folder trusted as a baseline. - Drift detection tracks an Indeterminate bucket: a GPO whose baseline settings XML is missing is reported as 'not checked', not silently 'unchanged' (missed drift). - The undoable GPO restore only registers an undo when the pre-restore snapshot actually succeeded; the dry-run undo verifies snapshot content before restoring. 73-NPS.ps1: - NPS config import verifies the pre-import backup landed before claiming it and registering the undo; warns plainly when the import isn't undoable. 72-JEA.ps1: - The dry-run Apply throws when Invoke-JEAEndpointBuild returns $false (validation failure returns without throwing), so a failed endpoint isn't marked applied. Audit also confirmed the JEA role/endpoint config is least-privilege + constrained and the VPN/RADIUS policy values are correct. Tests: Section 199 (10 asserts). Structural 5341/5341; Pester 312/312; PSSA 0. Version stamps -> 1.121.12.
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 security-feature modules (Group Policy, JEA, NPS, SIEM). One coherent class: a backup/snapshot taken with
-EA SilentlyContinue(or its result discarded), then trusted downstream — so a silently-failed backup made the exit code lie, missed drift, or made an "undo" destroy the live config. 4 finder findings were refuted and dropped.SIEM forwarder (
76)Write-SIEMConfigFilereturned the backup path withOk=$trueeven when theCopy-Itembackup silently failed;Restore-SIEMConfigthen saw the missing backup, fell through, andRemove-Item'd the just-written config on undo — silently stopping log forwarding. It now fails closed: if it can't back up an existing config, it doesn't overwrite it, so a non-nullBackupalways means a real backup exists.Group Policy (
71)GPOBackupexits non-zero when it backed up nothing (MED). GPOs enumerated but everyBackup-GPOfailed → stillexit 0, leaving an empty folder trusted as a drift/restore baseline. Now returns$null→ exit 1.unchanged(false all-clear). It's now tracked in an Indeterminate bucket and surfaced as "not checked".NPS (
73)JEA (
72)Invoke-JEAEndpointBuildreturns$falsewithout throwing when the.psscfails validation; the dry-run engine marks a non-throwing apply as "applied", so a rejected endpoint was reported registered. It now throws.Verified clean (no changes)
Verification