_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.
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.
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.
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.
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.
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.
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_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.
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_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.