mirror of https://github.com/raandree/NTFSSecurity
Browse Source
A cmdlet that enables the Backup, Restore, Take Ownership, and Security privileges decided which ones to disable on the states that it had read when it enabled them, and stopped at the first one that failed. When another command in the pipeline, such as Disable-Privileges, had disabled one of them, the cmdlet stopped with "Priviledge already disabled" and left the privileges after that one enabled. After an early stop, which Dispose handles since this branch, it left them enabled without any message, because PowerShell ignores exceptions thrown in Dispose; and Disable-Privileges threw that exception in Dispose on every call while the privileges were disabled. 4.2.6 already decided on the old states. DisablePrivilege now reads the current state, and the cleanup tries every privilege: in EndProcessing, a privilege that it can't disable gives a warning; in Dispose, it is ignored. The early-stop tests now pin EnablePrivileges and check that the cmdlet had enabled the privileges, so that they can't pass without testing anything. Found by the security review of fcb370e..00c3646 (findings 1 to 3). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com>ai/release-5.0.0-rc6
4 changed files with 141 additions and 13 deletions
Loading…
Reference in new issue