Commit Graph

51 Commits

Author SHA1 Message Date
Oliver Kieselbach e88c825b56 feat(agent,rules): VM detection on hardware_spec + ANALYZE-SEC-001 skip on VMs
Adds a coarse virtual-machine flag to every hardware_spec event so the rule
engine's preconditions feature can filter device-specific rules. Wires the
new flag into ANALYZE-SEC-001 (Secure Boot UEFI CA 2023): the rule no longer
fires on Hyper-V / VMware / VirtualBox / Xen / QEMU / Parallels / KVM
guests, where the firmware DB is host-controlled and the inside-the-VM
UEFICA2023Status registry value is not actionable.

Agent (V1 + V2)
- Centralized VM detection in DeviceInfoProvider.IsVirtualMachine(mfr, model)
  alongside the existing GetManufacturer / GetModel helpers (which already
  handle Lenovo's Win32_ComputerSystemProduct.Version quirk). Reused, not
  duplicated — same source of truth as SessionRegistration / DiagnosticsPackage
  / GatherRulesMode.
- New CollectSystemInfo step in DeviceInfoCollector.HardwareSpec emits
  systemManufacturer, systemModel, isVirtualMachine onto the hardware_spec
  event. No new WMI query — calls into DeviceInfoProvider.
- Conservative bias: Microsoft Corporation manufacturer is shared between
  Hyper-V VMs and physical Surface devices, disambiguated via model
  ("Virtual Machine" → VM, "Surface Laptop 5" → physical).

Rule
- ANALYZE-SEC-001 gains a precondition (equals isVirtualMachine=false) and
  bumps to v1.1.0 so EnsureBuiltInRulesSeededAsync re-saves it for tenants
  on next backend cold start.
- Old agents (no isVirtualMachine field on hardware_spec) → fail-closed →
  rule is silently skipped on those devices until the agent updates. Safe
  default for a security rule.

Tests
- DeviceInfoProviderVmDetectionTests (V1 + V2 mirror, 18 cases each):
  Hyper-V / Cloud PC / VMware / VirtualBox / Xen / QEMU / Parallels / KVM
  positive + Surface Laptop/Pro/Book + Lenovo / Dell / HP negative + null/empty
  edge cases. Pinned at the central DeviceInfoProvider so all consumers benefit.
- 781/781 backend, 525/525 V1 agent, 800/800 V2 agent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 23:35:00 +02:00
Oliver Kieselbach 5abdcb6eee feat(rules): preconditions gate — skip rules silently on non-matching device facts
Adds an optional `preconditions` array to analyze rules. Preconditions
evaluate BEFORE conditions and are AND-combined; any failing precondition
silently skips the rule (no RuleResult, no UI card, no tenant-visible
"rule fired"). Distinct from `conditions`, which decide whether the rule
fires given that it applies.

Use case: rules that should only run on certain hardware/OS profiles
(e.g. "skip ANALYZE-SEC-001 on virtual machines because UEFI CA 2023
deployment is host-controlled").

Backend
- New `RulePrecondition` model + `Preconditions` list on `AnalyzeRule`.
- JSON schema gains optional top-level `preconditions` referencing a new
  `rulePrecondition` definition (no signal/required/correlation noise —
  pure boolean gate).
- `RuleEngine.EvaluateRule` runs preconditions first; on failure returns
  null. `EvaluatePrecondition` reuses MatchesEventType / GetDataFieldValue
  / MatchesOperator. Operator semantics:
    * not_exists → passes when event type absent OR field empty (handy
      for "old agent without the new field" path).
    * exists / others → fail closed when event type or field missing.
- `TableStorageService` rule round-trip extended with `PreconditionsJson`
  on Store + Map (column-mapped, not blob — same pattern as Conditions).

Web (analyze-rules editor)
- `AnalyzeRule` / `RuleForm` types gain `preconditions` array; form
  payload round-trips on POST + PUT; ruleToForm + EMPTY_FORM updated.
- `AnalyzeRuleFormFields`: new amber Preconditions panel above Conditions
  with eventType/dataField/operator/value/description rows.
- `AnalyzeRuleCard`: read-only chip section above Conditions with
  "skipped silently if any fails" hint.

Tests
- `RuleEnginePreconditionTests` (7 cases): empty preconditions = legacy
  behavior, single pass/fail, AND-semantics with two preconditions,
  not_exists passes when event missing, equals fails closed when event
  missing, baseline.
- 781/781 backend, 507/507 V1 agent, 782/782 V2 agent, 208/208 web vitest.

No agent change yet — useful preconditions can already target existing
event fields (os_info.edition, hardware_spec.cpuName, tpm_status.specVersion,
…). Adding `hardware_spec.isVirtualMachine` is a follow-up PR (agent collector).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 23:18:40 +02:00
Oliver Kieselbach bba5761d14 refactor(v2): app_tracking_summary back to flat V1 schema
V2 had drifted to a renamed bucket schema (installedApps/failedApps/...)
plus nested perApp/byPhase. The nested objects were dead — no Web
component or rule consumed them — and the renamed counters needed a
fallback chain in every reader. Single flat schema is simpler:

- Builder rewritten to emit only the flat V1 keys: installed/failed/
  skipped/postponed (final), downloading/installing/pending (live),
  errorCount/deviceErrors/userErrors/hasErrors/isAllCompleted/
  ignoredCount (aggregate helpers), plus name lists per bucket
  (installedNames/failedNames/skippedNames/postponedNames/pendingNames).
  perApp + byPhase removed. The includePerAppDetail flag is gone — all
  emits ship the same shape (live snapshots stay cheap because the
  names lists are short strings, not per-app timing objects).

- ignoredCount needed a separate accessor: it lives on the live
  AppPackageStateList, not on the deduped phase-snapshot+live union
  used by the termination accessor. New ImeIgnoredCount property on
  DefaultComponentFactory + ignoredCountAccessor parameter on
  EnrollmentTerminationHandler.ctor (default () => 0 keeps existing
  test rigs unaffected).

- ANALYZE-APP-007.dataField back to errorCount (flat), dist regenerated.

- Web hooks (useSessionDerivedData, useProgressDerivedData) drop the
  V2 fallback chain — single-schema reads only.

- Tests rewritten for V1 schema: counter validation, device/user
  error split, hasErrors/isAllCompleted bool helpers, name-list
  population per bucket. EnrollmentTerminationHandlerTests collapsed
  the three V2-perApp tests into one V1-counts+split-errors test;
  per-app timing detail now lives only in FinalStatusBuilder /
  final-status.json, not in the event payload.

Per-transition emit cadence and ImmediateUpload=false on live
snapshots are unchanged from the previous commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 22:39:09 +02:00
Oliver Kieselbach d295eea390 fix(rules): align ANALYZE-APP-007 + SEC-001 with V2 emit + flat data lookup
ANALYZE-APP-007: dataField errorCount -> failedApps. V1 emitted errorCount
in app_tracking_summary; V2 emits failedApps. Pulling the rule to V2-naming
removes the V1-compat alias debt from the agent.

ANALYZE-SEC-001: drop the data. prefix from dataField. RuleEngine's
GetDataFieldValue does flat dictionary lookup; the data. prefix matched
nothing under V1 or V2. Both V1 and V2 emit uefiCA2023Status /
uefiSecureBootEnabled at the root of Data, so the rule was a long-standing
no-match.

Regenerated rules/dist/analyze-rules.json from the source files via
rules/scripts/combine.js.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 21:55:05 +02:00
Oliver Kieselbach 4da1540f8c added hardware hash command to guardrails 2026-04-15 01:46:32 +02:00
Oliver Kieselbach 45edbab0e1 feat: enhanced analyze rule engine (in not_in support) MarkSessionAsFailed support, new ESP rule for cert errors 2026-04-14 21:46:20 +02:00
okieselbach 32bc9da60c chore: regenerate rules/dist from individual files 2026-04-10 16:13:38 +00:00
Oliver Kieselbach 625809423f Better app failure detection and reporting 2026-04-10 18:12:30 +02:00
Oliver Kieselbach 3e7f66e8ea added app dashboard 2026-04-07 15:57:45 +02:00
Oliver Kieselbach 3a5bf83b7c new seed file 2026-04-07 09:47:59 +02:00
Oliver Kieselbach 6a8a916d3c extended schema with new values 2026-04-06 17:56:11 +02:00
Oliver Kieselbach 860d00c017 added better error code handling and mapping 2026-04-06 17:53:55 +02:00
Oliver Kieselbach e6390db5be better diagnosics package collection 2026-04-05 17:19:22 +02:00
Oliver Kieselbach 0976a6e45e new template analyze rule fix 2026-04-03 20:05:19 +02:00
Oliver Kieselbach ed0e19fa36 added template vars to analyze rules for better user journey 2026-04-03 19:52:58 +02:00
Oliver Kieselbach e19852cd9a add structured error code extraction from IME log patterns
The backend already reads errorCode from event data for FailureCode and
failure reason formatting, but the agent never populated it. This change
extracts error codes (exit codes, HRESULT) from named regex capture groups
in IME log error patterns and sends them as structured errorCode fields.

Also fixes a pre-existing bug where ErrorPatternId/ErrorDetail were not
persisted across agent restarts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 16:56:00 +02:00
Oliver Kieselbach eaba031b82 fix multiline script output matching in PS-AGENT-OUTPUT/ERROR patterns
.* doesn't match newlines without Singleline flag — script stdout/stderr
from AgentExecutor.log spans multiple lines and was never captured.
Changed to [\s\S]*? to match across newlines.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 11:25:53 +02:00
Oliver Kieselbach 7763563c76 improved matching with exclude pattern 2026-04-02 23:13:21 +02:00
Oliver Kieselbach 743d7b3372 fixex for vulnerability matching (respect platform, wildcard matches with low confidance flag now, mismatched secure client, updated seed file) 2026-04-02 21:36:57 +02:00
Claude e3a99e519a Fix CVE version filtering to exclude already-fixed vulnerabilities
The FilterByVersion wildcard logic was treating CVEs with specific
versions in their CPE URI as affecting ALL versions. Now extracts the
version from the CPE 2.3 URI and compares it against the installed
version, so only truly relevant CVEs are shown.

Also adds missing CPE seed mappings for common Intune/Autopilot
managed software: Intune Management Extension, Company Portal,
ODBC/OLE DB drivers, Remote Desktop, Azure CLI.

https://claude.ai/code/session_01Kv2aAEVqbeFSsyPv7gU7pF
2026-03-28 18:03:29 +00:00
Oliver Kieselbach f6ed4660d1 agent: secureboot certs incl. analyze rule, timezone auto set, NTP offset check 2026-03-26 09:23:12 +01:00
Claude e2073ebeba Fix 4 more incorrect CPE entries found by NVD verification
- Docker Desktop: docker_desktop → desktop (NVD uses docker:desktop)
- BlackBerry Protect: cylanceprotect → protect (rebranded in NVD)
- WithSecure: f-secure vendor → withsecure (company rebranded)
- ProtonVPN: protonvpn vendor → proton (correct NVD vendor)

Total fixes across all commits: 7 incorrect CPE entries corrected.

https://claude.ai/code/session_01CnCJ28kuJcrWtQZcX4kCAw
2026-03-21 16:51:06 +00:00
Claude 9b37832347 Add 14 more CPE mappings: hardware drivers, CAD/engineering, productivity
Hardware drivers (highest CVE relevance, previously missing category):
- Intel Graphics Driver, Intel Chipset Device Software
- AMD Radeon Software
- NVIDIA GeForce Experience
- Realtek HD Audio Driver
- Canon printer driver

OEM management:
- Lenovo Vantage (complements existing System Update entry)

Creative/Media:
- Adobe Media Encoder (completes CC suite coverage)

Engineering/CAD (enterprise manufacturing/construction):
- Autodesk AutoCAD, Autodesk Revit
- SolidWorks, MATLAB
- Siemens Teamcenter (PLM)

Productivity:
- Grammarly

Total mappings: 247 → 261

https://claude.ai/code/session_01CnCJ28kuJcrWtQZcX4kCAw
2026-03-21 16:50:13 +00:00
Claude 55da532f17 Improve CPE mapping seed: fix 3 incorrect entries, add 41 new mappings
Fixes (NVD-verified):
- CrowdStrike: falcon_sensor → falcon (correct NVD product name)
- Bitwarden: desktop → bitwarden (correct NVD product name)
- Nmap: removed npcap from displayNamePatterns (separate product)

New mappings added (41 entries, 206→247 total):
- Adobe Creative Suite: Creative Cloud, Photoshop, Illustrator, InDesign,
  Premiere Pro, After Effects, Animate, Bridge
- Hardware management: Dell SupportAssist, HP Support Assistant,
  Intel Driver & Support Assistant, NVIDIA GPU Display Driver
- VPN/Security: SonicWall NetExtender, Check Point Endpoint Security,
  Cisco Secure Client, Ivanti Secure Access Client
- Security tools: Tenable Nessus/Agent, RSA SecurID, Trellix Agent,
  Absolute Persistence, Wazuh Agent
- Enterprise: SolarWinds Orion, ManageEngine Endpoint Central,
  Progress WhatsUp Gold, Elastic Agent
- Communication: Mitel MiCollab, RingCentral, Cisco Webex Teams
- Development: JetBrains CLion/PhpStorm/RubyMine/Toolbox,
  Snyk CLI, Beyond Compare, WinMerge
- Print drivers: HP Universal, Ricoh, Lexmark
- Cloud storage: Box Drive, Citrix ShareFile

Also: Edge displayNamePatterns expanded for WebView2 Runtime,
version bumped to 1.1.0, lastUpdated set to 2026-03-21.

https://claude.ai/code/session_01CnCJ28kuJcrWtQZcX4kCAw
2026-03-21 16:48:41 +00:00
Oliver Kieselbach 8e0bf00079 simplified seeding 2026-03-21 00:16:25 +01:00
Oliver Kieselbach f977f7a31c debounce esp_provisioning_status, re-check vulnerabilities, save button fixes, rule engine fix min one condition required 2026-03-20 22:43:58 +01:00
Oliver Kieselbach f1d653e60e feat: enhanced software inventory and vulnerability report 2026-03-20 19:01:16 +01:00
okieselbach c2a9a647b8 chore: regenerate rules/dist from individual files 2026-03-20 13:56:55 +00:00
Oliver Kieselbach 709905fac9 fix rule 2026-03-20 14:56:10 +01:00
Oliver Kieselbach dc3a3a5923 added security category to rule schema 2026-03-20 14:49:47 +01:00
Oliver Kieselbach 26e5925672 feat: Software Inventory Analyzer with Vulnerability Correlation 2026-03-20 14:43:58 +01:00
Oliver Kieselbach 767b2d7807 changed link reference in admin analyze 2026-03-18 11:17:08 +01:00
Oliver Kieselbach 1bb0aea6c3 fix admin analyze rule 2026-03-18 11:06:09 +01:00
Oliver Kieselbach 09998249fa added local admin analyze rule, 2026-03-18 10:57:04 +01:00
okieselbach d1d88f57df chore: regenerate rules/dist from individual files 2026-03-17 21:44:00 +00:00
Oliver Kieselbach c3b8f12300 fix community gather cert rule 2026-03-17 22:43:17 +01:00
okieselbach 0b607df09b chore: regenerate rules/dist from individual files 2026-03-17 21:32:34 +00:00
Oliver Kieselbach 4dc61b4728 fix IsDeviceOnlyDeployment completion event, added community rules 2026-03-17 22:31:49 +01:00
Oliver Kieselbach c6899cf898 fixed new gather rules and added severity override 2026-03-17 18:19:21 +01:00
Oliver Kieselbach 280a413dac added centralized guardrails for easier maintenance, added some more gather rules 2026-03-17 17:17:08 +01:00
Oliver Kieselbach ae47161be5 fix summary cleanup, added old OS warning analyze rule 2026-03-09 17:49:55 +01:00
Oliver Kieselbach 0b960d7d6f added PowerShell Script Execution Tracking 2026-03-05 10:12:57 +01:00
Oliver Kieselbach eae2898ce2 add Galactic Admin audit logs, audit pagination, and platform metrics backend cache
- Galactic Admin Mode for Audit Logs: banner + cross-tenant endpoint (galactic/audit/logs)
- Audit page pagination (12 entries per page) with Previous/Next controls
- Platform Metrics: moved computation to backend PlatformMetricsService with 5-min cache
- New endpoint GET /api/galactic/metrics/platform replaces N+1 client-side fetches
- IME log tracker enhancements, DO telemetry pattern, and download progress improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 19:40:37 +01:00
okieselbach 0b322f2d2c chore: regenerate rules/dist from individual files 2026-02-28 13:12:14 +00:00
Oliver Kieselbach 65860d7e9b version bump 2026-02-28 14:11:35 +01:00
Oliver Kieselbach a1c9e9a576 chagned gather rule phase definition 2026-02-28 14:07:57 +01:00
Oliver Kieselbach 64a9a0aa99 chore: unignore rules/dist/ and add initial combined rule files
rules/dist/ was excluded by the global dist/ .gitignore pattern.
Added !rules/dist/ exception so the combine-rules workflow can
commit the generated files. Also adds the initial dist files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:24:15 +01:00
Oliver Kieselbach 7cb5cf040c fix: add count_per_group_gte operator to analyze rule schema
Adds the missing operator to the enum so ANALYZE-APP-006.json passes
schema validation in the combine-rules workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:19:35 +01:00
Oliver Kieselbach 1f796bf6e3 feat: externalize rules to GitHub + API consolidation + preview mode
## Rules as GitHub single source of truth
- Add 75 individual JSON rule files (2 gather, 18 analyze, 55 IME patterns)
  under rules/gather/, rules/analyze/, rules/ime-log-patterns/
- Add JSON Schemas for all three rule types with VS Code IntelliSense support
- Add CI combine script (rules/scripts/combine.js) + GitHub Action that
  validates schemas with ajv-cli and generates rules/dist/ combined files
- Convert BuiltIn*.cs from hardcoded C# objects to embedded JSON resource loaders
- Add GitHubRuleRepository service to fetch dist/ files from raw.githubusercontent.com
- Add ReseedFromGitHubFunction: POST /api/rules/reseed-from-github?type=all|gather|analyze|ime

## IME Log Patterns
- Extend ImeLogPattern model with Description and IsBuiltIn properties
- Add ImeLogPatterns table + API constants
- Add TableStorageService CRUD methods for IME log patterns
- Add ImeLogPatternService (CRUD, merge, auto-seed from embedded JSON)
- Add ImeLogPatternsFunction: GET/PUT /api/rules/ime-log-patterns (Phase 1: read-only
  for tenants, Galactic Admin can enable/disable/edit globally)
- Add IME Log Patterns management page (/ime-log-patterns)
- Wire GetAgentConfigFunction to use ImeLogPatternService instead of static class

## API route consolidation
- All rule endpoints now under /api/rules/* for single certificate exclusion path:
  /api/rules/gather, /api/rules/analyze, /api/rules/ime-log-patterns,
  /api/rules/reseed-from-github

## Export buttons
- Add per-rule and export-all JSON download buttons to gather-rules,
  analyze-rules, and ime-log-patterns pages

## Admin configuration
- Replace old individual reseed buttons with unified "Fetch & Reseed from GitHub"
  (calls new GitHub endpoint) plus compact individual-type reseed buttons
- Add CDN cache hint: GitHub raw.githubusercontent.com caches up to 5 minutes

## Preview mode
- ?preview=1 URL param seeds localStorage.previewMode (persists across navigation)
- ?preview=0 clears it; toggle in Navbar settings dropdown (indigo, eye icon)
- IME Log Patterns nav link gated behind galacticAdminMode OR previewMode
- Preview badge shown on nav link when active for normal users

## Tests
- Add xUnit test project (net8.0) with 5 tests for embedded resource loading,
  known IME actions validation, and valid categories check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:12:09 +01:00
Oliver Kieselbach 080624cc5b parsing signalr messages fix 2026-02-10 11:34:58 +01:00