Skip to content

NM-304: collect additional data for MDM integration#1334

Merged
abhishek9686 merged 13 commits into
developfrom
NM-304
Jun 29, 2026
Merged

NM-304: collect additional data for MDM integration#1334
abhishek9686 merged 13 commits into
developfrom
NM-304

Conversation

@abhishek9686

Copy link
Copy Markdown
Member

Describe your changes

Provide Issue ticket number if applicable/not in title

Provide link to Netmaker PR if required

Provide testing steps

Checklist before requesting a review

  • My changes affect only 10 files or less.
  • I have performed a self-review of my code and tested it.
  • If it is a new feature, I have added thorough tests, my code is <= 1450 lines.
  • If it is a bugfix, my code is <= 200 lines.
  • My functions are <= 80 lines.
  • I have had my code reviewed by a peer.
  • My unit tests pass locally.
  • Netclient & Netmaker are awesome.

@tenki-reviewer

tenki-reviewer Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Complete

Files Reviewed: 29
Findings: 6

By Severity:

  • 🟠 High: 2
  • 🟡 Medium: 3
  • 🟢 Low: 1

This PR introduces cross-platform device identity collection (Linux, Windows, macOS) and MDM compliance posture handling. Review found 2 high-severity bugs (unbounded external command execution blocking the SYSTEM service, and computer UPNs bypassing machine account filters) plus 3 medium-severity identity bugs (DMI placeholders, sentinel UUIDs, day-count truncation) and 1 low-severity error-wrapping contract violation.

Files Reviewed (29 files)
auth/mdm.go
auth/mdm_test.go
cmd/posture.go
cmd/root.go
config/config.go
functions/host_identity.go
functions/mqhandlers.go
functions/mqpublish.go
functions/posture.go
functions/pull.go
functions/register.go
functions/register_sso.go
go.mod
posture/apply.go
posture/client.go
posture/email.go
posture/email_test.go
posture/identity.go
posture/identity_darwin.go
posture/identity_darwin_test.go
posture/identity_linux.go
posture/identity_linux_test.go
posture/identity_other.go
posture/identity_registry_windows.go
posture/identity_test.go
posture/identity_windows.go
posture/identity_windows_test.go
posture/runner.go
posture/status.go

@tenki-reviewer tenki-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: 🟠 High (68/100) — 2 high findings, 3 medium, 1 low · 1400 LOC across 29 files


High Severity

  • Unbounded external command timeouts (posture/runner.go:11): osRunner.Run uses exec.Command().Output() without context/timeout. On Windows SYSTEM service, hung PowerShell/dsregcmd/wmic blocks all netclient operations indefinitely. Requires interface change to exec.CommandContext with 15s timeout.
  • Computer UPN misclassified as user email (posture/email.go:12): isMachineAccount only checks HasSuffix("$"), missing Azure AD computer UPNs like COMPUTERNAME$@tenant.onmicrosoft.com. Causes silent MDM matching failures when SYSTEM service reports machine identity as user email.

Medium Severity

  • DMI placeholder strings treated as valid serial numbers (posture/identity_linux.go:6): firstNonEmpty accepts placeholders like "Not Specified" and "To be filled by O.E.M.", skipping the board_serial fallback.
  • Sentinel UUIDs (nil/all-ones) unfiltered (posture/identity_windows.go:24): VM fleets without SMBIOS passthrough share the same sentinel UUID, causing device identity collisions.
  • humanDuration truncates day values ending in 0 (functions/posture.go:138): TrimSuffix strips "0d" from any day value ending in 0 (10→1, 20→2, etc.).

Low Severity

  • Error wrapping drops ErrStatusNotOk (auth/mdm.go:42): AsMDMDenied uses %w: %s instead of %w: %w, breaking the documented error chain contract.

Comment thread functions/posture.go Outdated
Comment thread posture/identity_linux.go
Comment thread posture/runner.go Outdated
Comment thread posture/email.go
Comment thread posture/identity_windows.go
Comment thread auth/mdm.go Outdated
abhishek9686 and others added 6 commits June 18, 2026 11:02
Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>
Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>
@abhishek9686 abhishek9686 merged commit 93f46a6 into develop Jun 29, 2026
4 checks passed
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.

2 participants