engine

package
v4.22.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0 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 engine compiles a feed's rules into what the sensor can run, and reports, per rule, whether it compiled. That report is the whole basis for the console calling a rule "protecting": a rule this package could not compile, or has no engine for, is never shown as running.

Engines:

  • MODSECURITY and the generated virtual patches in that format run on Coraza, in detection-only mode: Coraza says which rule matched and the verdict engine decides what to do about it.

  • REGEX_L7 runs on Go's RE2. A pattern that needs PCRE (lookaround, backreferences) is rejected with that reason rather than approximated.

  • STIX and OpenIOC become sets of domains, IP addresses and file hashes for the egress proxy, the DNS check and the file scan. So does IOC_LIST, the line-per-indicator list the site serves for catalog: and org: feeds (ioc.go addList).

  • SIGMA rules for process_creation run against process starts (sigma.go).

  • YARA rules in the subset yara.go evaluates run against the binary of each process start.

Snort, Suricata, AWS WAF, Cloudflare and nginx rules are loaded as no-engine: this sensor build cannot run them, and says so.

Index

Constants

View Source
const (
	Compiled = "compiled"
	Rejected = "rejected"
	NoEngine = "no-engine"
)

Load statuses, as the runtime API names them.

View Source
const MaxYaraFile = 64 << 20

MaxYaraFile bounds a file the sensor evaluates YARA rules against.

Variables

This section is empty.

Functions

func Compile

func Compile(rules []feed.Rule) (*Set, []Result)

Compile builds a Set from rules and returns each rule's outcome. A disabled rule is reported as rejected ("disabled in the feed") and never runs.

Types

type Hit

type Hit struct {
	Rule   decide.RuleRef
	Detail string
}

Hit is one rule matching one request.

type IOCSet

type IOCSet struct {
	Domains map[string]decide.RuleRef
	IPs     map[string]decide.RuleRef
	Hashes  map[string]decide.RuleRef
}

IOCSet is the indicators the sensor can check without a rule engine: a domain someone resolves or connects to, an address someone connects to, a file hash on disk. Each indicator remembers the rule it came from, so a hit is reported against that rule.

func (IOCSet) Len

func (s IOCSet) Len() int

Len is the number of indicators.

func (IOCSet) MatchHash

func (s IOCSet) MatchHash(hexDigest string) (decide.RuleRef, bool)

MatchHash checks a hex digest of any length the feed carried.

func (IOCSet) MatchHost

func (s IOCSet) MatchHost(host string) (decide.RuleRef, string, bool)

MatchHost checks a hostname or address, and every parent domain of a hostname: an indicator for evil.example covers c2.evil.example.

type Process

type Process struct {
	Image             string
	CommandLine       string
	ParentImage       string
	ParentCommandLine string
	CurrentDirectory  string
	User              string
}

Process is the event a Sigma rule is evaluated against.

type Result

type Result struct {
	Rule   feed.Rule
	Status string
	Reason string
}

Result is one rule's load outcome.

type Set

type Set struct {
	IOC IOCSet
	// contains filtered or unexported fields
}

Set is everything compiled from one or more feeds.

func (*Set) HasFileRules

func (s *Set) HasFileRules() bool

HasFileRules reports whether any YARA rule is loaded.

func (*Set) HasProcessRules

func (s *Set) HasProcessRules() bool

HasProcessRules reports whether anything checks process starts.

func (*Set) InspectRequest

func (s *Set) InspectRequest(r *http.Request, body []byte) []Hit

InspectRequest runs the HTTP engines over one request. body is what was buffered of it, possibly cut short.

func (*Set) MatchFile

func (s *Set) MatchFile(data []byte) []Hit

MatchFile evaluates the YARA rules against a file's bytes.

func (*Set) MatchProcess

func (s *Set) MatchProcess(p Process) []Hit

MatchProcess evaluates the Sigma rules against one process start.

Jump to

Keyboard shortcuts

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