pkg

package
v0.0.0-...-8e9acee Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RuleSuffix   = ".yaml"
	RuleSetYaml  = "ruleset.yaml"
	RuleSetImage = "image.svg"
)

RuleSet constants

View Source
const (
	KindJobFunction   = "jobfunction"
	KindRuleSet       = "ruleset"
	KindTagCategory   = "tagcategory"
	KindTarget        = "target"
	KindQuestionnaire = "questionnaire"
)

Seedable kinds

View Source
const (
	AllVersions = 0
)

Variables

This section is empty.

Functions

func Checksum

func Checksum(r io.Reader) (sum []byte, err error)

Checksum calculates a checksum for the contents of a reader.

func ChecksumDir

func ChecksumDir(dir string) (sum []byte, err error)

ChecksumDir calculates a checksum for the contents of a directory.

Types

type Answer

type Answer struct {
	Order         uint
	Text          string
	Risk          string
	Rationale     string           `yaml:",omitempty" json:",omitempty"`
	Mitigation    string           `yaml:",omitempty" json:",omitempty"`
	ApplyTags     []CategorizedTag `yaml:",omitempty" json:",omitempty"`
	AutoAnswerFor []CategorizedTag `yaml:",omitempty" json:",omitempty"`
	Selected      bool             `yaml:",omitempty" json:",omitempty"`
	AutoAnswered  bool             `yaml:",omitempty" json:",omitempty"`
}

Answer represents an answer to a question in a questionnaire.

type CategorizedTag

type CategorizedTag struct {
	Category string
	Tag      string
}

CategorizedTag represents a human-readable pair of category and tag.

type JobFunction

type JobFunction struct {
	UUID string
	Name string
}

JobFunction is a representation of the Hub's JobFunction that is fit for seeding.

type Question

type Question struct {
	Order       uint
	Text        string
	Explanation string
	IncludeFor  []CategorizedTag `yaml:",omitempty" json:",omitempty"`
	ExcludeFor  []CategorizedTag `yaml:",omitempty" json:",omitempty"`
	Answers     []Answer
}

Question represents a question in a questionnaire.

type Questionnaire

type Questionnaire struct {
	UUID         string
	Name         string
	Description  string `yaml:",omitempty" json:",omitempty"`
	Required     bool
	Sections     []Section
	Thresholds   Thresholds
	RiskMessages RiskMessages `yaml:",omitempty" json:",omitempty"`
}

Questionnaire is a representation of the Hub's Questionnaire model that is fit for seeding.

type RiskMessages

type RiskMessages struct {
	Red     string
	Yellow  string
	Green   string
	Unknown string
}

RiskMessages contains messages to display for each risk level.

type Rule

type Rule struct {
	Path string
	// contains filtered or unexported fields
}

Rule seed representation.

func (*Rule) AppendLabel

func (r *Rule) AppendLabel(label string)

AppendLabel adds a label to the rule without duplication.

func (*Rule) Labels

func (r *Rule) Labels() (labels []string)

Labels returns a slice of the rule's labels.

type RuleSet

type RuleSet struct {
	UUID         string   `yaml:",omitempty"`
	Name         string   `yaml:",omitempty"`
	Description  string   `yaml:",omitempty"`
	Labels       []string `yaml:",omitempty"`
	Directory    string   `yaml:",omitempty"`
	Dependencies []string `yaml:",omitempty"`
	Checksum     string   `yaml:",omitempty"`
	Rules        []Rule   `yaml:"-"`
	SeedDir      string   `yaml:"-"`
}

RuleSet seed representation.

func (*RuleSet) Dir

func (r *RuleSet) Dir() string

Dir returns the path to the directory containing the rule files.

func (*RuleSet) Load

func (r *RuleSet) Load() (err error)

Load populates the seed representation with values from the analyzer ruleset yaml.

func (*RuleSet) Yaml

func (r *RuleSet) Yaml() string

Yaml returns the path to the ruleset.yaml file.

type Section

type Section struct {
	Order     uint
	Name      string
	Questions []Question
}

Section represents a group of questions in a questionnaire.

type Seed

type Seed struct {
	Kind    string
	Version uint
	Items   []yaml.Node
	// contains filtered or unexported fields
}

Seed document structure.

func ReadFromDir

func ReadFromDir(dir string, version uint) (seeds []Seed, checksum []byte, err error)

ReadFromDir reads all seeds from the given directory.

func ReadFromFile

func ReadFromFile(filePath string, version uint) (seeds []Seed, checksum []byte, err error)

ReadFromFile reads all seeds from the given file.

func (*Seed) DecodeItems

func (r *Seed) DecodeItems() (decoded []interface{}, err error)

DecodeItems decodes the yaml nodes of the Items slice on the Seed into their proper representations based on the Seed's Kind.

func (*Seed) Dir

func (r *Seed) Dir() string

Dir returns the path to the directory that contains this Seed.

func (*Seed) Filename

func (r *Seed) Filename() string

Filename returns the name of the file containing this Seed.

type TagCategory

type TagCategory struct {
	UUID  string
	Name  string
	Color string
	Tags  []struct {
		UUID string
		Name string
	}
}

TagCategory is a representation of the Hub's TagCategory that is fit for seeding.

type Target

type Target struct {
	UUID        string        `yaml:",omitempty"`
	Name        string        `yaml:",omitempty"`
	Description string        `yaml:",omitempty"`
	Provider    string        `yaml:"provider"`
	ImagePath   string        `yaml:",omitempty"`
	Choice      bool          `yaml:",omitempty"`
	Labels      []TargetLabel `yaml:",omitempty"`
	SeedDir     string        `yaml:",omitempty"`
}

func (*Target) Image

func (r *Target) Image() string

type TargetLabel

type TargetLabel struct {
	Name  string `yaml:",omitempty" json:"name"`
	Label string `yaml:",omitempty" json:"label"`
}

type Thresholds

type Thresholds struct {
	Red     uint
	Yellow  uint
	Unknown uint
}

Thresholds contains the threshold values for determining risk for the questionnaire.

Jump to

Keyboard shortcuts

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