Add local Windows Server inventory collection and validation; include core package

This commit is contained in:
2026-10-30 11:24:40 -07:00
parent 967b2bd46a
commit f65ade9fff
35 changed files with 2200 additions and 56 deletions

View File

@@ -35,3 +35,17 @@ Summary presentation is derived by analyzers/summary.py without altering assessm
## Application branding
The supplied Samsara JPEG is bundled unchanged as `samsara/assets/samsara-logo.jpg`. `ui/branding.py` provides the shared Qt application/window icon and Windows taskbar application identity. The sidebar uses the same asset. Future packaged builds must include this asset; the original `App Logo` folder is not required at runtime. Icon loading was checked at 16–256 pixel sizes and the sidebar preview was reviewed offscreen. Native desktop/taskbar appearance still needs platform verification.
## Local Windows backend
`collectors/windows.py` implements supervised local execution; `powershell/Get-ServerInventory.ps1` dispatches independent section functions. Windows desktop detection routes through the verified CIM identity in the Windows backend, rather than inferring a Server edition from `platform.win32_ver()`. Explicit profiles are checked after the critical identity query and before other inventory work. No Windows module is executed on Linux.
The executable path comes from Windows GetSystemDirectoryW, with 64-bit Python required, never PATH/SystemRoot search. Argument lists use `-NoLogo -NoProfile -NonInteractive -File` with a trusted repository script and a fixed section enum. No shell, `-Command`, credential parameters, user-supplied command text, automatic elevation or execution-policy bypass. PSModulePath is limited to inbox modules. Native stdout is UTF-8 JSON; stderr/raw provider exceptions are excluded. Temporary stdout is bounded; each process is polled for cancellation/time/output limits and killed/reaped on exit paths. Provider services are not stopped or reconfigured.
Per-section default timeout is 45 seconds; overall budget is 300 seconds; per-section and accepted total inventory limits are 10 MiB. Timed-out/invalid sections are explicitly failed, remaining unattempted checks are not_collected when the overall budget expires, and successful observations survive. Cancellation rejects the new result and retains the previous UI assessment. The direct PowerShell `all` path emits the complete schema but has no Python timeout supervisor.
OS ProductType 2/3 plus build mapping gates Server 2016/2019/2022/2025. Workstation identities and unknown builds are rejected. A partial system check can be accepted only if the OS identity itself is verified; domain/IP failures remain explicit. Each section has start/end UTC timestamps, status, safe error codes/messages, access limitations and scope limitations. Complete means successful documented scope, not comprehensive dependency evidence. Non-elevated sensitive queries are conservatively partial. ACL-based silent filtering remains a manual verification concern.
`models/inventory.py` now owns the shared v1 validator and field allowlists. Metadata fields are additive and old demo/Linux results remain valid. Live Windows results are projected to safe fields; raw CIM instances are never serialized. Imported errors retain recognized categorical codes and timestamps but discard arbitrary diagnostic/permission text. Imports cannot assert the trusted local source label. Registry software covers both read-only machine uninstall views; services omit PathName; tasks emit safe action basenames and selected triggers rather than Arguments/XML; certificates never access private-key properties. Reports include all check statuses, timestamps and limitations.
Fixtures for all four Server releases live in tests/fixtures/windows. Python tests cover contract/identity/array handling, partial permission results, invalid output, process cancellation/reaping, timeouts, output bounds, secret-field exclusion, imports and the unchanged GUI/history/report flow. `tests/powershell/Test-Collectors.ps1` uses the native PowerShell AST parser and synthetic function/registry objects to test the scripts without querying the host; it runs automatically where PowerShell is present. This test is skipped in the current Linux environment. **No real Windows inventory has yet been produced here; do not mark the Windows milestone complete.** Use the README's explicit real-host validation command and review private reports before recording compatibility.