Add admin-mode enablement for disabled event log channels#662
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an admin-only, in-process flow to enable disabled Windows Event Log channels directly from the scenario readiness dashboard, backed by a native wevtapi writer and guarded by elevation checks and confirmation UX.
Changes:
- Introduces
IChannelConfigWriter+ChannelConfigWriterto persistEvtChannelConfigEnabled=trueviaEvtOpenChannelConfig/EvtSetChannelConfigProperty/EvtSaveChannelConfig. - Adds
IChannelEnableService+ UI wiring to surface an “Enable channel” action for eligible disabled required channels (or an elevation hint when not elevated). - Expands unit/integration tests and gates mutation integration tests behind
EVENTLOG_ALLOW_CHANNEL_MUTATION(wired into compose + CI).
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/EventLogExpert.UI.Tests/Dashboard/ScenarioDetailTests.cs | Adds unit tests for enable-button visibility/click behavior and non-admin hint. |
| tests/Unit/EventLogExpert.UI.Tests/Dashboard/EmptyStateDashboardTests.cs | Adds unit tests for confirm-cancel and confirm-enable + readiness refresh behavior. |
| tests/Unit/EventLogExpert.Runtime.Tests/Scenarios/ChannelEnableServiceTests.cs | Adds unit tests for elevation gating, cancellation contract, and readiness invalidation. |
| tests/Integration/README.md | Documents the third gate (EVENTLOG_ALLOW_CHANNEL_MUTATION) for mutation integration tests. |
| tests/Integration/EventLogExpert.Eventing.IntegrationTests/Writers/ChannelConfigWriterIntegrationTests.cs | Adds mutation-gated integration coverage for enable + restore flow and not-found behavior. |
| src/EventLogExpert.UI/Dashboard/ScenarioDetail.razor.css | Styles the new “Enable channel” button and non-admin hint. |
| src/EventLogExpert.UI/Dashboard/ScenarioDetail.razor.cs | Adds parameters/callbacks and eligibility logic (present+disabled+non-system channel). |
| src/EventLogExpert.UI/Dashboard/ScenarioDetail.razor | Renders enable action or elevation hint inline with channel readiness facts. |
| src/EventLogExpert.UI/Dashboard/ScenarioBrowserPanel.razor.cs | Plumbs enable capability + callback through the scenario browser panel. |
| src/EventLogExpert.UI/Dashboard/ScenarioBrowserPanel.razor | Passes enable capability + callback into ScenarioDetail. |
| src/EventLogExpert.UI/Dashboard/EmptyStateDashboard.razor.cs | Adds enable flow (confirm → service enable → refresh readiness) and error messaging. |
| src/EventLogExpert.UI/Dashboard/EmptyStateDashboard.razor | Wires dashboard to pass CanEnableChannels + OnEnableChannel to scenario panel. |
| src/EventLogExpert.UI/Common/EnableChannelConfirmation.cs | Implements the confirmation dialog content for channel enablement. |
| src/EventLogExpert.Runtime/Scenarios/IChannelEnableService.cs | Defines the runtime service contract for gated enable attempts. |
| src/EventLogExpert.Runtime/Scenarios/ChannelEnableService.cs | Implements elevation gating, cancellation semantics, and readiness invalidation. |
| src/EventLogExpert.Runtime/DependencyInjection/RuntimeServiceCollectionExtensions.cs | Registers IChannelConfigWriter and IChannelEnableService in runtime DI. |
| src/EventLogExpert.Eventing/Writers/IChannelConfigWriter.cs | Introduces writer interface for persisting channel enablement. |
| src/EventLogExpert.Eventing/Writers/ChannelEnableResult.cs | Adds result record carrying outcome + Win32 error. |
| src/EventLogExpert.Eventing/Writers/ChannelEnableOutcome.cs | Adds typed outcomes (Enabled/AlreadyEnabled/NotElevated/etc.). |
| src/EventLogExpert.Eventing/Writers/ChannelConfigWriter.cs | Implements native write path with read-first fail-closed behavior. |
| src/EventLogExpert.Eventing/Interop/NativeMethods.Evt.cs | Adds P/Invokes for EvtSetChannelConfigProperty and EvtSaveChannelConfig. |
| src/EventLogExpert.Eventing/Interop/EvtVariant.cs | Adds boolean ctor to ensure deterministic union initialization for native calls. |
| compose.yml | Enables mutation integration tests in container via EVENTLOG_ALLOW_CHANNEL_MUTATION=1. |
| .github/workflows/PullRequest.yml | Enables mutation integration tests in CI via EVENTLOG_ALLOW_CHANNEL_MUTATION=1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jschick04
force-pushed
the
jschick/enable-disabled-channels
branch
from
July 22, 2026 23:28
ea2f153 to
f5c0b24
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/EventLogExpert.Eventing/Writers/IChannelConfigWriter.cs:10
- The XML doc implies a non-elevated caller will always get AccessDenied, but this writer can also return other outcomes (e.g., NotFound) and non-elevation may fail at different stages. It would be more accurate to describe AccessDenied as a common/expected failure mode rather than a guarantee.
/// Enables a disabled event log channel by persisting <c>EvtChannelConfigEnabled = true</c>. Requires an elevated
/// process; without elevation a native call fails and the result is <see cref="ChannelEnableOutcome.AccessDenied" />.
jschick04
marked this pull request as ready for review
July 22, 2026 23:36
jschick04
force-pushed
the
jschick/enable-disabled-channels
branch
from
July 23, 2026 16:44
f5c0b24 to
8232f83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to enable a disabled Windows event log channel in place, without leaving the app, but only when EventLogExpert is already running elevated (admin mode). Surfaced in the scenario readiness dashboard: elevated users get an "Enable channel" button on a required-but-disabled channel; non-elevated users get an honest hint to restart as administrator (there is no in-app elevation or relaunch-as-admin path).
Approach
IWindowsIdentityProvider.IsUserInAdministratorRole).EventLogExpert.Eventing/Writers/):EvtOpenChannelConfigthen read-firstEvtGetChannelConfigPropertythenEvtSetChannelConfigProperty(EvtChannelConfigEnabled, true)thenEvtSaveChannelConfig.Safety design
EvtSaveChannelConfigreturning TRUE is the persistence guarantee; no post-save re-read.GetLastWin32Erroris captured immediately after each failing P/Invoke, before the handle dispose clobbers it.Tests
EVENTLOG_ALLOW_CHANNEL_MUTATIONopt-in set only in the throwaway container (compose.yml) and CI (PullRequest.yml);EVENTLOG_CONTAINER=1alone (the documented host opt-in) deliberately does not run it, so a developer host is never mutated.Feature 1 Phase 2 of the roadmap.