nodes

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActiveNodes to represent active nodes
	ActiveNodes = "active"
	// InactiveNodes to represent inactive nodes
	InactiveNodes = "inactive"
	// AllNodes to represent all nodes
	AllNodes = "all"
)

Variables

This section is empty.

Functions

func CacheFullKeyByNodeKey added in v0.4.4

func CacheFullKeyByNodeKey(n OsqueryNode) string

Helper to generate the key to identify a full node in the cache, by node_key

func CacheFullKeyByUUID added in v0.4.4

func CacheFullKeyByUUID(n OsqueryNode) string

Helper to generate the key to identify a full node in the cache, by UUID

func CacheFullKeyRaw added in v0.4.4

func CacheFullKeyRaw(identifier string, envID uint) string

Helper to generate the key to identify a full node in the cache

func CachePartialKeyByNodeKey added in v0.4.4

func CachePartialKeyByNodeKey(n OsqueryNode) string

Helper to generate the key to identify partially node in the cache, by node_key

func CachePartialKeyByUUID added in v0.4.4

func CachePartialKeyByUUID(n OsqueryNode) string

Helper to generate the key to identify partially node in the cache, by UUID

func CachePartialKeyRaw added in v0.4.4

func CachePartialKeyRaw(identifier string, envID uint) string

Helper to generate the key to identify partially node in the cache

func IsActive

func IsActive(n OsqueryNode, inactive int64) bool

Helper to get what is the last seen time for a node, inactive should be negative to check for past activity

Types

type ArchiveOsqueryNode

type ArchiveOsqueryNode struct {
	gorm.Model
	NodeKey         string `gorm:"index"`
	UUID            string `gorm:"index"`
	Trigger         string
	Platform        string
	PlatformVersion string
	OsqueryVersion  string
	Hostname        string
	Localname       string
	IPAddress       string
	Username        string
	OsqueryUser     string
	Environment     string
	CPU             string
	Memory          string
	HardwareSerial  string
	ConfigHash      string
	DaemonHash      string
	BytesReceived   int
	RawEnrollment   string
	LastSeen        time.Time
	UserID          uint
	EnvironmentID   uint
	ExtraData       string
}

ArchiveOsqueryNode as abstraction of an archived node

type NodeManager

type NodeManager struct {
	DB    *gorm.DB
	Cache *redis.Client
}

NodeManager to handle all nodes of the system

func CreateNodes

func CreateNodes(backend *gorm.DB, cache *redis.Client) *NodeManager

CreateNodes to initialize the nodes struct and its tables

func (*NodeManager) Archive

func (n *NodeManager) Archive(uuid, trigger string) error

Archive to archive osquery node by UUID

func (*NodeManager) ArchiveDeleteByUUID

func (n *NodeManager) ArchiveDeleteByUUID(uuid string) error

ArchiveDeleteByUUID to archive and delete an existing node record by UUID

func (*NodeManager) CheckByHost

func (n *NodeManager) CheckByHost(host string) bool

CheckByHost to check if node exists by Hostname

func (*NodeManager) CheckByKey

func (n *NodeManager) CheckByKey(nodeKey string) bool

CheckByKey to check if node exists by node_key node_key is expected lowercase

func (*NodeManager) CheckByUUID

func (n *NodeManager) CheckByUUID(uuid string) bool

CheckByUUID to check if node exists by UUID UUID is expected uppercase

func (*NodeManager) CheckByUUIDEnv

func (n *NodeManager) CheckByUUIDEnv(uuid, environment string) bool

CheckByUUIDEnv to check if node exists by UUID in a specific environment UUID is expected uppercase

func (*NodeManager) CheckByUUIDEnvID

func (n *NodeManager) CheckByUUIDEnvID(uuid string, envID int) bool

CheckByUUIDEnvID to check if node exists by UUID in a specific environment UUID is expected uppercase

func (*NodeManager) Create

func (n *NodeManager) Create(node *OsqueryNode) error

Create to insert new osquery node generating new node_key

func (*NodeManager) GetAllPlatforms

func (n *NodeManager) GetAllPlatforms() ([]string, error)

GetAllPlatforms to get all different platform with nodes in them

func (*NodeManager) GetByEnv

func (n *NodeManager) GetByEnv(environment, target string, hours int64) ([]OsqueryNode, error)

GetByEnv to retrieve target nodes by environment

func (*NodeManager) GetByIdentifier

func (n *NodeManager) GetByIdentifier(identifier string) (OsqueryNode, error)

GetByIdentifier to retrieve full node object from DB, by uuid or hostname or localname UUID is expected uppercase

func (*NodeManager) GetByKey

func (n *NodeManager) GetByKey(nodekey string) (OsqueryNode, error)

GetByKey to retrieve full node object from DB, by node_key node_key is expected lowercase

func (*NodeManager) GetByPlatform

func (n *NodeManager) GetByPlatform(platform, target string, hours int64) ([]OsqueryNode, error)

GetByPlatform to retrieve target nodes by platform

func (*NodeManager) GetBySelector

func (n *NodeManager) GetBySelector(stype, selector, target string, hours int64) ([]OsqueryNode, error)

GetBySelector to retrieve target nodes by selector

func (*NodeManager) GetByUUID

func (n *NodeManager) GetByUUID(uuid string) (OsqueryNode, error)

GetByUUID to retrieve full node object from DB, by uuid UUID is expected uppercase

func (*NodeManager) GetByUUIDEnv

func (n *NodeManager) GetByUUIDEnv(uuid string, envid uint) (OsqueryNode, error)

GetByUUIDEnv to retrieve full node object from DB, by uuid and environment ID UUID is expected uppercase

func (*NodeManager) GetEnvPlatforms

func (n *NodeManager) GetEnvPlatforms(environment string) ([]string, error)

GetEnvPlatforms to get the platforms with nodes in them by environment

func (*NodeManager) GetFullFromCache added in v0.4.4

func (n *NodeManager) GetFullFromCache(uuid string, envID uint, ctx context.Context) (OsqueryNode, error)

GetFullFromCache returns the full node from the cache by node UUID and environment ID

func (*NodeManager) GetPartialFromCache added in v0.4.4

func (n *NodeManager) GetPartialFromCache(nodeKey string, envID uint, ctx context.Context) (OsqueryNode, error)

GetPartialFromCache returns the partial node from the cache by node key and environment ID

func (*NodeManager) GetStatsByEnv

func (n *NodeManager) GetStatsByEnv(environment string, hours int64) (StatsData, error)

GetStatsByEnv to populate table stats about nodes by environment. Active machine is < 3 days

func (*NodeManager) GetStatsByPlatform

func (n *NodeManager) GetStatsByPlatform(platform string, hours int64) (StatsData, error)

GetStatsByPlatform to populate table stats about nodes by platform. Active machine is < 3 days

func (*NodeManager) Gets

func (n *NodeManager) Gets(target string, hours int64) ([]OsqueryNode, error)

Gets to retrieve all/active/inactive nodes

func (*NodeManager) IncreaseBytes

func (n *NodeManager) IncreaseBytes(node OsqueryNode, incBytes int) error

IncreaseBytes to update received bytes per node

func (*NodeManager) MetadataRefresh

func (n *NodeManager) MetadataRefresh(node OsqueryNode, updates map[string]interface{}) error

MetadataRefresh to perform all needed update operations per node to keep metadata refreshed

func (*NodeManager) NewHistoryEntry

func (n *NodeManager) NewHistoryEntry(entry interface{}) error

NewHistoryEntry to insert new entry for the history of Hostnames

func (*NodeManager) RefreshLastSeenBatch added in v0.4.4

func (n *NodeManager) RefreshLastSeenBatch(nodeID []uint) error

func (*NodeManager) SetFullCached added in v0.4.4

func (n *NodeManager) SetFullCached(node OsqueryNode, ctx context.Context) error

SetFullCached sets the provided full node in the cache, default expiration is 1 hour

func (*NodeManager) SetPartialCached added in v0.4.4

func (n *NodeManager) SetPartialCached(node OsqueryNode, ctx context.Context) error

SetPartialCached sets the provided partial node in the cache, default expiration is 1 hour

func (*NodeManager) UpdateByUUID

func (n *NodeManager) UpdateByUUID(data OsqueryNode, uuid string) error

UpdateByUUID to update an existing node record by UUID

func (*NodeManager) UpdateIP added in v0.4.4

func (n *NodeManager) UpdateIP(nodeID uint, ip string) error

func (*NodeManager) UpdateMetadataByUUID

func (n *NodeManager) UpdateMetadataByUUID(uuid string, metadata NodeMetadata) error

UpdateMetadataByUUID to update node metadata by UUID

type NodeMetadata

type NodeMetadata struct {
	IPAddress       string
	Username        string
	OsqueryUser     string
	Hostname        string
	Localname       string
	ConfigHash      string
	DaemonHash      string
	OsqueryVersion  string
	Platform        string
	PlatformVersion string
	BytesReceived   int
}

NodeMetadata to hold metadata for a node

type OsqueryNode

type OsqueryNode struct {
	gorm.Model
	NodeKey         string `gorm:"index"`
	UUID            string `gorm:"index"`
	Platform        string
	PlatformVersion string
	OsqueryVersion  string
	Hostname        string
	Localname       string
	IPAddress       string
	Username        string
	OsqueryUser     string
	Environment     string
	CPU             string
	Memory          string
	HardwareSerial  string
	DaemonHash      string
	ConfigHash      string
	BytesReceived   int
	RawEnrollment   string
	LastSeen        time.Time
	UserID          uint
	EnvironmentID   uint
	ExtraData       string
}

OsqueryNode as abstraction of a node

type StatsData

type StatsData struct {
	Total    int64 `json:"total"`
	Active   int64 `json:"active"`
	Inactive int64 `json:"inactive"`
}

StatsData to display node stats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳