[PR #6995] [client] Fix macOS platform info parsing from ioreg #27733

Open
opened 2026-08-05 07:09:09 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6995
Author: @Optic00
Created: 7/30/2026
Status: 🔄 Open

Base: mainHead: codex/fix-macos-platform-info


📝 Commits (1)

  • d0d3b7d fix macOS platform system information

📊 Changes

2 files changed (+109 additions, -17 deletions)

View changed files

📝 client/system/info_darwin.go (+28 -17)
📝 client/system/info_darwin_test.go (+81 -0)

📄 Description

Describe your changes

sysInfo on macOS scanned the entire ioreg -l output with substring matches for keys that do not exist on Macs ("ModelNumber", "device manufacturer"), so product name and manufacturer were effectively never reported, and the serial-number substring match could pick up unrelated keys.

It now runs /usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice and parses the exact IOPlatformSerialNumber, model, and manufacturer keys, handling both quoted values and the <"..."> data-string form, and preserving = characters inside values.

Added table-driven tests covering the quoted and data-string forms, exact-key matching against similarly named keys, missing values, and values containing =. Real Apple Silicon output was checked with the serial redacted; the Intel format is fixture-tested. Verified with go test -count=1 ./client/system and git diff --check.

N/A

Stack

Standalone PR based on main.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal fix to system-information collection; no user-facing configuration or documented behavior changes.

Docs PR URL (required if "docs added" is checked)

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Improved macOS device information detection for serial numbers, model names, and manufacturers.
    • Correctly handles quoted values, wrapped values, missing fields, exact key matches, and values containing equals signs.
  • Tests

    • Added coverage for varied macOS platform information formats and edge cases.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6995 **Author:** [@Optic00](https://github.com/Optic00) **Created:** 7/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/fix-macos-platform-info` --- ### 📝 Commits (1) - [`d0d3b7d`](https://github.com/netbirdio/netbird/commit/d0d3b7dcaec7820c0ff64b322481afe73b7e7fea) fix macOS platform system information ### 📊 Changes **2 files changed** (+109 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `client/system/info_darwin.go` (+28 -17) 📝 `client/system/info_darwin_test.go` (+81 -0) </details> ### 📄 Description ## Describe your changes `sysInfo` on macOS scanned the entire `ioreg -l` output with substring matches for keys that do not exist on Macs ("ModelNumber", "device manufacturer"), so product name and manufacturer were effectively never reported, and the serial-number substring match could pick up unrelated keys. It now runs `/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice` and parses the exact `IOPlatformSerialNumber`, `model`, and `manufacturer` keys, handling both quoted values and the `<"...">` data-string form, and preserving `=` characters inside values. Added table-driven tests covering the quoted and data-string forms, exact-key matching against similarly named keys, missing values, and values containing `=`. Real Apple Silicon output was checked with the serial redacted; the Intel format is fixture-tested. Verified with `go test -count=1 ./client/system` and `git diff --check`. ## Issue ticket number and link N/A ## Stack <!-- branch-stack --> Standalone PR based on `main`. ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal fix to system-information collection; no user-facing configuration or documented behavior changes. ### Docs PR URL (required if "docs added" is checked) N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved macOS device information detection for serial numbers, model names, and manufacturers. * Correctly handles quoted values, wrapped values, missing fields, exact key matches, and values containing equals signs. * **Tests** * Added coverage for varied macOS platform information formats and edge cases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:09:09 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27733