From e65ba845cacbf786084bce9c479145a0ebe2e612 Mon Sep 17 00:00:00 2001 From: spydisec <9101327+spydisec@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:30:14 +1000 Subject: [PATCH] Test: note when the AppLocker logs can't record anything (#74) When the AppLocker channels are selected, Test now adds an informational note after the storage check: AppLocker not available on this edition, no AppLocker policy in effect (the logs will stay empty), or the number of rules in effect. Read-only (Get-AppLockerPolicy -Effective), never a FAIL; the kit never creates an AppLocker policy. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + Test-LoggingBaseline.ps1 | 21 +++++++++++++++++++++ docs/commands.md | 6 ++++-- tests/Kit.Tests.ps1 | 9 +++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 613b3e5..bfb788e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Releases are tagged `vX.Y.Z` and published with a zip and a SHA256 checksum. - 🛡️ **Advanced audit policy can't be silently overridden.** A new Core setting turns on "Audit: Force audit policy subcategory settings to override audit policy category settings" (`SCENoApplyLegacyAuditPolicy`). It's Windows' default, but a policy that turns it off lets legacy category-level audit policy override every subcategory the kit applies; now Enable sets it, Test verifies it, and the Settings catalog and Group Policy pages map it. The role presets include it; ASD stays faithful to its script. [#71](https://github.com/spydisec/WinLogKit/issues/71) - 🚨 **Test checks that CrashOnAuditFail is off.** It's on the never-do list and the kit never sets it, but another policy might; Test now fails if it's on, since a full Security log would then halt the host. [#75](https://github.com/spydisec/WinLogKit/issues/75) - 👤 **Insecure SMB guest logons are audited.** A new Core SMB setting makes the SMB client log when a share logs it on as the Guest account, an unauthenticated logon (event 31997 in SmbClient/Audit, Windows 11 24H2 / Server 2025 and later). Mapped on the Settings catalog and Group Policy pages and carried in the GPO pack. The server-side switch isn't included: it writes to SMBServer/Operational, a log the kit doesn't collect. [#72](https://github.com/spydisec/WinLogKit/issues/72) +- 🔒 **Test says when the AppLocker logs can't record anything.** Those logs pass as enabled, but only record while an AppLocker policy is in effect. When they're selected, Test now notes if no AppLocker policy is in effect, or if AppLocker isn't available on the Windows edition, so empty logs aren't mistaken for coverage. Read-only: the kit never creates an AppLocker policy. [#74](https://github.com/spydisec/WinLogKit/issues/74) ### Fixed diff --git a/Test-LoggingBaseline.ps1 b/Test-LoggingBaseline.ps1 index 4661197..476b475 100644 --- a/Test-LoggingBaseline.ps1 +++ b/Test-LoggingBaseline.ps1 @@ -387,6 +387,27 @@ Write-Host '' Write-Host '=== Log storage (assessed channels at their maximum size) ===' -ForegroundColor White Write-LogStorageCheck (@(Get-LogStorageCheck -Logs $storageLogs)) +# Informational (#74): the AppLocker logs pass as enabled, but only record +# anything while an AppLocker policy is in effect. The kit never creates one. +$appLockerLogs = @($script:BaselineChannels | Where-Object { $_.Name -like 'Microsoft-Windows-AppLocker/*' -and $null -eq (Get-SkipReason $_.Tier 'Channel' $_.Name) }) +if ($appLockerLogs.Count -gt 0) { + Write-Host '' + Write-Host '=== AppLocker ===' -ForegroundColor White + if (-not (Get-Command Get-AppLockerPolicy -ErrorAction SilentlyContinue)) { + Write-Host '[NOTE] AppLocker isn''t available on this edition of Windows, so the AppLocker logs will stay empty.' -ForegroundColor Yellow + } else { + $ruleCount = $null + try { $ruleCount = @((Get-AppLockerPolicy -Effective -ErrorAction Stop).RuleCollections | ForEach-Object { $_ }).Count } catch { $ruleCount = $null } + if ($null -eq $ruleCount) { + Write-Host '[NOTE] Could not read the effective AppLocker policy; the AppLocker logs only record while one is in effect.' -ForegroundColor Yellow + } elseif ($ruleCount -eq 0) { + Write-Host '[NOTE] No AppLocker policy is in effect, so the AppLocker logs will stay empty. To get these events, deploy an AppLocker policy in audit-only mode (the kit doesn''t create one).' -ForegroundColor Yellow + } else { + Write-Host "[OK ] $ruleCount AppLocker rule(s) in effect; the AppLocker logs will record their decisions." -ForegroundColor DarkGray + } + } +} + # ---------------------------------------------------------------- output ---- if (-not (Test-Path $OutputDir)) { New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null } diff --git a/docs/commands.md b/docs/commands.md index 81680a0..20febd0 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -53,8 +53,10 @@ audit subcategories (superset-aware - more auditing than required passes), registry values, SMB audit settings, and that `CrashOnAuditFail` is off (the kit never sets it; the test fails if something else has). Per-behaviour-category PASS/FAIL/NOT APPLICABLE, detail + summary CSVs, non-zero exit on any failure. Ends -with the same [disk space](safety.md#disk-space) check as Enable, for -information only. +with the same [disk space](safety.md#disk-space) check as Enable and, when +the AppLocker logs are selected, a note if no AppLocker policy is in effect +(those logs stay empty without one; the kit never creates one). Both are +for information only. ```powershell .\Test-LoggingBaseline.ps1 [-IncludeHighVolume] diff --git a/tests/Kit.Tests.ps1 b/tests/Kit.Tests.ps1 index e232a83..6c7bca0 100644 --- a/tests/Kit.Tests.ps1 +++ b/tests/Kit.Tests.ps1 @@ -397,6 +397,15 @@ Describe 'Audit integrity' { Select-String -Path (Join-Path $KitRoot 'Test-LoggingBaseline.ps1') -Pattern "-Name 'CrashOnAuditFail'" -Quiet | Should -BeTrue } } +# #74: Test tells you when the AppLocker logs can't record anything. +Describe 'AppLocker readiness note' { + It 'checks for an effective AppLocker policy, read-only, and never fails on it' { + $src = Get-Content (Join-Path $KitRoot 'Test-LoggingBaseline.ps1') -Raw + $src | Should -Match 'Get-AppLockerPolicy -Effective' + $src | Should -Not -Match 'Set-AppLockerPolicy' + $src | Should -Match "Get-Command Get-AppLockerPolicy -ErrorAction SilentlyContinue" + } +} Describe 'Rollback baseline' { BeforeAll { $enableAst = [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $KitRoot 'Enable-LoggingBaseline.ps1'), [ref]$null, [ref]$null)