edr

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: 13 Imported by: 0

Documentation

Overview

Package edr defines the pluggable EDR provider interface and registry used by the Netmaker EDR posture-check feature.

Index

Constants

View Source
const (
	ProviderDefender    = "defender"
	ProviderCrowdStrike = "crowdstrike"
	ProviderSentinelOne = "sentinelone"
	ProviderWazuh       = "wazuh"
)
View Source
const (
	RiskNone     = "none"
	RiskLow      = "low"
	RiskMedium   = "medium"
	RiskHigh     = "high"
	RiskCritical = "critical"
	RiskUnknown  = "unknown"
)

Risk levels in ascending severity order.

Variables

View Source
var (
	ErrDeviceNotFoundInEDR = errors.New("device_not_found_in_edr")
)

Functions

func ActiveProviderID

func ActiveProviderID(ctx context.Context) (string, error)

func CrowdStrikeContainedFromStatus

func CrowdStrikeContainedFromStatus(status string) bool

CrowdStrikeContainedFromStatus reports whether Falcon status is contained.

func CrowdStrikeHealthyFromStatus

func CrowdStrikeHealthyFromStatus(status string) bool

CrowdStrikeHealthyFromStatus reports good operations per Falcon (status normal).

func GetActive

func GetActive(ctx context.Context) (*schema.Integration, error)

func LookupErrorCode

func LookupErrorCode(err error) string

func MatchHostToEndpoint

func MatchHostToEndpoint(providerID string, h schema.Host, ep ManagedEndpoint) (matchedBy string, ok bool)

func RedactConfig

func RedactConfig(providerID string, configJSON json.RawMessage) (json.RawMessage, error)

func RefreshHostEDRState

func RefreshHostEDRState(ctx context.Context, h schema.Host) error

RefreshHostEDRState syncs EDR posture state for a single host before join or registration posture evaluation. It does not honour the global sync rate limit.

func Register

func Register(name, display string, f Factory)

func RegisterCapabilities

func RegisterCapabilities(name string, c Capabilities)

func RiskExceeds

func RiskExceeds(maxAllowed, actual RiskLevel) bool

RiskExceeds reports whether actual risk is strictly greater than max allowed.

func RunEDRSync

func RunEDRSync(ctx context.Context) error

func RunEDRSyncForPosture

func RunEDRSyncForPosture(ctx context.Context) error

RunEDRSyncForPosture runs a full EDR sync before the posture evaluation cycle, ignoring sync_enabled and the rate limit.

func RunEDRSyncForce

func RunEDRSyncForce(ctx context.Context) error

func SerialMatch

func SerialMatch(hostSerial, deviceSerial string) bool

SerialMatch reports whether two serial numbers refer to the same device.

func SyncHostEDRState

func SyncHostEDRState(ctx context.Context, hostID string) error

SyncHostEDRState refreshes EDR posture state for one host from the active provider. Called after check-in when device-matching identifiers change.

func ValidateConfig

func ValidateConfig(providerID string, configJSON json.RawMessage) error

func WazuhHealthyFromStatus

func WazuhHealthyFromStatus(status string) bool

WazuhHealthyFromStatus reports whether a Wazuh agent is connected and reporting.

Types

type Capabilities

type Capabilities struct {
	ReportsRisk bool
}

Capabilities advertises optional provider features.

func CapabilitiesFor

func CapabilitiesFor(name string) Capabilities

type CrowdStrikeConfig

type CrowdStrikeConfig struct {
	SyncSettings
	BaseURL      string `json:"base_url"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

CrowdStrikeConfig is stored in integrations_v1.config for CrowdStrike Falcon.

type DefenderConfig

type DefenderConfig struct {
	SyncSettings
	TenantID     string `json:"tenant_id"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

DefenderConfig is stored in integrations_v1.config for Microsoft Defender for Endpoint.

type Factory

type Factory func(config json.RawMessage) (Provider, error)

type HostEndpointLookup

type HostEndpointLookup interface {
	LookupForHost(ctx context.Context, h schema.Host) (ManagedEndpoint, string, error)
}

HostEndpointLookup resolves a host using provider-specific filtered queries (e.g. serial_number) without listing the full fleet.

type ManagedEndpoint

type ManagedEndpoint struct {
	ProviderDeviceID string
	SerialNumber     string
	Hostname         string
	EntraDeviceID    string

	AgentInstalled bool
	AgentHealthy   bool
	RiskLevel      RiskLevel
	ThreatCount    int
	ActiveThreats  bool
	Isolated       bool
	Contained      bool
	LastSeen       time.Time

	RawVendorData json.RawMessage
}

ManagedEndpoint is the provider-agnostic view of an endpoint returned by EDR integrations. Normalized posture fields are populated by each provider.

type Provider

type Provider interface {
	Name() string
	Capabilities() Capabilities
	Verify(ctx context.Context) error
	ListManagedEndpoints(ctx context.Context) ([]ManagedEndpoint, error)
}

Provider is the minimal contract every EDR integration must satisfy.

func Build

func Build(name string, config json.RawMessage) (Provider, error)

func BuildActive

func BuildActive(ctx context.Context) (Provider, error)

type ProviderType

type ProviderType struct {
	Name        string `json:"name"`
	Display     string `json:"display"`
	ReportsRisk bool   `json:"reports_risk"`
}

ProviderType describes a registered provider for API listing.

func ListProviderTypes

func ListProviderTypes() []ProviderType

type RiskLevel

type RiskLevel string

RiskLevel is the vendor-agnostic endpoint risk classification.

func ComputeRiskLevel

func ComputeRiskLevel(s VendorSignals) RiskLevel

ComputeRiskLevel maps vendor signals to a vendor-agnostic risk level.

func CrowdStrikeRiskFromStatus

func CrowdStrikeRiskFromStatus(status string) RiskLevel

CrowdStrikeRiskFromStatus maps Falcon containment status to normalized level. Documented values: normal, containment_pending, contained, lift_containment_pending.

func DefenderRiskFromScore

func DefenderRiskFromScore(score string) RiskLevel

DefenderRiskFromScore maps Microsoft Defender riskScore to normalized level.

func ParseRiskLevel

func ParseRiskLevel(level string) RiskLevel

ParseRiskLevel normalizes a risk level string.

func SentinelOneRiskFromAgent

func SentinelOneRiskFromAgent(infected bool, networkQuarantine bool, activeThreats int) RiskLevel

SentinelOneRiskFromAgent maps SentinelOne agent fields to vendor risk hint.

func WazuhRiskFromStatus

func WazuhRiskFromStatus(status string) RiskLevel

WazuhRiskFromStatus maps Wazuh agent status to vendor risk hint.

type SentinelOneConfig

type SentinelOneConfig struct {
	SyncSettings
	ConsoleURL string `json:"console_url"`
	APIToken   string `json:"api_token"`
}

SentinelOneConfig is stored in integrations_v1.config for SentinelOne.

type SerialLookup

type SerialLookup interface {
	LookupBySerial(ctx context.Context, serial string) (ManagedEndpoint, error)
}

SerialLookup is implemented by EDR providers that can resolve a host by serial_number via a targeted API query instead of listing all endpoints.

type SyncSettings

type SyncSettings struct {
	SyncEnabled         bool `json:"sync_enabled"`
	SyncIntervalMinutes int  `json:"sync_interval_minutes"`
}

SyncSettings are shared across EDR provider configs.

func ParseSyncSettings

func ParseSyncSettings(providerID string, configJSON json.RawMessage) (SyncSettings, error)

type VendorSignals

type VendorSignals struct {
	AgentInstalled   bool
	AgentHealthy     bool
	Isolated         bool
	Contained        bool
	ActiveThreats    bool
	ActiveMalware    bool
	ActiveRansomware bool
	ThreatCount      int
	VendorRiskLevel  RiskLevel
}

VendorSignals are provider-specific inputs normalized into RiskLevel.

type WazuhConfig

type WazuhConfig struct {
	SyncSettings
	ManagerURL         string `json:"manager_url"`
	Username           string `json:"username"`
	Password           string `json:"password"`
	InsecureSkipVerify bool   `json:"insecure_skip_verify"`
}

WazuhConfig is stored in integrations_v1.config for Wazuh.

func ParseWazuhConfig

func ParseWazuhConfig(configJSON json.RawMessage) (WazuhConfig, error)

Directories

Path Synopsis
Package crowdstrike implements an EDR provider backed by CrowdStrike Falcon.
Package crowdstrike implements an EDR provider backed by CrowdStrike Falcon.
Package defender implements an EDR provider backed by Microsoft Defender for Endpoint via the WindowsDefenderATP API.
Package defender implements an EDR provider backed by Microsoft Defender for Endpoint via the WindowsDefenderATP API.
Package sentinelone implements an EDR provider backed by SentinelOne.
Package sentinelone implements an EDR provider backed by SentinelOne.
Package wazuh implements an EDR provider backed by the Wazuh server API.
Package wazuh implements an EDR provider backed by the Wazuh server API.

Jump to

Keyboard shortcuts

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