Documentation
¶
Index ¶
- Variables
- func CompactReporter(o *RegulaReport) (string, error)
- func JSONReporter(r *RegulaReport) (string, error)
- func JUnitReporter(o *RegulaReport) (string, error)
- func ResultCompare(resA, resB string) bool
- func SarifReporter(o *RegulaReport) (string, error)
- func SeverityCompare(sevA, sevB string) bool
- func TableReporter(o *RegulaReport) (string, error)
- func TapReporter(o *RegulaReport) (string, error)
- func TextReporter(o *RegulaReport) (string, error)
- func ToSarifLevel(r string, s string) string
- func ToSarifLocation(l loader.Location) *sarif.Location
- func ValidateFormat(name string) error
- func ValidateSeverity(name string) error
- type FilepathResults
- type Format
- type JUnitFailure
- type JUnitSkipMessage
- type JUnitTestCase
- type JUnitTestSuite
- type JUnitTestSuites
- type RegulaReport
- type Reporter
- type ResourceResults
- type Result
- type ResultsByFilepath
- type ResultsByRule
- type RuleResult
- type RuleResults
- type ScanInput
- type ScanView
- type Severity
- type Summary
- type TableRow
- type TapRow
Constants ¶
This section is empty.
Variables ¶
var DefaultFormat = FormatIDs[Text][0]
var DefaultSeverity = SeverityIds[Unknown][0]
var FormatIDs = map[Format][]string{ JSON: {"json"}, Table: {"table"}, Junit: {"junit"}, Tap: {"tap"}, None: {"none"}, Text: {"text"}, Compact: {"compact"}, Sarif: {"sarif"}, }
var SeverityIds = map[Severity][]string{ Unknown: {"unknown"}, Informational: {"informational"}, Low: {"low"}, Medium: {"medium"}, High: {"high"}, Critical: {"critical"}, Off: {"off"}, }
Functions ¶
func CompactReporter ¶
func CompactReporter(o *RegulaReport) (string, error)
TextReporter returns the Regula report in a human-friendly format
func JSONReporter ¶
func JSONReporter(r *RegulaReport) (string, error)
func JUnitReporter ¶
func JUnitReporter(o *RegulaReport) (string, error)
func ResultCompare ¶
ResultCompare orders "FAIL" > "PASS" > "WAIVED"
func SarifReporter ¶
func SarifReporter(o *RegulaReport) (string, error)
func SeverityCompare ¶
SeverityCompare returns true if the first severity is more important than the second. E.g. SeverityCompare("High", "Medium") yields true.
func TableReporter ¶
func TableReporter(o *RegulaReport) (string, error)
func TapReporter ¶
func TapReporter(o *RegulaReport) (string, error)
func TextReporter ¶
func TextReporter(o *RegulaReport) (string, error)
TextReporter returns the Regula report in a human-friendly format
func ToSarifLevel ¶
Constructs sarif level based on rule result and severity.
func ToSarifLocation ¶
Turns a regula location into a sarif location
func ValidateFormat ¶
func ValidateSeverity ¶
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 JUnitFailure ¶
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 RegulaReport ¶
type RegulaReport struct {
RuleResults []RuleResult `json:"rule_results"`
Summary Summary `json:"summary"`
}
func ParseRegulaOutput ¶
func ParseRegulaOutput(conf loader.LoadedConfigurations, r rego.RegoResult) (*RegulaReport, error)
func (RegulaReport) AggregateByFilepath ¶
func (o RegulaReport) AggregateByFilepath() ResultsByFilepath
func (RegulaReport) AggregateByRule ¶
func (o RegulaReport) AggregateByRule() ResultsByRule
AggregateByRule returns all rule results grouped by rule
func (RegulaReport) ExceedsSeverity ¶
func (o RegulaReport) ExceedsSeverity(severity Severity) bool
func (RegulaReport) FailuresByRule ¶
func (o RegulaReport) FailuresByRule() ResultsByRule
FailuresByRule returns failing rule results grouped by rule
func (*RegulaReport) RecomputeSummary ¶
func (report *RegulaReport) RecomputeSummary()
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 ResultsByRule ¶
type ResultsByRule []RuleResults
ResultsByRule is used to carry all rule results grouped by rule
type RuleResult ¶
type RuleResult struct {
Controls []string `json:"controls"`
Families []string `json:"families"`
Filepath string `json:"filepath"`
InputType string `json:"input_type"`
Provider string `json:"provider"`
ResourceID string `json:"resource_id"`
ResourceType string `json:"resource_type"`
ResourceTags map[string]interface{} `json:"resource_tags"`
RuleDescription string `json:"rule_description"`
RuleID string `json:"rule_id"`
RuleMessage string `json:"rule_message"`
RuleName string `json:"rule_name"`
RuleRawResult bool `json:"rule_raw_result"`
RuleRemediationDoc string `json:"rule_remediation_doc,omitempty"`
RuleResult string `json:"rule_result"`
RuleSeverity string `json:"rule_severity"`
RuleSummary string `json:"rule_summary"`
// List of source code locations this rule result pertains to. The first
// element of the list always refers to the most specific source code site,
// and further elements indicate modules in which this was included, like
// a call stack.
SourceLocation loader.LocationStack `json:"source_location,omitempty"`
ActiveWaivers []string `json:"active_waivers,omitempty"`
}
func (*RuleResult) EnrichRuleResult ¶
func (r *RuleResult) EnrichRuleResult(conf loader.LoadedConfigurations)
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 RuleResults ¶
type RuleResults struct {
RuleID string
RuleName string
RuleSummary string
RuleSeverity string
RuleRemediationDoc string
Results []*RuleResult
}
RuleResults carries a slice of RuleResults associated with a specific rule. A minimal amount of rule metadata is duplicated here for convenience.
type ScanInput ¶
type ScanInput struct {
Filepath string `json:"filepath"`
InputType string `json:"input_type"`
Resources map[string]map[string]interface{} `json:"resources"`
}
func (*ScanInput) EnrichResources ¶
func (s *ScanInput) EnrichResources(conf loader.LoadedConfigurations)
type ScanView ¶
type ScanView struct {
Inputs []ScanInput `json:"inputs"`
RegulaVersion string `json:"regula_version"`
ScanViewVersion string `json:"scan_view_version"`
Report RegulaReport `json:"report"`
}
func ParseScanView ¶
func ParseScanView(conf loader.LoadedConfigurations, r rego.RegoResult) (*ScanView, error)