Commit 13d86e7
fix: harden hardware identifier collection across all platforms (#14)
* chore: ai config
* chore: ai config
* fix: remove unnecessary workflow
* fix: filter OEM placeholder in Windows PowerShell fallback paths
PowerShell fallbacks for CPU, system UUID, and disk serials were returning
"To be filled by O.E.M." as a valid identifier — only motherboard serial
handled it. Centralize filtering in parsePowerShellValue /
parsePowerShellMultipleValues so every PowerShell-backed collector rejects
OEM placeholders consistently with the wmic path.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: harden Linux CPU and disk serial collection
Three correctness bugs in the Linux collector:
1. parseCPUInfo returned ":::" when /proc/cpuinfo was empty or contained
no recognized fields, silently contributing a fixed string to the
machine ID and reducing entropy. Now returns ErrNotFound so the
caller records a proper component error.
2. linuxDiskSerials, linuxDiskSerialsLSBLK, and linuxDiskSerialsSys did
not filter the BIOS "To be filled by O.E.M." placeholder, unlike the
motherboard path which uses isValidSerial. Route all disk serial
candidates through isValidSerial so the placeholder is rejected
consistently.
3. linuxDiskSerials returned (nil, nil) when both lsblk and /sys/block
failed, making "no disks on this system" indistinguishable from
"collection is broken." It now returns ErrNotFound only when both
backends errored AND no valid serial was produced.
Also parameterize sysBlockDir via a package-private variable so
linuxDiskSerialsSys can be tested against a fake /sys/block tree built
with t.TempDir().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add args-aware overrides to mockExecutor
The existing mock keys registered outputs and errors by command name
only, which made it impossible to test code that invokes the same
command with different arguments (e.g. two sysctl subcommands on
macOS). Add setOutputForArgs / setErrorForArgs that take precedence
over the name-only maps so such flows can be exercised deterministically.
Existing setOutput / setError behavior is unchanged.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: reject null UUIDs and lock Apple Silicon CPU path on darwin
macOSHardwareUUID accepted "00000000-0000-0000-0000-000000000000" from
either system_profiler or ioreg, letting a null UUID contribute to the
machine ID on hardware where firmware hasn't programmed a real one.
Reject the null UUID in both the system_profiler path (falling back to
ioreg) and the ioreg path (returning ParseError/ErrNotFound).
Also add Apple Silicon and Intel CPU tests that use the new args-aware
mock executor to exercise the exact production paths that were
previously impossible to test:
- brand_string = "Apple M1 Pro", features = "" → "Apple M1 Pro:"
(trailing colon preserved for license activation compatibility).
- brand_string + non-empty features → "brand:features".
- brand_string OK but features errors → degraded "brand" result.
The degraded path is intentionally preserved to avoid invalidating
existing license activations; a new doc comment on macOSCPUInfo
explains the divergence, and TestMacOSCPUInfoBrandOKFeaturesErrorDegrades
locks the behavior in so any future change fails loudly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 79926bf commit 13d86e7
File tree
10 files changed
+763
-251
lines changed- .github
- workflows
10 files changed
+763
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
| |||
114 | 124 | | |
115 | 125 | | |
116 | 126 | | |
| 127 | + | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| |||
122 | 133 | | |
123 | 134 | | |
124 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
125 | 144 | | |
126 | 145 | | |
127 | 146 | | |
| |||
182 | 201 | | |
183 | 202 | | |
184 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
185 | 211 | | |
186 | 212 | | |
187 | 213 | | |
| |||
0 commit comments