From d148ec05aecbe7053befe7684ab06e76601c2a8c Mon Sep 17 00:00:00 2001 From: Petr Stepan Date: Fri, 5 Jun 2026 16:17:30 +0200 Subject: [PATCH] =?UTF-8?q?Oprava=20detekce=20dokon=C4=8Den=C3=AD=20na=20V?= =?UTF-8?q?M?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ Invoke-SecureBootAudit.ps1 | 40 ++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be6ed64 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +*.log +SecureBootRemediation-*.log +audit_results/ diff --git a/Invoke-SecureBootAudit.ps1 b/Invoke-SecureBootAudit.ps1 index 56aa9bc..97dedfd 100644 --- a/Invoke-SecureBootAudit.ps1 +++ b/Invoke-SecureBootAudit.ps1 @@ -239,8 +239,9 @@ function Get-CertificateStatus { Certs2023 = @() Error = $null } - AnyExpiring2011 = $false - AllReplacements2023 = $false + AnyExpiring2011 = $false + AllReplacements2023 = $false + AllReplacements2023_VM = $false } # ── KEK databáze ── @@ -308,11 +309,17 @@ function Get-CertificateStatus { $status.DB.Has2011UEFI -or $status.DB.Has2011WindowsPCA + # Plná sada pro fyzické servery (všechny 4 certifikáty) $status.AllReplacements2023 = $status.KEK.Has2023 -and $status.DB.Has2023UEFI -and $status.DB.Has2023OptionROM -and $status.DB.Has2023WindowsUEFI + # Minimální sada pro VM (UEFI CA 2023 + Option ROM nejsou na VM povinné — + # VM nemá fyzické PCIe option ROM karty, hypervisor řídí UEFI obsah) + $status.AllReplacements2023_VM = $status.KEK.Has2023 -and + $status.DB.Has2023WindowsUEFI + return $status } @@ -443,11 +450,27 @@ function Get-RemediationCategory { } # Secure Boot je zapnutý — zkontrolovat certifikáty - if ($cert.AllReplacements2023 -and -not $cert.AnyExpiring2011) { - return @{ Code = 'OK'; Emoji = '✅'; Label = 'OK — má nové 2023 certifikáty' } + # Na VM stačí minimální sada (KEK 2K CA 2023 + Windows UEFI CA 2023), + # UEFI CA 2023 a Option ROM UEFI CA 2023 nejsou na VM povinné + $isVM = $env -like '*VM*' + $certOK = if ($isVM) { $cert.AllReplacements2023_VM } else { $cert.AllReplacements2023 } + $certOKFull = $cert.AllReplacements2023 + + if ($certOK -and -not $cert.AnyExpiring2011) { + $_label = if ($isVM -and -not $certOKFull) { + 'OK — má povinné 2023 certifikáty pro VM (UEFI CA + Option ROM nejsou na VM vyžadovány)' + } else { + 'OK — má nové 2023 certifikáty' + } + return @{ Code = 'OK'; Emoji = '✅'; Label = $_label } } - if ($cert.AllReplacements2023 -and $cert.AnyExpiring2011) { - return @{ Code = 'OK_TRANSITION'; Emoji = '✅'; Label = 'OK — přechodný stav (2023 i 2011 certifikáty)' } + if ($certOK -and $cert.AnyExpiring2011) { + $_label = if ($isVM -and -not $certOKFull) { + 'OK — přechodný stav, VM má povinné 2023 certifikáty' + } else { + 'OK — přechodný stav (2023 i 2011 certifikáty)' + } + return @{ Code = 'OK_TRANSITION'; Emoji = '✅'; Label = $_label } } # Selhání aktualizace @@ -517,8 +540,9 @@ if ($result.SecureBoot.IsUEFI -and $result.SecureBoot.IsSupported) { Certs2011 = @(); Certs2023 = @() Error = 'Secure Boot not available — certificate check skipped' } - AnyExpiring2011 = $false - AllReplacements2023 = $false + AnyExpiring2011 = $false + AllReplacements2023 = $false + AllReplacements2023_VM = $false } }