validator

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadQuery         = errors.New("bad query")
	ErrComplicatedQuery = errors.New("complicated query")
	ErrAccessDenied     = errors.New("access denied")
	ErrUnknownTable     = errors.New("unknown table")
	ErrUnknownColumn    = errors.New("unknown column")
)

Functions

func GetColumnNames

func GetColumnNames(req tree.NodeFormatter) ([]string, error)

GetColumnNames will return all mentioned columns from query. Note: It will have unexpected behavior for queries that have a subquery.

func IsAllowed

func IsAllowed(tables []config.TargetTable, haveAccess func(Vec) bool, query string) error

IsAllowed will tokenize query, validate schema and check access after all.

func ValidateAccess added in v0.12.0

func ValidateAccess(vectors []Vec, haveAccess func(Vec) bool) error

ValidateAccess check that all vectors is allowed to run.

func ValidateSchema added in v0.12.0

func ValidateSchema(vectors []Vec, tables []config.TargetTable) error

ValidateSchema will check that request contains only allowed columns.

func Walk

func Walk(collect ICollect, statements ...tree.NodeFormatter) error

Types

type ICollect added in v0.5.0

type ICollect func(tree.NodeFormatter)

func CollectAll added in v0.5.0

func CollectAll(funcs ...ICollect) ICollect

type TypeCollector added in v0.5.0

type TypeCollector[T tree.NodeFormatter] struct {
	// contains filtered or unexported fields
}

func CollectType added in v0.5.0

func CollectType[T tree.NodeFormatter]() *TypeCollector[T]

func (*TypeCollector[T]) Collect added in v0.5.0

func (c *TypeCollector[T]) Collect(node tree.NodeFormatter)

func (*TypeCollector[T]) Res added in v0.5.0

func (c *TypeCollector[T]) Res() []T

type Vec added in v0.5.0

type Vec struct {
	Op   config.Op
	Tbl  string
	Cols []string
}

func MakeSelectVec

func MakeSelectVec(req *tree.Select) (*Vec, error)

func MakeVectors added in v0.12.0

func MakeVectors(query string) ([]Vec, error)

MakeVectors create vectors from query.

func (Vec) String added in v0.5.0

func (v Vec) String() string

Jump to

Keyboard shortcuts

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