posture

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NBVersionCheckName        = "NBVersionCheck"
	OSVersionCheckName        = "OSVersionCheck"
	GeoLocationCheckName      = "GeoLocationCheck"
	PeerNetworkRangeCheckName = "PeerNetworkRangeCheck"

	CheckActionAllow string = "allow"
	CheckActionDeny  string = "deny"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check interface {
	Check(peer nbpeer.Peer) (bool, error)
	Name() string
}

Check represents an interface for performing a check on a peer.

type Checks

type Checks struct {
	// ID of the posture checks
	ID string `gorm:"primaryKey"`

	// Name of the posture checks
	Name string

	// Description of the posture checks visible in the UI
	Description string

	// AccountID is a reference to the Account that this object belongs
	AccountID string `json:"-" gorm:"index"`

	// Checks is a set of objects that perform the actual checks
	Checks ChecksDefinition `gorm:"serializer:json"`
}

func NewChecksFromAPIPostureCheck

func NewChecksFromAPIPostureCheck(source api.PostureCheck) (*Checks, error)

func NewChecksFromAPIPostureCheckUpdate

func NewChecksFromAPIPostureCheckUpdate(source api.PostureCheckUpdate, postureChecksID string) (*Checks, error)

func (*Checks) Copy

func (pc *Checks) Copy() *Checks

Copy returns a copy of a posture checks.

func (*Checks) EventMeta

func (pc *Checks) EventMeta() map[string]any

EventMeta returns activity event meta-related to this posture checks.

func (*Checks) GetChecks

func (pc *Checks) GetChecks() []Check

GetChecks returns list of all initialized checks definitions

func (*Checks) TableName

func (*Checks) TableName() string

TableName returns the name of the table for the Checks model in the database.

func (*Checks) ToAPIResponse

func (pc *Checks) ToAPIResponse() *api.PostureCheck

func (*Checks) Validate

func (pc *Checks) Validate() error

type ChecksDefinition

type ChecksDefinition struct {
	NBVersionCheck        *NBVersionCheck        `json:",omitempty"`
	OSVersionCheck        *OSVersionCheck        `json:",omitempty"`
	GeoLocationCheck      *GeoLocationCheck      `json:",omitempty"`
	PeerNetworkRangeCheck *PeerNetworkRangeCheck `json:",omitempty"`
}

ChecksDefinition contains definition of actual check

func (ChecksDefinition) Copy

Copy returns a copy of a checks definition.

type GeoLocationCheck

type GeoLocationCheck struct {
	// Locations list of geolocations, to which the policy applies
	Locations []Location

	// Action to take upon policy match
	Action string
}

func (*GeoLocationCheck) Check

func (g *GeoLocationCheck) Check(peer nbpeer.Peer) (bool, error)

func (*GeoLocationCheck) Name

func (g *GeoLocationCheck) Name() string

type Location

type Location struct {
	// CountryCode 2-letter ISO 3166-1 alpha-2 code that represents the country
	CountryCode string

	// CityName Commonly used English name of the city
	CityName string
}

type MinKernelVersionCheck

type MinKernelVersionCheck struct {
	MinKernelVersion string
}

type MinVersionCheck

type MinVersionCheck struct {
	MinVersion string
}

type NBVersionCheck

type NBVersionCheck struct {
	MinVersion string
}

func (*NBVersionCheck) Check

func (n *NBVersionCheck) Check(peer nbpeer.Peer) (bool, error)

func (*NBVersionCheck) Name

func (n *NBVersionCheck) Name() string

type OSVersionCheck

type OSVersionCheck struct {
	Android *MinVersionCheck
	Darwin  *MinVersionCheck
	Ios     *MinVersionCheck
	Linux   *MinKernelVersionCheck
	Windows *MinKernelVersionCheck
}

func (*OSVersionCheck) Check

func (c *OSVersionCheck) Check(peer nbpeer.Peer) (bool, error)

func (*OSVersionCheck) Name

func (c *OSVersionCheck) Name() string

type PeerNetworkRangeCheck

type PeerNetworkRangeCheck struct {
	Action string
	Ranges []netip.Prefix `gorm:"serializer:json"`
}

func (*PeerNetworkRangeCheck) Check

func (p *PeerNetworkRangeCheck) Check(peer nbpeer.Peer) (bool, error)

func (*PeerNetworkRangeCheck) Name

func (p *PeerNetworkRangeCheck) Name() string

Jump to

Keyboard shortcuts

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