Visitar URL original
feat(prompt): implement interactive unknown device trust prompt and countermeasure integration by Bor-Code · Pull Request #41 · Bor-Code/HIDGuard · GitHub
Skip to content

feat(prompt): implement interactive unknown device trust prompt and countermeasure integration - #41

Merged
Bor-Code merged 1 commit into
mainfrom
feat/unknown-device-trust-prompt
Oct 16, 2026
Merged

Bor-Code merged 1 commit into
mainfrom
feat/unknown-device-trust-prompt

Conversation

@Bor-Code

Copy link
Copy Markdown
Owner

Summary

This PR implements the interactive user trust prompt mechanism for unknown/unverified USB input hardware devices. When an unrecognized keyboard connects and the policy evaluates to PolicyAction.PromptUser (or UnknownDeviceAction.PromptUser), HIDGuard presents a modern WPF prompt dialog allowing the user to either trust the device, immediately block and disable the device at the PnP hardware level, or defer judgment.

Key Changes

  • Core Abstraction: Created IDevicePromptService (HidGuard.Core.Trust) providing PromptDeviceTrustAsync contract.
  • Countermeasure Pipeline: Integrated IDevicePromptService into CountermeasureService.HandlePromptUserAsync:
    • Selecting Trust persists DeviceTrustLevel.Trusted to ITrustStore and publishes SecurityEventIds.DeviceReEnabled to Windows Event Log.
    • Selecting Block persists DeviceTrustLevel.Blocked to ITrustStore, disables the USB hardware node via IDeviceDisabler, and publishes SecurityEventIds.DeviceDisabled to Windows Event Log.
    • Selecting Decide Later retains non-disruptive state without unauthorized trust elevation.
  • Pipeline Arrival Integration: Updated KeystrokePipeline.OnDeviceConnected to evaluate policy for newly attached unknown keyboards and trigger prompt countermeasures.
  • WPF UI Components:
    • Implemented DevicePromptDialog.xaml and .xaml.cs styled with the dark theme card architecture.
    • Implemented WpfDevicePromptService with safe thread dispatching to the WPF UI dispatcher.
  • Dependency Injection: Registered IDevicePromptService as WpfDevicePromptService in App.xaml.cs.
  • Unit Test Coverage: Added 3 new tests in CountermeasureServiceTests and 1 test in WpfDevicePromptServiceTests (bringing total test count to 228 tests).
  • Documentation: Updated test counts and test scopes in README.md and README.tr.md.

Verification

  • dotnet test HidGuard.sln --configuration Release passed with 228/228 tests (100% green).
  • End-to-end simulator verification passed 5/5 scenarios (dotnet run --project tools/HidGuard.Simulator/HidGuard.Simulator.csproj --configuration Release --no-build -- --verify).
  • Verified zero compiler warnings under TreatWarningsAsErrors.

@Bor-Code
Bor-Code merged commit ea48bdc into main Oct 16, 2026
1 check passed
@Bor-Code
Bor-Code deleted the feat/unknown-device-trust-prompt branch October 16, 2026 22:06
Bor-Code added a commit that referenced this pull request Oct 17, 2026
…ountermeasure integration (#41)

## Summary
This PR implements the interactive user trust prompt mechanism for
unknown/unverified USB input hardware devices. When an unrecognized
keyboard connects and the policy evaluates to `PolicyAction.PromptUser`
(or `UnknownDeviceAction.PromptUser`), HIDGuard presents a modern WPF
prompt dialog allowing the user to either trust the device, immediately
block and disable the device at the PnP hardware level, or defer
judgment.

## Key Changes
- **Core Abstraction**: Created `IDevicePromptService`
(`HidGuard.Core.Trust`) providing `PromptDeviceTrustAsync` contract.
- **Countermeasure Pipeline**: Integrated `IDevicePromptService` into
`CountermeasureService.HandlePromptUserAsync`:
- Selecting **Trust** persists `DeviceTrustLevel.Trusted` to
`ITrustStore` and publishes `SecurityEventIds.DeviceReEnabled` to
Windows Event Log.
- Selecting **Block** persists `DeviceTrustLevel.Blocked` to
`ITrustStore`, disables the USB hardware node via `IDeviceDisabler`, and
publishes `SecurityEventIds.DeviceDisabled` to Windows Event Log.
- Selecting **Decide Later** retains non-disruptive state without
unauthorized trust elevation.
- **Pipeline Arrival Integration**: Updated
`KeystrokePipeline.OnDeviceConnected` to evaluate policy for newly
attached unknown keyboards and trigger prompt countermeasures.
- **WPF UI Components**:
- Implemented `DevicePromptDialog.xaml` and `.xaml.cs` styled with the
dark theme card architecture.
- Implemented `WpfDevicePromptService` with safe thread dispatching to
the WPF UI dispatcher.
- **Dependency Injection**: Registered `IDevicePromptService` as
`WpfDevicePromptService` in `App.xaml.cs`.
- **Unit Test Coverage**: Added 3 new tests in
`CountermeasureServiceTests` and 1 test in `WpfDevicePromptServiceTests`
(bringing total test count to 228 tests).
- **Documentation**: Updated test counts and test scopes in `README.md`
and `README.tr.md`.

## Verification
- `dotnet test HidGuard.sln --configuration Release` passed with 228/228
tests (100% green).
- End-to-end simulator verification passed 5/5 scenarios (`dotnet run
--project tools/HidGuard.Simulator/HidGuard.Simulator.csproj
--configuration Release --no-build -- --verify`).
- Verified zero compiler warnings under `TreatWarningsAsErrors`.

Co-authored-by: Boran <nonmr@users.noreply.github.com>
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