check

package
v0.0.0-...-4addfbe Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PASS check passed.
	PASS State = "PASS"
	// FAIL check failed.
	FAIL = "FAIL"
	// WARN could not carry out check.
	WARN = "WARN"
	// INFO informational message
	INFO = "INFO"
	// SKIP for when a check should be skipped.
	SKIP = "skip"
)
View Source
const TypeAudit = "audit"

TypeAudit string representing default "Audit".

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

type Audit string

Audit string that holds audit to execute.

func (Audit) Execute

func (audit Audit) Execute(customConfig ...interface{}) (result string, errMessage string, state State)

Execute method called by the main logic to execute the Audit's Execute type.

type AuditType

type AuditType string

AuditType is the type of audit to test.

type Auditer

type Auditer interface {
	Execute(customConfig ...interface{}) (result string, errMsg string, state State)
}

Auditer represents the Execute method to be called.

type BaseCheck

type BaseCheck struct {
	AuditType   AuditType           `json:"audit_type"`
	Audit       interface{}         `json:"audit"`
	Type        string              `json:"type"`
	Commands    []*exec.Cmd         `json:"-"`
	Tests       *auditeval.Tests    `json:"-"`
	Remediation string              `json:"-"`
	Constraints map[string][]string `yaml:"constraints"`
	// contains filtered or unexported fields
}

BaseCheck (Original version) - checks don't have sub checks, each check has only one sub check as part of the check itself

type Bench

type Bench interface {
	RegisterAuditType(auditType AuditType, typeCallback func() interface{}) error
	NewControls(in []byte, definitions []string, customConfigs ...interface{}) (*Controls, error)
}

Bench implementer of this interface represent audit types to be tests.

func NewBench

func NewBench() Bench

NewBench returns a new Bench

type Check

type Check struct {
	ID             string           `yaml:"id" json:"test_number"`
	Description    string           `json:"test_desc" yaml:"text"`
	Set            bool             `json:"-"`
	SubChecks      []*SubCheck      `yaml:"sub_checks"`
	AuditType      AuditType        `json:"audit_type"`
	Audit          interface{}      `json:"audit"`
	Type           string           `json:"type"`
	Commands       []*exec.Cmd      `json:"-"`
	Tests          *auditeval.Tests `json:"-"`
	Remediation    string           `json:"-"`
	TestInfo       []string         `json:"test_info"`
	State          `json:"status"`
	ActualValue    string `json:"actual_value"`
	ExpectedResult string `json:"expected_result"`
	Scored         bool   `json:"scored"`
	IsMultiple     bool   `yaml:"use_multiple_values"`

	Reason string `json:"reason,omitempty"`
	// contains filtered or unexported fields
}

Check contains information about a recommendation.

func (*Check) Run

func (c *Check) Run(definedConstraints map[string][]string)

Run executes the audit commands specified in a check and outputs the results.

type Controls

type Controls struct {
	ID          string   `yaml:"id" json:"id"`
	Description string   `json:"text" yaml:"text"`
	Groups      []*Group `json:"tests" yaml:"groups"`
	Summary
	DefinedConstraints map[string][]string
	// contains filtered or unexported fields
}

Controls holds all controls to check for master nodes.

func NewControls

func NewControls(in []byte, definitions []string) (*Controls, error)

NewControls instantiates a new master Controls object.

func (*Controls) JSON

func (controls *Controls) JSON() ([]byte, error)

JSON encodes the results of last run to JSON.

func (*Controls) JUnit

func (controls *Controls) JUnit() ([]byte, error)

JUnit encodes the results of last run to JUnit.

func (*Controls) RunChecks

func (controls *Controls) RunChecks(ids ...string) Summary

RunChecks runs the checks with the supplied IDs.

func (*Controls) RunGroup

func (controls *Controls) RunGroup(gids ...string) Summary

RunGroup runs all checks in a group.

type Group

type Group struct {
	ID          string              `yaml:"id" json:"section"`
	Description string              `json:"desc" yaml:"text"`
	Constraints map[string][]string `yaml:"constraints"`
	Type        string              `yaml:"type" json:"type"`
	Checks      []*Check            `json:"results"`
	Pass        int                 `json:"pass"` // Tests with no type that passed
	Fail        int                 `json:"fail"` // Tests with no type that failed
	Warn        int                 `json:"warn"` // Tests of type manual won't be run and will be marked as Warn
	Info        int                 `json:"info"` // Tests of type skip won't be run and will be marked as Info
}

Group is a collection of similar checks.

type State

type State string

State is the state of a control check.

type SubCheck

type SubCheck struct {
	BaseCheck `yaml:"check"`
}

SubCheck additional check to be performed.

type Summary

type Summary struct {
	Pass int `json:"total_pass"`
	Fail int `json:"total_fail"`
	Warn int `json:"total_warn"`
	Info int `json:"total_info"`
}

Summary is a summary of the results of control checks run.

Jump to

Keyboard shortcuts

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