Skip to content

Report Group Policy-forced "do not overwrite" instead of fighting it - #85

Merged
spydisec merged 1 commit into
mainfrom
fix/retention-policy
Sep 24, 2026
Merged

spydisec merged 1 commit into
mainfrom
fix/retention-policy

Conversation

@spydisec

Copy link
Copy Markdown
Owner

From the review of darkoperator/Windows-Auditing-Guide, whose baseline sets Retention = 1 ("do not overwrite") with 4 GB sizes on Application, Security and System.

Problem: under such a GPO, Enable's #73 repair (wevtutil sl /rt:false) is undone at the next policy refresh, and Test fails that log forever with advice (run Enable) that can't work.

Change

  • Test-RetentionForcedByPolicy in WinLogKit.Common.ps1: reads HKLM\SOFTWARE\Policies\Microsoft\Windows\EventLog\<log>\Retention for the classic logs (Application, Security, Setup, System; the only ones with this policy, per Microsoft's EventLogService CSP / Event Log Service templates). Compared as text, so a DWORD or string 1 both count.
  • Enable: when a Retain log is policy-forced, it doesn't touch retention (size and enablement still apply) and reports retention 'do not overwrite' is set by Group Policy (Event Log Service > <log> > Control Event Log behavior when the log file reaches its maximum size): set it to Disabled or Not configured there.
  • Test: the FAIL for a policy-forced Retain log names the policy to change and says Enable won't override Group Policy.
  • Docs: Group Policy paths page (before-you-start bullet), Safety never-do table, Commands.

Checks: Pester 70/70 on PowerShell 7 and 5.1 (3 new, mocking the registry read: classic logs only; DWORD/string 1 vs 0/absent; wired into Enable and Test). PSScriptAnalyzer clean for the kit; mkdocs build --strict passes. Not exercised against a real GPO here.

🤖 Generated with Claude Code

Some published GPO baselines enable the Event Log Service policy "Control
Event Log behavior when the log file reaches its maximum size" (registry
value Retention = 1) on the classic logs. Enable's #73 repair was then
undone at every policy refresh and Test failed forever. New
Test-RetentionForcedByPolicy (Common) reads that policy; Enable leaves
such a log's retention alone and reports the policy to change, and Test's
FAIL says the same. The Group Policy paths page says to leave it Disabled
or Not configured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: spydisec/WinLogKit/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a757ee95-28b3-4d00-b0dd-81584d4e4fa0

📥 Commits

Reviewing files that changed from the base of the PR and between d7af7b8 and 063d232.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • Enable-LoggingBaseline.ps1
  • Test-LoggingBaseline.ps1
  • WinLogKit.Common.ps1
  • docs/commands.md
  • docs/gpo-paths.md
  • docs/safety.md
  • tests/Kit.Tests.ps1
  • tools/Export-PolicyTables.ps1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spydisec
spydisec merged commit b3c6669 into main Sep 24, 2026
6 checks passed
@spydisec
spydisec deleted the fix/retention-policy branch September 24, 2026 04:18
@spydisec spydisec mentioned this pull request Sep 24, 2026
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.

1 participant