engine

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Rules        []Rule    `json:"rules"`
	CallbackWait *Duration `json:"callback_wait"`
}

type Duration added in v1.8.0

type Duration time.Duration

Duration is a time.Duration that reads from JSON as a duration string, so a config says "100ms" rather than 100000000. A bare number would be nanoseconds, which is a trap: "callback_wait": 100 means 100ns, not 100ms.

func (Duration) MarshalJSON added in v1.8.0

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON added in v1.8.0

func (d *Duration) UnmarshalJSON(data []byte) error

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New() (*Engine, error)

func (*Engine) CallbackWait added in v1.8.0

func (e *Engine) CallbackWait() time.Duration

CallbackWait returns the delay applied before delivering a callback.

func (*Engine) LoadConfig

func (e *Engine) LoadConfig(reader io.Reader) error

func (*Engine) Process

func (e *Engine) Process(contents io.Reader) (Result, error)

func (*Engine) QueueCallback added in v1.1.0

func (e *Engine) QueueCallback(c string, r *Result)

func (*Engine) RuleCount

func (e *Engine) RuleCount() int

func (*Engine) SetCallbackWait added in v1.8.0

func (e *Engine) SetCallbackWait(wait time.Duration)

SetCallbackWait overrides how long the engine waits before delivering a callback. It takes effect for callbacks that have not been delivered yet, which is what lets --callback-wait win over a config file loaded before it.

type Result

type Result struct {
	ID            string
	Sha1          string
	Sha256        string
	ContentLength uint64
	Findings      []string
	ContentType   string
	CreationDate  string
	Metadata      map[string]string
	Error         string
}

type Rule

type Rule struct {
	Format  string `json:"format"`
	Content string `json:"content"`
	Result  string `json:"result"`
}

Jump to

Keyboard shortcuts

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