detection

package
v0.0.0-...-c97ac92 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooShortMatcher = errors.New("too short matcher string")
	ErrTooShortNode    = errors.New("too short node string")
	ErrInvalidBounds   = errors.New("invalid surrounding bounds")
	ErrInvalidContent  = errors.New("invalid matcher content")
	ErrMalformedGroup  = errors.New("malformed groups")
	ErrMalformedTree   = errors.New("malformed tree structure: have children and matches")
)

Functions

func MDC1

func MDC1(asset *model.Asset, cve *model.CVE) bool

MDC1 performs a CVE's configuration check for an asset using the MDC1 algorithm. As it is based on a CPE and configurations, it wraps the actual algorithm. Such check should be performed on each node for an alone-vulnerable detection, before a tree mode using the MDCN algorithm.

Types

type Matcher

type Matcher struct {
	// SuperCPE23 is the CPE v2.3 containing the SubCPE23.
	SuperCPE23 string
	// SubCPE23 is the CPE v2.3 that is contained by SuperCPE23.
	// As it is defined, it is the Asset one. This imply that
	// the actual version used for bound check is stored in it.
	SubCPE23 string

	// Vulnerable defines whether this Matcher is one of the
	// vulnerable one or not.
	// If true, it implies that this Matcher triggered a part or
	// all of the detection.
	// This concept does not exist in MDC1, as the notion of
	// context does not exist too.
	Vulnerable bool

	VersionStartIncluding *string
	VersionStartExcluding *string
	VersionEndIncluding   *string
	VersionEndExcluding   *string
}

Matcher defines a single-node matching explanation. In case it is used to represent a CVE-Asset match, it explains that the SuperCPE23 contains the SubCPE23, and if version bounds are defined, why.

func ParseMatcher

func ParseMatcher(input string) (*Matcher, error)

ParseMatcher parses a single Matcher string and returns an object representing it, or an error.

func (Matcher) String

func (m Matcher) String() string

type Node

type Node struct {
	Operator string
	Children []*Node
	Matchers []*Matcher
}

Node represents a circuit path of a CVE configuration. It could be used to explain what matched, or what did not. Remember that it does not handle the semantic of effectively vulnerable or not, as it is only a tool to represent wether it matched or not. Such semantic is handled by how the Node is used. It could be used to perform tracability on detections. It looks like a NVD configuration, because it represents an evaluation of a circuit. The root of a Node tree is called a Circuit.

func ParseNode

func ParseNode(input string) (*Node, error)

func (Node) String

func (n Node) String() string

Jump to

Keyboard shortcuts

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