table

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 5 Imported by: 56

Documentation

Overview

Package table creates an osquery table plugin.

Index

Constants

View Source
const (
	ColumnTypeText    ColumnType = "TEXT"
	ColumnTypeInteger            = "INTEGER"
	ColumnTypeBigInt             = "BIGINT"
	ColumnTypeDouble             = "DOUBLE"
)

The following column types are defined in osquery tables.h.

View Source
const (
	// DEFAULT means no special column options.
	DEFAULT ColumnOptions = iota // 0

	// INDEX treats this column as a primary key.
	INDEX = iota // 1

	// REQUIRED column MUST be included in the query predicate.
	REQUIRED = iota // 2

	// ADDITIONAL column is used to generate additional information.
	ADDITIONAL = iota + 1 // 3 + 1

	// OPTIMIZED column can be used to optimize the query.
	OPTIMIZED = iota + 4 // 4 + 4

	// HIDDEN column should be hidden from '*” selects.
	HIDDEN = iota + 11 // 5 + 11
)
View Source
const (
	OperatorEquals              Operator = 2
	OperatorGreaterThan                  = 4
	OperatorLessThanOrEquals             = 8
	OperatorLessThan                     = 16
	OperatorGreaterThanOrEquals          = 32
	OperatorMatch                        = 64
	OperatorLike                         = 65
	OperatorGlob                         = 66
	OperatorRegexp                       = 67
	OperatorUnique                       = 1
)

The following operators are dfined in osquery tables.h.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnDefinition

type ColumnDefinition struct {
	Name string
	Type ColumnType
	Op   ColumnOptions
}

ColumnDefinition defines the relevant information for a column in a table plugin. Both values are mandatory. Prefer using the *Column helpers to create ColumnDefinition structs.

func BigIntColumn

func BigIntColumn(name string, options ...ColumnOptions) ColumnDefinition

BigIntColumn is a helper for defining columns containing big integers.

func DoubleColumn

func DoubleColumn(name string, options ...ColumnOptions) ColumnDefinition

DoubleColumn is a helper for defining columns containing floating point values.

func IntegerColumn

func IntegerColumn(name string, options ...ColumnOptions) ColumnDefinition

IntegerColumn is a helper for defining columns containing integers.

func TextColumn

func TextColumn(name string, options ...ColumnOptions) ColumnDefinition

TextColumn is a helper for defining columns containing strings.

type ColumnOptions added in v0.7.0

type ColumnOptions int

ColumnOptions for marking columns

type ColumnType

type ColumnType string

ColumnType is a strongly typed representation of the data type string for a column definition. The named constants should be used.

type Constraint

type Constraint struct {
	Operator   Operator
	Expression string
}

Constraint contains both an operator and an expression that are applied as constraints in the query.

type ConstraintList

type ConstraintList struct {
	Affinity    ColumnType
	Constraints []Constraint
}

ConstraintList contains the details of the constraints for the given column.

type DeleteFunc added in v0.8.0

type DeleteFunc func(ctx context.Context, rowID int64) error

DeleteFunc is optional implementation that can be used to implement delete SQL semantics

type GenerateFunc

type GenerateFunc func(ctx context.Context, queryContext QueryContext) ([]map[string]string, error)

GenerateFunc returns the rows generated by the table. The ctx argument should be checked for cancellation if the generation performs a substantial amount of work. The queryContext argument provides the deserialized JSON query context from osquery.

type InsertFunc added in v0.8.0

type InsertFunc func(ctx context.Context, autoRowId bool, row []interface{}) ([]map[string]string, error)

InsertFunc is optional implementation that can be used to implement insert SQL semantics

type Operator

type Operator int

Operator is an enum of the osquery operators.

type Plugin

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

Plugin structure holds the plugin details.

func NewMutablePlugin added in v0.8.0

func NewMutablePlugin(name string, columns []ColumnDefinition, gen GenerateFunc, ins InsertFunc, upd UpdateFunc, del DeleteFunc) *Plugin

NewMutablePlugin is helper method to create mutable plugin structure.

func NewPlugin

func NewPlugin(name string, columns []ColumnDefinition, gen GenerateFunc) *Plugin

NewPlugin is helper method to create plugin structure.

func (*Plugin) Call

Call is invoked to generate the table contents or to get the column details.

func (*Plugin) Name

func (t *Plugin) Name() string

Name returns the plugin name.

func (*Plugin) Ping

func (t *Plugin) Ping() osquery.ExtensionStatus

Ping returns static OK response.

func (*Plugin) RegistryName

func (t *Plugin) RegistryName() string

RegistryName returns the plugin type, which is always "table" for table plugin.

func (*Plugin) Routes

Routes returns the table columns definitions.

func (*Plugin) Shutdown

func (t *Plugin) Shutdown()

Shutdown is a no-op for table plugins.

type QueryContext

type QueryContext struct {
	// Constraints is a map from column name to the details of the
	// constraints on that column.
	Constraints map[string]ConstraintList
}

QueryContext contains the constraints from the WHERE clause of the query, that can optionally be used to optimize the table generation. Note that the osquery SQLite engine will perform the filtering with these constraints, so it is not mandatory that they be used in table generation.

type UpdateFunc added in v0.8.0

type UpdateFunc func(ctx context.Context, rowID int64, row []interface{}) error

UpdateFunc is optional implementation that can be used to implement update SQL semantics

Jump to

Keyboard shortcuts

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