Skip to content

Harden PowerShell execution and fixer reliability / Повысить надёжность W-Fix - #1

Merged
OneDeadMachine-Dev merged 1 commit into
mainfrom
odm/harden-powershell-execution
Aug 14, 2026
Merged

Harden PowerShell execution and fixer reliability / Повысить надёжность W-Fix#1
OneDeadMachine-Dev merged 1 commit into
mainfrom
odm/harden-powershell-execution

Conversation

@OneDeadMachine-Dev

Copy link
Copy Markdown
Owner

Русский

Что изменилось

  • Добавлен типизированный PowerShellExecutionResult, который различает успешное выполнение, ошибку, ненулевой exit code и таймаут.
  • Исправлена отмена PowerShell: встроенный pipeline останавливается, внешний powershell.exe завершается вместе с дочерними процессами.
  • Добавлен десятиминутный таймаут по умолчанию без прежнего зависания на синхронном чтении stdout/stderr.
  • Строки [ERROR] теперь корректно делают операцию неуспешной, даже если PowerShell-скрипт перехватил исключение.
  • Служебный progress-CLIXML Windows PowerShell 5.1 больше не создаёт ложный статус ошибки.
  • Многошаговые фиксеры 0x00000002, 0x00004005, 0x0000007e и IPP учитывают результаты всех выполненных шагов.
  • DriverFixer проверяет exit code pnputil и больше не сообщает об успешной переустановке, если драйвер не найден.
  • Error8Fixer больше не удаляет все файлы из пользовательских и системных временных каталогов; очистка очереди и перезапуск Spooler сохранены.
  • Microsoft.PowerShell.SDK обновлён до 7.4.18, уязвимая транзитивная криптографическая зависимость заменена исправленной версией.
  • Добавлены 8 автоматических тестов, Windows CI, MIT License и архитектурная документация.

Почему

Раньше CancellationToken не останавливал уже запущенный PowerShell, таймаут внешнего процесса фактически игнорировался, а перехваченные внутри скриптов ошибки могли завершаться ложным Success. Некоторые многошаговые фиксеры также учитывали только последний шаг.

Изменения сохраняют рабочие обходы проблем Windows Printing, но делают их результат предсказуемым и честным.

Влияние

  • зависшие операции теперь можно отменить;
  • UI реже показывает ложный успех;
  • ошибки установки драйвера корректно отражаются в результате;
  • устранено чрезмерно широкое удаление временных файлов;
  • функциональность Spooler, драйверов, RPC, IPP и удалённого выполнения сохранена.

Проверка

  • Release build: 0 ошибок, 0 предупреждений;
  • Tests: 8/8 пройдено;
  • NuGet vulnerability audit: известных уязвимых пакетов нет;
  • git diff --check: успешно.

English

What changed

  • Added a typed PowerShellExecutionResult that distinguishes success, errors, non-zero exit codes, and timeouts.
  • Fixed cancellation: in-process pipelines are stopped and external powershell.exe processes are terminated together with their child processes.
  • Added a ten-minute default timeout without the previous synchronous stdout/stderr blocking behavior.
  • [ERROR] output now correctly fails an operation even when the PowerShell script catches the underlying exception.
  • Windows PowerShell 5.1 progress CLIXML written to stderr no longer causes false failures.
  • Multi-step fixers for 0x00000002, 0x00004005, 0x0000007e, and IPP now account for every executed step.
  • DriverFixer validates the pnputil exit code and no longer reports a successful reinstall when no matching driver exists.
  • Error8Fixer no longer deletes every file from user and system temporary directories; spool queue cleanup and Spooler restart remain intact.
  • Updated Microsoft.PowerShell.SDK to 7.4.18 and pinned a patched cryptography dependency.
  • Added 8 automated tests, Windows CI, an MIT License, and architecture documentation.

Why

Previously, CancellationToken did not stop an already-running PowerShell operation, the external process timeout was ineffective, and errors caught inside scripts could still produce a false Success. Several multi-step fixers also based their final result only on the last step.

This change keeps the practical Windows Printing workarounds while making execution and reporting deterministic and trustworthy.

Impact

  • hung operations can now be cancelled;
  • the UI reports fewer false successes;
  • driver installation failures are represented correctly;
  • overly broad temporary-file deletion has been removed;
  • Spooler, driver, RPC, IPP, and remote execution functionality is preserved.

Validation

  • Release build: 0 errors, 0 warnings;
  • Tests: 8/8 passed;
  • NuGet vulnerability audit: no known vulnerable packages;
  • git diff --check: passed.

@OneDeadMachine-Dev
OneDeadMachine-Dev marked this pull request as ready for review August 14, 2026 05:54
@OneDeadMachine-Dev
OneDeadMachine-Dev merged commit 02d83d1 into main Aug 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants