Documentation
¶
Index ¶
Constants ¶
const ( OutputStandard = "stdout" OutputJSON = "json" OutputTAP = "tap" OutputTable = "table" OutputJUnit = "junit" OutputGitHub = "github" OutputAzureDevOps = "azuredevops" OutputSARIF = "sarif" )
The defined output formats represent all of the supported formats that can be used to format and render results.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AzureDevOps ¶ added in v0.45.0
type AzureDevOps struct {
// contains filtered or unexported fields
}
AzureDevOps represents an Outputter that outputs results in AzureDevOps Pipelines format. https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands
func NewAzureDevOps ¶ added in v0.45.0
func NewAzureDevOps(w io.Writer) *AzureDevOps
NewAzureDevOps creates a new AzureDevOps with the given writer.
func (*AzureDevOps) Output ¶ added in v0.45.0
func (t *AzureDevOps) Output(checkResults CheckResults) error
Output outputs the results.
type CheckResult ¶
type CheckResult struct {
FileName string `json:"filename"`
Namespace string `json:"namespace"`
Successes int `json:"successes"`
Skipped []Result `json:"skipped,omitempty"`
Warnings []Result `json:"warnings,omitempty"`
Failures []Result `json:"failures,omitempty"`
Exceptions []Result `json:"exceptions,omitempty"`
Queries []QueryResult `json:"queries,omitempty"`
}
CheckResult describes the result of a conftest policy evaluation. Errors produced by rego should be considered separate from other classes of exceptions.
func (CheckResult) HasException ¶ added in v0.58.0
func (cr CheckResult) HasException() bool
HasException returns true if any exceptions were encountered.
func (CheckResult) HasFailure ¶ added in v0.58.0
func (cr CheckResult) HasFailure() bool
HasFailure returns true if any failures were encountered.
func (CheckResult) HasWarning ¶ added in v0.58.0
func (cr CheckResult) HasWarning() bool
HasWarning returns true if any warnings were encountered.
func (CheckResult) OnlySuccess ¶ added in v0.58.0
func (cr CheckResult) OnlySuccess() bool
OnlySuccess returns true if there are no failures, warnings, or exceptions.
type CheckResults ¶ added in v0.58.0
type CheckResults []CheckResult
CheckResults is a slice of CheckResult.
func (CheckResults) ExitCode ¶ added in v0.58.0
func (cr CheckResults) ExitCode() int
ExitCode returns the exit code that should be returned given all of the returned results.
func (CheckResults) ExitCodeFailOnWarn ¶ added in v0.58.0
func (cr CheckResults) ExitCodeFailOnWarn() int
ExitCodeFailOnWarn returns the exit code that should be returned given all of the returned results, and will consider warnings as failures.
func (CheckResults) HasException ¶ added in v0.58.0
func (cr CheckResults) HasException() bool
HasException returns true if any of the checks in the list has an exception.
func (CheckResults) HasFailure ¶ added in v0.58.0
func (cr CheckResults) HasFailure() bool
HasFailure returns true if any of the checks in the list has a failure.
func (CheckResults) HasWarning ¶ added in v0.58.0
func (cr CheckResults) HasWarning() bool
HasWarning returns true if any of the checks in the list has a warning.
func (CheckResults) OnlySuccess ¶ added in v0.58.0
func (cr CheckResults) OnlySuccess() bool
OnlySuccess returns true if all of the checks have only success messages.
type GitHub ¶ added in v0.27.0
type GitHub struct {
// contains filtered or unexported fields
}
GitHub represents an Outputter that outputs results in GitHub workflow format. https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions
func (*GitHub) Output ¶ added in v0.27.0
func (g *GitHub) Output(checkResults CheckResults) error
Output outputs the results.
type JSON ¶ added in v0.22.0
JSON represents an Outputter that outputs results in JSON format.
func (*JSON) Output ¶ added in v0.22.0
func (j *JSON) Output(results CheckResults) error
Output outputs the results.
type JUnit ¶ added in v0.22.0
JUnit represents an Outputter that outputs results in JUnit format.
func (*JUnit) Output ¶ added in v0.22.0
func (j *JUnit) Output(results CheckResults) error
Output outputs the results.
type Location ¶ added in v0.64.0
type Location struct {
File string `json:"file,omitempty"`
Line json.Number `json:"line,omitempty"`
}
Location describes the origin location in the configuration file that caused the result to be produced.
type Options ¶ added in v0.22.0
type Options struct {
Tracing bool
NoColor bool
SuppressExceptions bool
ShowSkipped bool
JUnitHideMessage bool
File *os.File
}
Options represents the options available when configuring an Outputter.
type Outputter ¶ added in v0.22.0
Outputter controls how results of an evaluation will be recorded and reported to the end user.
type QueryResult ¶ added in v0.22.0
type QueryResult struct {
// Query is the fully qualified query that was used
// to determine the result. Ex: (data.main.deny)
Query string `json:"query"`
// Results are the individual results of the query.
// When querying data.main.deny, multiple deny rules can
// exist, producing multiple results.
Results []Result `json:"results"`
// Traces represents a single trace of how the query was
// evaluated. Each trace value is a trace line.
Traces []string `json:"traces"`
// Output represents anything print()'ed during the query
// evaluation. Each value is a print() call's result.
Outputs []string `json:"outputs,omitempty"`
}
QueryResult describes the result of evaluting a query.
func (QueryResult) Passed ¶ added in v0.22.0
func (q QueryResult) Passed() bool
Passed returns true if all of the results in the query passed and no failures were found.
type Result ¶
type Result struct {
Message string `json:"msg"`
Location *Location `json:"loc,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Outputs []string `json:"outputs,omitempty"`
}
Result describes the result of a single rule evaluation.
type SARIF ¶ added in v0.57.0
type SARIF struct {
// contains filtered or unexported fields
}
SARIF represents an Outputter that outputs results in SARIF format.
func (*SARIF) Output ¶ added in v0.57.0
func (s *SARIF) Output(results CheckResults) error
Output outputs the results in SARIF format.
type Standard ¶ added in v0.22.0
type Standard struct {
Writer io.Writer
// Tracing will render the trace results of the
// queries when set to true.
Tracing bool
// NoColor will disable all coloring when
// set to true.
NoColor bool
// SuppressExceptions will disable output for exceptions when set to true.
SuppressExceptions bool
// ShowSkipped whether to show skipped tests
// in the output.
ShowSkipped bool
}
Standard represents an Outputter that outputs results in a human readable format.
func NewStandard ¶ added in v0.22.0
NewStandard creates a new Standard with the given writer.
func (*Standard) Output ¶ added in v0.22.0
func (s *Standard) Output(results CheckResults) error
Output outputs the results.
type TAP ¶ added in v0.22.0
TAP represents an Outputter that outputs results in TAP format.
func (*TAP) Output ¶ added in v0.22.0
func (t *TAP) Output(checkResults CheckResults) error
Output outputs the results.
type Table ¶ added in v0.22.0
Table represents an Outputter that outputs results in a tabular format.
func (*Table) Output ¶ added in v0.22.0
func (t *Table) Output(checkResults CheckResults) error
Output outputs the results.