* Convert raw subprocess output into parsed MDM and HKCU results, * applying the first-source-wins policy.
(raw: RawReadResult)
| 226 | * applying the first-source-wins policy. |
| 227 | */ |
| 228 | function consumeRawReadResult(raw: RawReadResult): { |
| 229 | mdm: MdmResult |
| 230 | hkcu: MdmResult |
| 231 | } { |
| 232 | // macOS: plist result (first source wins — already filtered in mdmRawRead) |
| 233 | if (raw.plistStdouts && raw.plistStdouts.length > 0) { |
| 234 | const { stdout, label } = raw.plistStdouts[0]! |
| 235 | const result = parseCommandOutputAsSettings(stdout, label) |
| 236 | if (Object.keys(result.settings).length > 0) { |
| 237 | return { mdm: result, hkcu: EMPTY_RESULT } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // Windows: HKLM result |
| 242 | if (raw.hklmStdout) { |
| 243 | const jsonString = parseRegQueryStdout(raw.hklmStdout) |
| 244 | if (jsonString) { |
| 245 | const result = parseCommandOutputAsSettings( |
| 246 | jsonString, |
| 247 | `Registry: ${WINDOWS_REGISTRY_KEY_PATH_HKLM}\\${WINDOWS_REGISTRY_VALUE_NAME}`, |
| 248 | ) |
| 249 | if (Object.keys(result.settings).length > 0) { |
| 250 | return { mdm: result, hkcu: EMPTY_RESULT } |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // No admin MDM — check managed-settings.json before using HKCU |
| 256 | if (hasManagedSettingsFile()) { |
| 257 | return { mdm: EMPTY_RESULT, hkcu: EMPTY_RESULT } |
| 258 | } |
| 259 | |
| 260 | // Fall through to HKCU (already read in parallel) |
| 261 | if (raw.hkcuStdout) { |
| 262 | const jsonString = parseRegQueryStdout(raw.hkcuStdout) |
| 263 | if (jsonString) { |
| 264 | const result = parseCommandOutputAsSettings( |
| 265 | jsonString, |
| 266 | `Registry: ${WINDOWS_REGISTRY_KEY_PATH_HKCU}\\${WINDOWS_REGISTRY_VALUE_NAME}`, |
| 267 | ) |
| 268 | return { mdm: EMPTY_RESULT, hkcu: result } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | return { mdm: EMPTY_RESULT, hkcu: EMPTY_RESULT } |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Check if file-based managed settings (managed-settings.json or any |
no test coverage detected