logtypes

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectNames added in v1.14.0

func CollectNames(c Collection) []string

CollectNames is a helper to get the names of all log type entries in a Collection

func ParserResolver added in v1.16.0

func ParserResolver(r Resolver) pantherlog.ParserResolver

Types

type CachedResolver added in v1.15.0

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

func NewCachedResolver added in v1.15.0

func NewCachedResolver(maxAge time.Duration, r Resolver) *CachedResolver

NewCachedResolver creates a new resolver that caches entries for maxAge duration.

func (*CachedResolver) Forget added in v1.15.0

func (c *CachedResolver) Forget(name string)

func (*CachedResolver) Resolve added in v1.15.0

func (c *CachedResolver) Resolve(ctx context.Context, name string) (Entry, error)

type Collection added in v1.12.0

type Collection interface {
	Entries() []Entry
}

Collection is a collection of log type entries

type Config

type Config struct {
	Name         string
	Description  string
	ReferenceURL string
	Schema       interface{}
	NewParser    pantherlog.LogParserFactory
}

Config describes a log event type in a declarative way. To convert to an Entry instance it must be registered. The Config/LogType separation enforces mutability rules for registered log event types.

func (Config) BuildEntry added in v1.12.0

func (c Config) BuildEntry() (Entry, error)

BuildEntry implements EntryBuilder interface

func (*Config) Describe

func (c *Config) Describe() Desc

func (*Config) Validate

func (c *Config) Validate() error

Validate verifies a log type is valid

type ConfigJSON added in v1.12.0

type ConfigJSON struct {
	Name            string
	Description     string
	ReferenceURL    string
	NewEvent        func() interface{}
	Validate        func(interface{}) error
	JSON            jsoniter.API
	NextRowID       func() string
	Now             func() time.Time
	ExtraIndicators pantherlog.FieldSet
}

ConfigJSON is a configuration that creates a log type entry for a JSON log. The parser only handles the usual case where each JSON value produces a single pantherlog.Result.

func (ConfigJSON) BuildEntry added in v1.12.0

func (c ConfigJSON) BuildEntry() (Entry, error)

BuildEntry implements EntryBuilder interface

type Desc

type Desc struct {
	Name         string
	Description  string
	ReferenceURL string
}

Desc describes a log type.

func (*Desc) Fill added in v1.11.0

func (desc *Desc) Fill()

func (*Desc) Validate

func (desc *Desc) Validate() error

Validate validates the fields describing a log type.

type Entry

type Entry interface {
	Describe() Desc
	pantherlog.LogParserFactory
	Schema() interface{}
	String() string
	// Entry should be usable as an EntryBuilder that returns itself with no error
	EntryBuilder
	// Entry should implement Group for a single entry
	Group
}

Entry describes a log event type. It provides a method to create a new parser and a schema struct to derive tables from.

func MustBuild added in v1.12.0

func MustBuild(builder EntryBuilder) Entry

MustBuild builds an entry from an EntryBuilder or panics

func MustFind added in v1.12.0

func MustFind(f Finder, name string) Entry

Must find panics if a log type entry is not found

type EntryBuilder added in v1.12.0

type EntryBuilder interface {
	BuildEntry() (Entry, error)
}

EntryBuilder builds a new entry. It is used by various entry configurations (Config, ConfigJSON).

type Finder added in v1.12.0

type Finder interface {
	Find(logType string) Entry
}

Finder can find a log entry by name. It should return nil if the entry is not found.

type Group added in v1.12.0

type Group interface {
	Name() string
	Collection
	Finder
}

Group is a named collection of log type entries. The purpose of Group is to provide read-only access to a set of log types

func BuildGroup added in v1.12.0

func BuildGroup(name string, entries ...EntryBuilder) (Group, error)

BuildGroup builds a read-only collection of distinct log type entries.

func Merge added in v1.12.0

func Merge(name string, groups ...Group) (Group, error)

Merge merges log type entry groups without name conflicts

func Must added in v1.12.0

func Must(name string, entries ...EntryBuilder) Group

Must builds a group of log type entries or panics

func MustMerge added in v1.12.0

func MustMerge(name string, groups ...Group) Group

MustMerge panics the groups cannot be merged

type Resolver added in v1.11.0

type Resolver interface {
	Resolve(ctx context.Context, name string) (Entry, error)
}

Resolver resolves a log type name to it's entry. Implementations should use the context argument if they require to make network requests to resolve the entry. If an error occurred while trying to resolve the entry it should be returned (nil, err). If an entry could not be resolved but no errors occurred the implementations should return `nil, nil`.

func ChainResolvers added in v1.11.0

func ChainResolvers(resolvers ...Resolver) Resolver

ChainResolvers tries multiple resolvers in order returning the first resolved entry

func LocalResolver added in v1.12.0

func LocalResolver(finders ...Finder) Resolver

LocalResolver returns a log type resolver that looks up entries locally

type ResolverFunc added in v1.15.0

type ResolverFunc func(ctx context.Context, name string) (Entry, error)

func (ResolverFunc) Resolve added in v1.15.0

func (f ResolverFunc) Resolve(ctx context.Context, name string) (Entry, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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