posture

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package posture collects stable MDM device identifiers and queries the server-side posture status endpoint. Netclient itself does NOT evaluate device compliance (disk encryption, AV, firewall, patch level, jailbreak/root, screen lock) - that responsibility stays in the MDM and is enforced by the netmaker server.

Index

Constants

View Source
const (
	StatusPass = "pass"
	StatusWarn = "warn"
	StatusFail = "fail"
)

Standard status values mirrored from the server.

Variables

This section is empty.

Functions

func ApplyIdentity

func ApplyIdentity(host *schema.Host)

ApplyIdentity copies MDM device-matching identifiers onto the host when identity reporting is enabled. Fields are best-effort: empty strings are left unchanged when Collect() cannot determine a value.

func ApplyIdentityIfChanged

func ApplyIdentityIfChanged(host *schema.Host) bool

ApplyIdentityIfChanged collects device identity onto host and reports whether any posture field changed.

Types

type DeviceIdentity

type DeviceIdentity struct {
	Hostname      string `json:"hostname"`
	SerialNumber  string `json:"serial_number"`
	HardwareUUID  string `json:"hardware_uuid"`
	OS            string `json:"os"`
	EntraDeviceID string `json:"entra_device_id"`
}

DeviceIdentity is the platform identifier set collected locally and copied onto schema.Host fields via ApplyIdentity during join and check-in.

func Collect

func Collect() DeviceIdentity

Collect gathers the device identity for the current host. It never returns an error: any per-field failure leaves that field empty.

type HostMDMStatus

type HostMDMStatus struct {
	Provider     string    `json:"provider"`
	MatchedBy    string    `json:"matched_by"`
	Enrolled     bool      `json:"enrolled"`
	Compliant    bool      `json:"compliant"`
	LastSyncedAt time.Time `json:"last_synced_at"`
}

HostMDMStatus reports the MDM enrollment + compliance verdict the server has on file for this host. Netclient renders this; it does not compute it.

type HostPostureStatus

type HostPostureStatus struct {
	HostID      string                 `json:"host_id"`
	EvaluatedAt time.Time              `json:"evaluated_at"`
	MDM         *HostMDMStatus         `json:"mdm,omitempty"`
	Networks    []NetworkPostureStatus `json:"networks"`
}

HostPostureStatus mirrors the server's response DTO for GET /api/v1/host/{hostid}/posture_status. The server-side definition lives in netmaker/models/posture_status.go; the netclient keeps a local mirror so it does not need to wait for the netmaker module bump.

func FetchStatus

func FetchStatus(serverName string) (*HostPostureStatus, error)

FetchStatus queries the host-authenticated posture endpoint on the named server. Pass an empty serverName to use the current server. The host's JWT is obtained via auth.Authenticate; on 401 the cached token is purged and the request is retried once.

type NetworkPostureStatus

type NetworkPostureStatus struct {
	NetworkID  string             `json:"network_id"`
	NodeID     string             `json:"node_id"`
	Severity   schema.Severity    `json:"severity"`
	Status     string             `json:"status"`
	Violations []models.Violation `json:"violations"`
}

NetworkPostureStatus holds the per-network posture verdict + any policy violations. Severity 0 means "pass".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL