model

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertSchemaVersion = "v0"
)

Variables

This section is empty.

Functions

func SelectPolicyAll

func SelectPolicyAll(meta *PolicyMetadata) bool

Types

type Alert

type Alert struct {
	// ID is unique identifier of alert. It would be used for aggregation. If ID is empty, it will be generated automatically.
	ID AlertID `json:"id"`

	// Version is schema version of alert. It should be overwritten with AlertSchemaVersion.
	Version string `json:"version"`

	// Title is short description of alert. It's required.
	Title string `json:"title"`

	// Description is detailed description of alert.
	Description string `json:"description"`

	// Timestamp is time when alert is generated. If Timestamp is zero, it will be set to current time.
	Timestamp time.Time `json:"timestamp"`

	// Attrs is key-value pairs of additional information of alert.
	Attrs Attrs `json:"attrs"`
}

func (*Alert) Finalize added in v0.0.3

func (x *Alert) Finalize(ctx context.Context)

func (Alert) Validate added in v0.0.3

func (x Alert) Validate() error

type AlertID

type AlertID string

func NewAlertID added in v0.0.3

func NewAlertID() AlertID

type Attrs

type Attrs map[string]any

type JobID

type JobID string

func NewJobID

func NewJobID() JobID

type PolicyMetadata

type PolicyMetadata struct {
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Tags        []string  `json:"tags"`
	Input       []QueryID `json:"input"`
	Package     string    `json:"package"`
	Location    string    `json:"location"`
}

func NewPolicyMetadataFromAnnotation

func NewPolicyMetadataFromAnnotation(ref *ast.AnnotationsRef) (*PolicyMetadata, error)

func (*PolicyMetadata) HasAnyTag added in v0.0.3

func (x *PolicyMetadata) HasAnyTag(tags []string) bool

func (*PolicyMetadata) HasTag

func (x *PolicyMetadata) HasTag(tag string) bool

type PolicyMetadataSet

type PolicyMetadataSet []*PolicyMetadata

func NewPolicyMetadataSetFromAnnotation

func NewPolicyMetadataSetFromAnnotation(refs ast.FlatAnnotationsRefSet) (PolicyMetadataSet, error)

func (PolicyMetadataSet) Filter

func (PolicyMetadataSet) RequiredQueries

func (x PolicyMetadataSet) RequiredQueries(base Queries) Queries

type PolicySelector

type PolicySelector func(meta *PolicyMetadata) bool

func SelectPolicyByTag

func SelectPolicyByTag(tags ...string) PolicySelector

type Queries

type Queries []*Query

func (Queries) FindByID

func (x Queries) FindByID(id QueryID) *Query

func (Queries) Validate

func (x Queries) Validate() error

type Query

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

func MustNewQuery

func MustNewQuery(name string, data []byte) *Query

func NewQuery

func NewQuery(name string, data []byte) (*Query, error)

func (*Query) ID

func (x *Query) ID() QueryID

func (*Query) String

func (x *Query) String() string

func (*Query) Validate

func (x *Query) Validate() error

type QueryID

type QueryID string

type QueryInput

type QueryInput map[QueryID]any

type QueryOutput

type QueryOutput struct {
	Alert []Alert `json:"alert"`
}

Jump to

Keyboard shortcuts

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