validate

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HubRegoPolicy = "ghcr.io/santoshkal/genval-security-policies/rego-policies:v0.0.1"
)

Variables

This section is empty.

Functions

func ApplyDefaultPolicies added in v0.1.5

func ApplyDefaultPolicies(ociURL, path string) (string, error)

func EvaluateCELPolicies

func EvaluateCELPolicies(policies []CELPolicy, inputFile string, t table.Writer) error

func FetchRegoMetadata added in v0.1.3

func FetchRegoMetadata(policyDir, metaExt, regoExt string) ([]string, []string, error)

func LoadRegoMetadata added in v0.1.3

func LoadRegoMetadata(filePaths []string) ([]*regoMetadata, error)

LoadRegoMetadata loads the contents of the metadata files into a slice of pointers to RegoMeta structs

func MatchPolicyMetadata added in v0.1.3

func MatchPolicyMetadata(metas []*regoMetadata, key string) (string, *regoMetadata, error)

MatchPolicyMetadata matches the RegoMeta policy names with the Rego evaluation results and returns the matched key

func PrintResults added in v0.1.2

func PrintResults(result rego.ResultSet, metas []*regoMetadata) error

PrintResults prints the evaluation results along with the metadata

func SaveResults added in v0.1.3

func SaveResults(filename string, newResults []Results) error

SaveResults saves the results to a file as a JSON array

func ValidateDockerfile

func ValidateDockerfile(dockerfileContent string, regoPolicyPath string) error

ValidateDockerfileUsingRego validates a Dockerfile using Rego.

func ValidateInput

func ValidateInput(yamlContent string, regoPolicyPath string) error

func ValidateWithRego

func ValidateWithRego(inputContent string, regoPolicyPath string) error

Types

type CELPolicy added in v0.1.3

type CELPolicy struct {
	APIVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	Metadata   Metadata `yaml:"metadata"`
	Rule       string   `yaml:"rule"`
}

func ParseYAMLPolicies added in v0.1.3

func ParseYAMLPolicies(policyFile string) ([]CELPolicy, error)

type CELPolicyFile added in v0.1.3

type CELPolicyFile struct {
	Policies []CELPolicy `yaml:"policies"`
}

type Metadata added in v0.1.3

type Metadata struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Severity    string `yaml:"severity"`
	Benchmark   string `yaml:"benchmark"`
}

type PolicyFile added in v0.1.3

type PolicyFile struct {
	Policies []CELPolicy `yaml:"policies"`
}

type Results added in v0.1.3

type Results struct {
	ID          string `json:"id"`
	PolicyName  string `json:"policyName"`
	Status      string `json:"status"`
	Description string `json:"description"`
	Severity    string `json:"severity"`
	Benchmark   string `json:"benchmark"`
	Category    string `json:"category"`
}

Jump to

Keyboard shortcuts

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