feat(audit): 1.3 — CPU collector (dmidecode type 4, microcode)

- cpu.go: collectCPUs(), parseCPUs(), parseCPUSection()
- splitDMISections(): splits multi-section dmidecode output generically
- parseFieldLines(): reusable key→value parser for DMI sections
- parseCPUStatus(): Populated/Unpopulated → OK/WARNING/EMPTY/UNKNOWN
- parseSocketIndex(): CPU0/Processor 1/Socket 2 → integer
- cleanManufacturer(): strips (R), Corporation, Inc. suffixes
- parseMHz(), parseInt(): field value parsers
- Serial fallback: <board_serial>-CPU-<socket> when DMI serial absent
- readMicrocode(): /sys/devices/system/cpu/cpu0/microcode/version
- cpu_test.go: dual-socket, unpopulated skipped, status, socket, manufacturer, MHz

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 10:37:19 +03:00
parent f1e392a7fe
commit 00bb2fdace
5 changed files with 484 additions and 1 deletions

View File

@@ -21,7 +21,11 @@ func Run() schema.HardwareIngestRequest {
snap.Board = board
snap.Firmware = append(snap.Firmware, biosFW...)
// remaining collectors added in steps 1.3 1.10
cpus, cpuFW := collectCPUs(snap.Board.SerialNumber)
snap.CPUs = cpus
snap.Firmware = append(snap.Firmware, cpuFW...)
// remaining collectors added in steps 1.4 1.10
slog.Info("audit completed", "duration", time.Since(start).Round(time.Millisecond))