feat(device): collect static machine resource info#68
Open
swarit-stepsecurity wants to merge 1 commit intostep-security:mainfrom
Open
feat(device): collect static machine resource info#68swarit-stepsecurity wants to merge 1 commit intostep-security:mainfrom
swarit-stepsecurity wants to merge 1 commit intostep-security:mainfrom
Conversation
Adds CPU model / physical+logical cores / architecture, total RAM, and root volume capacity to the device snapshot reported on every scan. Answers "how much resource does this machine have" without including volatile signals like free memory or per-process load. Linux reads /proc/cpuinfo and /proc/meminfo (no subprocess); macOS uses sysctl; Windows uses native Win32 APIs (registry CPU name, GetLogicalProcessorInformation, GlobalMemoryStatusEx, GetDiskFreeSpaceEx) with PowerShell Get-CimInstance as fallback — wmic is unavailable on Win11 / Server 2025. Disk capacity routes through a new Executor.DiskCapacityBytes method so it stays mockable like everything else. Surfaced in pretty + HTML output and the enterprise telemetry payload. Verified end-to-end against ground truth on macOS, Fedora 42 EC2, and Server 2025 EC2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds CPU model / physical+logical cores / architecture, total RAM, and root volume capacity to the device snapshot reported on every scan. High-signal answer to "how much resource does this machine have" — no volatile fields (free RAM, per-process load) that would muddy a static snapshot.
Implementation
model.MachineResourcesstruct embedded asDevice.Resources— single nested key, additive change.internal/device/resources.{go,_other.go,_windows.go}follow the existing platform-split convention in this package./proc/cpuinfo+/proc/meminfo(no subprocess). Graceful ARM degradation — falls back toHardware/Modellines and reportsphysical_cores: 0rather than misreporting.sysctl machdep.cpu.brand_string,hw.physicalcpu,hw.logicalcpu,hw.memsize.ProcessorNameString,GetLogicalProcessorInformation,GlobalMemoryStatusEx,GetDiskFreeSpaceEx) with PowerShellGet-CimInstanceas the only fallback. wmic is no longer available on Win11 / Server 2025 and was deliberately not used.Executor.DiskCapacityBytes(path) uint64method (syscall.Statfson unix,GetDiskFreeSpaceExon windows) so it stays mockable like every other OS interaction.Payload.SetGOOS, and missing-file degradation.Test plan
go test ./...— full suite greengo vet ./...cleannproc(4),free -h(15Gi),df -h /(29G)Get-CimInstance Win32_Processor(1c/2t Xeon 8175M) andWin32_ComputerSystem(8.36 GB / 99.5 GB)