Windows Update: search in the refresh, pending updates with KBs, CVEs and MSRC severity, install through a one-shot SYSTEM task with the selection guard, update history
event-log warnings (unexpected shutdowns, crashes, hardware and disk errors, repeated crashes), services that should run, event channels as log sources
SFC verify, DISM ScanHealth, Defender signature update and quick scan as runs
Layout
Each topic is a mixin module with its own tests and synthetic fixtures. WindowsDriver combines them, and no method is defined twice in its MRO.
Checked locally
The run used the device-types train on the path:
Tests: 637 passed, 99.4 % coverage.
ruff clean; mypy strict clean on napalm_windows and tools.
Dependency
pyproject.toml requires napalm-device-types>=4.55.0, but the code needs the device-types train (NAPALM/napalm-device-types chore/merge-train-windows-depth). The floor must rise to that release, expected 4.56.0, before this can be released. Until then the lowest CI job fails on import.
Not confirmed on a real host
No Windows host was available. Every PowerShell script is written from Microsoft's documentation and tested against synthetic fixtures. Each one is in napalm-windows' tools/harvest.py, so a single harvest from a Windows Server and a Windows 11 client records them all. The harvest stays open on #300.
**Not to be merged before Christian's go.** This is the napalm-windows depth programme (NetOrk/netork#2888–#2899), eight streams merged into one branch.
| Stream | Issues | What it adds |
|---|---|---|
| basics | #2888 #2889 #2890 #2891 | SMBIOS identity, processes, OS users, installed programs, host status (restart pending, automatic updates, system drive) |
| updates | #2892 | Windows Update: search in the refresh, pending updates with KBs, CVEs and MSRC severity, install through a one-shot SYSTEM task with the selection guard, update history |
| posture | #2893 | Secure Boot, TPM, BitLocker status, Defender, firewall profiles and VBS in the hardening reading, with five new hardening checks |
| exposure | #2894 #2898 | the Windows host firewall in the exposure chain; roles and optional features as CVE precondition facts |
| logins | #2895 | login accounts with SID, administrator and Remote Desktop rights, the groups granting them, console and RDP sessions from the Security log |
| storage | #2896 | disks, Storage Spaces pools, volumes and drive health from the Storage module |
| events | #2897 | event-log warnings (unexpected shutdowns, crashes, hardware and disk errors, repeated crashes), services that should run, event channels as log sources |
| repairs | #2899 | SFC verify, DISM ScanHealth, Defender signature update and quick scan as runs |
## Layout
Each topic is a mixin module with its own tests and synthetic fixtures. `WindowsDriver` combines them, and no method is defined twice in its MRO.
## Checked locally
The run used the device-types train on the path:
- **Tests:** 637 passed, 99.4 % coverage.
- **ruff** clean; **mypy strict** clean on `napalm_windows` and `tools`.
## Dependency
`pyproject.toml` requires `napalm-device-types>=4.55.0`, but the code needs the device-types train (NAPALM/napalm-device-types `chore/merge-train-windows-depth`). The floor must rise to that release, expected 4.56.0, before this can be released. Until then the `lowest` CI job fails on import.
## Not confirmed on a real host
No Windows host was available. Every PowerShell script is written from Microsoft's documentation and tested against synthetic fixtures. Each one is in napalm-windows' `tools/harvest.py`, so a single harvest from a Windows Server and a Windows 11 client records them all. The harvest stays open on #300.
get_hardening() reads Secure Boot, the TPM, BitLocker per volume, Defender,
the firewall profiles' state and virtualization-based security in one script,
each part caught on its own and each cmdlet probed with Get-Command first.
BitLocker through Win32_EncryptableVolume, never Get-BitLockerVolume: no
recovery password or key protector is read.
verify_system_files (sfc /verifyonly), check_component_store (DISM
/ScanHealth /English), update_antimalware_signatures (Update-MpSignature)
and scan_antimalware (Start-MpScan, quick or full), each one bounded PSRP
call streamed line by line through PsrpTransport.run_streaming. Native
tools run as a process read in their own encoding (sfc: UTF-16), and NULs
of UTF-16 read byte by byte are dropped. The exit code decides; a missing
tool or Defender says it is not available. sfc /scannow and DISM
/RestoreHealth stay undefined until a real host was tested.
tools/harvest.py --runs records the runs' output.
get_services moves into WindowsServicesMixin and reads, beside state and start
mode, Win32_Service's ExitCode (1066 hands over to ServiceSpecificExitCode, 1077
is not started since boot), StartName and whether a TriggerInfo key starts the
service, as napalm-device-types' ServiceDict result, exit_code, trigger_start
and account.
WindowsStorageMixin implements napalm-device-types' HostStorageMixin, so
the host reports its storage and stays a host:
- get_disks: Get-PhysicalDisk with medium, bus, Windows' health and the
Storage Spaces pool a disk is in; a Storage Spaces virtual disk is no
physical disk.
- get_disk_smart: Get-StorageReliabilityCounter per disk (temperature,
wear, power-on hours, uncorrected read and write errors). A counter
that cannot be read is no counter, not an error; disks that report
nothing are left out.
- get_disk_pools: Storage Spaces' pools.
- get_volumes: fixed volumes mounted at a drive letter or in a folder,
with file system and health.
A disk whose medium Windows cannot tell and whose counters are empty (a
virtual disk, a RAID controller's logical disk) reads temperature -1 and
health "unknown". Every script probes its cmdlets first. The fixtures
are synthetic; the scripts are in harvest.py for the first real host.
get_host_firewall reads the Windows Firewall: the profiles' settings in
force, every enabled rule of the active policy with its filters read in
bulk and joined on InstanceID, and the profile of each connected
interface. get_windows_features lists the image's optional features
with their state from Win32_OptionalFeature. Both scripts are in the
harvest.
WindowsHostEventsMixin.get_host_events(since=None) reads, in one script, three
bounded queries over the window: the System log's rare events (Kernel-Power 41,
EventLog 6008, WER-SystemErrorReporting 1001, WHEA-Logger 18, disk 7, Ntfs 55)
with their messages, its frequent ones (WHEA-Logger 19/47, disk 153, Service
Control Manager 7031/7034) and the Application log's crashes (Application Error
1000). Each query catches NoMatchingEventsFound; one that fails names its kinds
unread, one read up to its bound names them capped.
WindowsLogSourcesMixin.get_log_sources lists every event channel that is
switched on and holds records (Get-WinEvent -ListLog *) as a source of kind
eventlog, named by its channel, with its .evtx file, size and last write.
Analytic and debug channels are left out. README and CHANGELOG describe the
services, host events and log sources readings.
get_login_accounts reads the host's own accounts (Get-LocalUser), their
last login and failed attempts from the account database, expiry and
lock, and whether each is an administrator (S-1-5-32-544, by SID) or may
log in over Remote Desktop (the logon right and its denial from
secedit, the host's fDenyTSConnections). groups lists the groups that
grant either, with every member, a domain's included. uid is the RID,
sid the SID. A domain controller's accounts are not read.
get_login_sessions reads logon events 4624 of type 2, 10 and 11 of the
last seven days from the Security log, ended by 4634/4647, an
administrator's two linked logons as one session. own_address is the
reading's own WinRM logon's address; records_since the log's oldest
event. A log without any logon raises LoginSessionsUnavailable.
Both scripts are in tools/harvest.py.
refresh_available_updates runs the Windows Update Agent's search against the
configured source and keeps its reading under HKLM\SOFTWARE\napalm-windows;
get_available_updates reads it back without a search, leaving out what the
history shows installed since, and raises PackageIndexMissing before the
first search. Each update carries its title, KB articles, CveIDs and
MsrcSeverity, and is named by its title without month, KB and version, so
next month's cumulative update keeps the name. Previews, feature upgrades and
drivers are left out.
apply_updates installs in a one-shot task running as SYSTEM, since Windows
refuses downloads and installs to a network logon. The task's script and the
exact UpdateID:revision chosen travel in the run's registry key; it searches
again, refuses what no longer matches exactly, what asks for input or has
unaccepted licence terms, installs nothing while a restart is pending and
never restarts. Its log is followed line by line; the next run sweeps what a
dead run left. get_scheduled_jobs shows these tasks as an application's.
get_update_history reads QueryHistory, one transaction per entry, with the
ClientApplicationID as requested_by.
_member hands its name and kind to _member_name and _is_group;
parse_login_sessions hands the audit check to _audited_logons and the
sessions to _sessions. No change in behaviour.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Not to be merged before Christian's go. This is the napalm-windows depth programme (NetOrk/netork#2888–#2899), eight streams merged into one branch.
Layout
Each topic is a mixin module with its own tests and synthetic fixtures.
WindowsDrivercombines them, and no method is defined twice in its MRO.Checked locally
The run used the device-types train on the path:
napalm_windowsandtools.Dependency
pyproject.tomlrequiresnapalm-device-types>=4.55.0, but the code needs the device-types train (NAPALM/napalm-device-typeschore/merge-train-windows-depth). The floor must rise to that release, expected 4.56.0, before this can be released. Until then thelowestCI job fails on import.Not confirmed on a real host
No Windows host was available. Every PowerShell script is written from Microsoft's documentation and tested against synthetic fixtures. Each one is in napalm-windows'
tools/harvest.py, so a single harvest from a Windows Server and a Windows 11 client records them all. The harvest stays open on #300.