source

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// QueryFileName The default query file name
	QueryFileName = "query.rego"
	// MetadataFileName The default metadata file name
	MetadataFileName = "metadata.json"
	// LibraryFileName The default library file name
	LibraryFileName = "library.rego"
	// LibrariesDefaultBasePath the path to rego libraries
	LibrariesDefaultBasePath = "./assets/libraries/"
)

Variables

This section is empty.

Functions

func GetPathToLibrary

func GetPathToLibrary(platform, relativeBasePath string) string

GetPathToLibrary returns the libraries path for a given platform

func ListSupportedPlatforms

func ListSupportedPlatforms() []string

ListSupportedPlatforms returns a list of supported platforms

func ReadMetadata

func ReadMetadata(queryDir string) map[string]interface{}

ReadMetadata read query's metadata file inside the query directory

func ReadQuery

func ReadQuery(queryDir string) (model.QueryMetadata, error)

ReadQuery reads query's files for a given path and returns a QueryMetadata struct with it's content

Types

type ExcludeQueries

type ExcludeQueries struct {
	ByIDs        []string
	ByCategories []string
}

ExcludeQueries represents a struct with options to exclude queries and a list for each option

type FilesystemSource

type FilesystemSource struct {
	Source string
	Types  []string
}

FilesystemSource this type defines a struct with a path to a filesystem source of queries Source is the path to the queries Types are the types given by the flag --type for query selection mechanism

func NewFilesystemSource

func NewFilesystemSource(source string, types []string) *FilesystemSource

NewFilesystemSource initializes a NewFilesystemSource with source to queries and types of queries to load

func (*FilesystemSource) CheckType

func (s *FilesystemSource) CheckType(queryPlatform interface{}) bool

CheckType checks if the queries have the type passed as an argument in '--type' flag to be loaded

func (*FilesystemSource) GetQueries

func (s *FilesystemSource) GetQueries(excludeQueries ExcludeQueries) ([]model.QueryMetadata, error)

GetQueries walks a given filesource path returns all queries found in an array of QueryMetadata struct

func (*FilesystemSource) GetQueryLibrary added in v1.2.2

func (s *FilesystemSource) GetQueryLibrary(platform string) (string, error)

GetQueryLibrary returns the library.rego for the platform passed in the argument

type QueriesSource

type QueriesSource interface {
	GetQueries(excludeQueries ExcludeQueries) ([]model.QueryMetadata, error)
	GetQueryLibrary(platform string) (string, error)
}

QueriesSource wraps an interface that contains basic methods: GetQueries and GetQueryLibrary GetQueries gets all queries from a QueryMetadata list GetQueryLibrary gets a library of rego functions given a plataform's name

Jump to

Keyboard shortcuts

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