Skip to content

Add osinfo package, split software & updater modules#7

Open
Warhammer4000 wants to merge 19 commits into
developfrom
ai-code-refactor
Open

Add osinfo package, split software & updater modules#7
Warhammer4000 wants to merge 19 commits into
developfrom
ai-code-refactor

Conversation

@Warhammer4000
Copy link
Copy Markdown

Introduce a new internal/osinfo package (many collectors: audio, collect, disk, display, format, gpu, helpers, network, peripherals, printers, ram, system, types, users) to centralize system inventory collection. Split software service into software_collect/parse/sync/types and remove the old softwareService; add updater components (checker, downloader, installer, process) and remove the legacy updater.go. Simplify cmd/sentinelgo/main.go by removing embedded service/program code and many CLI helper functions, streamlining flags and runtime flows. Adjust internal/config to silence debug prints. Update Makefile: add targets (test-version, deps, test, pre-release, quality-check, format-check, setup, packages), make golangci-lint install conditional, and fix release package contents. Update task and audit service files to reflect API changes. Overall this refactors and modularizes OS info, software sync, and updater functionality and cleans up CLI/service wiring.

Introduce a new internal/osinfo package (many collectors: audio, collect, disk, display, format, gpu, helpers, network, peripherals, printers, ram, system, types, users) to centralize system inventory collection. Split software service into software_collect/parse/sync/types and remove the old softwareService; add updater components (checker, downloader, installer, process) and remove the legacy updater.go. Simplify cmd/sentinelgo/main.go by removing embedded service/program code and many CLI helper functions, streamlining flags and runtime flows. Adjust internal/config to silence debug prints. Update Makefile: add targets (test-version, deps, test, pre-release, quality-check, format-check, setup, packages), make golangci-lint install conditional, and fix release package contents. Update task and audit service files to reflect API changes. Overall this refactors and modularizes OS info, software sync, and updater functionality and cleans up CLI/service wiring.
@Warhammer4000 Warhammer4000 requested a review from habib45 May 21, 2026 19:02
Introduce a set of CLI/service helper files under cmd/sentinelgo to manage the SentinelGo agent: handlers for audit logs and logging integration (commands.go), macOS launchd plist creation/loading/unloading (launchd.go), process discovery and termination/status utilities (process.go), service program lifecycle using kardianos/service with lockfile support and audit log runner (service.go), software listing/JSON output helpers (software.go), and version resolution (version.go). Also add local .claude settings to allow specific Bash commands and tweak .gitignore to account for sentinelgo artifacts. These additions provide tooling to install/start/stop/check the agent, collect/upload logs, and report software/audit status.
Add gofmt commands to .claude/settings.local.json to run and write formatting. Update .gitignore to remove coverage.out and old release entries and to ignore the /release directory. Minor non-functional formatting changes: align struct field spacing in internal/osinfo/types.go and reorder imports in internal/updater/installer.go.
Split the monolithic internal/osinfo package into smaller, component-based packages (audio, disk, display, gpu, network, peripherals, printers, ram, system, users) and a shared subpackage for common types/helpers. Updated collect.go to import and call the new package Get()/systempkg functions (e.g. networkpkg.Get(), diskpkg.Get(), systempkg.GetFirmwareInfo(), userspkg.Get()), adjusted mapping of OS/kernel info and hardware fields, and changed manufacturer handling to use CPU model name where available. Removed old consolidated files and added platform-specific implementations (darwin/linux/windows) for each component. Also includes minor workspace changes: updated .claude/settings.local.json entries, removed cmd/.gitkeep, and trimmed .gitignore.
Refactor internal/osinfo to centralize canonical type definitions and system helpers. Deleted old type alias and wrapper files (types.go, system.go) and removed the uptime formatter (format.go). Collect() and other APIs now return and consume internal/osinfo/shared.SystemInfo and related types, and OS/system helpers are called from internal/osinfo/system where needed. Updated callers (cmd/sentinelgo, service, task manager) and tests to import shared or system packages and to handle the removed UptimeFormatted field (use Uptime in seconds). Also small workspace tweaks: unignored build/ in .gitignore and adjusted .claude/settings.local.json filter.
Ensure AgentID is populated when missing in config.Load and add a 3s context timeout to RunCommand to prevent hanging external commands. Update .claude/settings.local.json with additional Bash/PowerShell debug helpers. Adjust tests to match behavior changes: expect empty AccessToken when not provided, simplify logging test (remove config dependency), add assertions for TenantID/EventData in models_test, make procinfo tests robust (check CmdLine, use zero-value struct, skip Linux-specific parsing tests on Windows), and minor imports/cleanup to support these changes.
Introduce platform-specific Unix implementations for peripherals and printers (peripherals_unix.go, printers_unix.go) with build tags and move device-type and lpstat parsing logic there. Clean up imports in shared files and adjust formatting in collect.go. Harden Windows audit log collector by safely deferring DLL handle closes and ignoring non-critical return values; fix fmt.Sscanf usage to ignore returned count. Update CI workflow: make security job depend on lint, add OS matrix for tests, ensure coverage check runs in bash, and adjust build job naming/needs. Add modernc.org/sqlite to go.mod and refresh go.sum. Update local .claude settings to run gofmt, golangci-lint and go install as development helpers.
Replace the PowerShell-based Windows display parser with native WMI queries using github.com/yusufpapurcu/wmi. Adds WMI structs and helper functions (wmiByteArrayToString, instanceSerial, videoOutputTechToString) and derives a stable MD5-based serial fallback when a monitor serial is missing. Move parseSizeFromName into a darwin||windows-specific file and remove it from the common display.go. Update getDisplays to query WmiMonitorID, WmiMonitorConnectionParams and Win32_VideoController, build shared.Display entries, and return nil early when WMI yields nothing. Also update .claude/settings.local.json with additional local debug commands (go env and inspecting the wmi module files).
Expand the Lint job into a GOOS matrix (linux, darwin, windows) with fail-fast disabled and set GOOS env. Restrict go.mod tidy and format checks to the linux matrix, and check both go.mod and go.sum after tidy. Add github.com/yusufpapurcu/wmi v1.2.4 as a direct dependency in go.mod (removed its previous indirect entry).
Refactor: extract parseSizeFromName into internal/osinfo/shared/format.go as ParseDisplaySizeFromName and add required regexp/strconv imports. Update darwin and windows display code to call shared.ParseDisplaySizeFromName and remove the duplicate display_notlinux.go file. Also simplify CI test step by removing coverage flags and running plain go test to avoid generating coverage output.
CI: run tests in ./tests with -coverprofile and show per-function coverage via go tool cover; Makefile: update test target to produce coverage.out, add coverage-html target, and add coverage-html to .PHONY; .gitignore: ignore generated coverage.html.

Windows display: fix WMI type mismatches by using int32/uint32 for COM-returned VT_I4 elements (ManufacturerName/UserFriendlyName/SerialNumberID/YearOfManufacture/VideoOutputTechnology), update wmiByteArrayToString to accept []int32 and cast elements to byte, change videoOutputTechToString to uint32 and map sentinel constants as uint32 values, add a panic-safe defer in getDisplays and switch to a named return to avoid crashes. These changes address type/encoding bugs and add coverage reporting utilities.
Move CPU collection into a new internal/osinfo/cpu package and consume it from Collect(); remove local timezone logic and use UTC timestamp. Normalize and extend disk encryption and manufacturer handling: add encryption_status/encryption_type fields, manufacturer inference, and platform-specific encryption detection (darwin, linux, windows). Improve GPU detection across platforms: better VRAM parsing, driver/version lookup, PCI/device mapping, and architecture determination. Update shared types and system package to expose new disk encryption/method/hardware functions. Clean up miscellaneous telemetry/debug prints and update AgentService mapping to use the new DiskEncryptionEnabled field.
Convert capacity fields from formatted strings to uint64 byte values across OS collectors and shared types. Updated disk collectors (darwin/linux/windows) to populate FreeCapacity and Capacity with raw bytes instead of formatted GiB/percent; updated RAM collectors (darwin/linux/windows) to parse and return capacities in bytes and to return RAMInfo.TotalCapacity as bytes. Removed BytesToGiB and GBToGiB helpers from shared/format.go and deleted an obsolete timezone test (tests/timezone_test.go).

This is a breaking change to the shared types (DiskDevice, RAMStick, RAMInfo) — consumers must handle numeric byte values instead of pre-formatted strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant