reporter

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FormatIds = map[Format][]string{
	JSON:  {"json"},
	Table: {"table"},
	Junit: {"junit"},
	Tap:   {"tap"},
	None:  {"none"},
}
View Source
var SeverityIds = map[Severity][]string{
	Unknown:       {"unknown"},
	Informational: {"informational"},
	Low:           {"low"},
	Medium:        {"medium"},
	High:          {"high"},
	Critical:      {"critical"},
	Off:           {"off"},
}

Functions

func JSONReporter

func JSONReporter(r *RegulaOutput) (string, error)

func JUnitReporter

func JUnitReporter(o *RegulaOutput) (string, error)

func TableReporter

func TableReporter(o *RegulaOutput) (string, error)

func TapReporter

func TapReporter(o *RegulaOutput) (string, error)

Types

type FilepathResults

type FilepathResults struct {
	Filepath string
	Results  map[string]ResourceResults
	Pass     bool
}

func (FilepathResults) SortedKeys

func (f FilepathResults) SortedKeys() []string

func (FilepathResults) ToTestSuite

func (r FilepathResults) ToTestSuite() JUnitTestSuite

type Format

type Format int
const (
	JSON Format = iota
	Table
	Junit
	Tap
	None
)

type JUnitFailure

type JUnitFailure struct {
	Message  string `xml:"message,attr"`
	Type     string `xml:"type,attr"`
	Contents string `xml:",chardata"`
}

type JUnitSkipMessage

type JUnitSkipMessage struct {
	Message string `xml:"message,attr"`
}

type JUnitTestCase

type JUnitTestCase struct {
	XMLName     xml.Name            `xml:"testcase"`
	Name        string              `xml:"name,attr"`
	ClassName   string              `xml:"classname,attr"`
	Assertions  int                 `xml:"assertions,attr"`
	SkipMessage *[]JUnitSkipMessage `xml:"skipped,omitempty"`
	Failures    *[]JUnitFailure     `xml:"failure,omitempty"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	XMLName   xml.Name        `xml:"testsuite"`
	Name      string          `xml:"name,attr"`
	Tests     int             `xml:"tests,attr"`
	TestCases []JUnitTestCase `xml:"testcase"`
}

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName    xml.Name         `xml:"testsuites"`
	Name       string           `xml:"name,attr"`
	TestSuites []JUnitTestSuite `xml:"testsuite"`
}

type RegulaOutput

type RegulaOutput struct {
	RuleResults []RuleResult `json:"rule_results"`
	Summary     Summary      `json:"summary"`
}

func (RegulaOutput) AggregateByFilepath

func (o RegulaOutput) AggregateByFilepath() ResultsByFilepath

func (RegulaOutput) ExceedsSeverity

func (o RegulaOutput) ExceedsSeverity(severity Severity) bool

type Reporter

type Reporter func(r *RegulaOutput) (string, error)

func GetReporter

func GetReporter(format Format) (Reporter, error)

type ResourceResults

type ResourceResults struct {
	Filepath     string
	ResourceID   string
	ResourceType string
	Results      []RuleResult
	Pass         bool
}

func (ResourceResults) ToTestCase

func (r ResourceResults) ToTestCase() JUnitTestCase

type ResultsByFilepath

type ResultsByFilepath map[string]FilepathResults

func (ResultsByFilepath) SortedKeys

func (r ResultsByFilepath) SortedKeys() []string

func (ResultsByFilepath) ToTestSuites

func (r ResultsByFilepath) ToTestSuites() JUnitTestSuites

type RuleResult

type RuleResult struct {
	Controls        []string `json:"controls"`
	Filepath        string   `json:"filepath"`
	Platform        string   `json:"platform"`
	Provider        string   `json:"provider"`
	ResourceID      string   `json:"resource_id"`
	ResourceType    string   `json:"resource_type"`
	RuleDescription string   `json:"rule_description"`
	RuleID          string   `json:"rule_id"`
	RuleMessage     string   `json:"rule_message"`
	RuleName        string   `json:"rule_name"`
	RuleResult      string   `json:"rule_result"`
	RuleSeverity    string   `json:"rule_severity"`
	RuleSummary     string   `json:"rule_summary"`
}

func (RuleResult) IsFail

func (r RuleResult) IsFail() bool

func (RuleResult) IsPass

func (r RuleResult) IsPass() bool

func (RuleResult) IsWaived

func (r RuleResult) IsWaived() bool

func (RuleResult) Message

func (r RuleResult) Message() string

func (RuleResult) ToTapRow

func (r RuleResult) ToTapRow(idx int) TapRow

type Severity

type Severity int
const (
	Unknown Severity = iota
	Informational
	Low
	Medium
	High
	Critical
	Off
)

type Summary

type Summary struct {
	Filepaths   []string       `json:"filepaths"`
	RuleResults map[string]int `json:"rule_results"`
	Severities  map[string]int `json:"severities"`
}

type TableRow

type TableRow struct {
	Resource string
	Type     string
	Filepath string
	Severity string
	RuleID   string
	RuleName string
	Message  string
	Result   string
}

type TapRow

type TapRow struct {
	Ok        string
	Index     int
	Message   string
	Directive string
	Resource  string
	RuleID    string
}

func (TapRow) String

func (r TapRow) String(indent string) string

Jump to

Keyboard shortcuts

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