Documentation ¶
Index ¶
- Variables
- func BaseHttpUrl(hostname string) string
- func CountViolations(rs rego.ResultSet, platform string, kind string) int
- func Eval(policy RegoModule, input interface{}) rego.ResultSet
- func HumanizeDuration(duration time.Duration) string
- func HumanizeDurationShort(d time.Duration) string
- func PrintViolations(rs rego.ResultSet, filename string, platform string, kind string, ...)
- func PrintViolationsOnWriter(writer *SafeWriter, rs rego.ResultSet, filename string, platform string, ...)
- func RESTPrefix(hostname string) string
- type Duration
- type File
- type Iso8601Duration
- func (d Iso8601Duration) MarshalJSON() ([]byte, error)
- func (d Iso8601Duration) MarshalYAML() (interface{}, error)
- func (d Iso8601Duration) String() string
- func (d Iso8601Duration) ToDuration() time.Duration
- func (d *Iso8601Duration) UnmarshalJSON(b []byte) error
- func (d *Iso8601Duration) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Level
- type Location
- type RegoModule
- type Resource
- type Result
- type ResultSet
- type Rule
- type SafeWriter
- type Score
- type Suggestion
Constants ¶
This section is empty.
Variables ¶
var LevelStringMap map[string]Level = map[string]Level{ // contains filtered or unexported fields }
var Levels []string = []string{levelInfo, levelWarning, levelError}
Functions ¶
func BaseHttpUrl ¶ added in v0.3.0
BaseHttpUrl returns the scheme and net loc for URLs
func CountViolations ¶
CountViolations returns the count of violations from an OPA result set
func Eval ¶
func Eval(policy RegoModule, input interface{}) rego.ResultSet
Eval ... input requires to be a map !! with only string as keys !!
func HumanizeDuration ¶ added in v0.12.0
HumanizeDuration returns the duration with more human friendly format https://gist.github.com/harshavardhana/327e0577c4fed9211f65#gistcomment-2366908
func HumanizeDurationShort ¶ added in v0.12.0
HumanizeDuration returns the time.Duration with better output format including the number of years, days (rather than very long hours) https://gist.github.com/harshavardhana/327e0577c4fed9211f65#gistcomment-2557682 NB: Small adjusmtents were made to now show optional trailing 0d0s but not in the middle ie 1y0d3h will be kept as is
func PrintViolations ¶
func PrintViolations(rs rego.ResultSet, filename string, platform string, kind string, startLine int)
PrintViolations ... staringLine is needed for files that contains multiple split resources in order to be able to match the location to exact line in original file
func PrintViolationsOnWriter ¶
func PrintViolationsOnWriter(writer *SafeWriter, rs rego.ResultSet, filename string, platform string, kind string, startLine int)
PrintViolationsOnWriter writes violations on the given writer
func RESTPrefix ¶ added in v0.3.0
RESTPrefix returns the Reliably API URL prefix
Types ¶
type Duration ¶ added in v0.7.0
This has been built to mitigate the poor support in JSON and YAML unmarshalling for the time.Duration type
func (Duration) MarshalJSON ¶ added in v0.12.0
func (Duration) MarshalYAML ¶ added in v0.7.0
func (*Duration) UnmarshalJSON ¶ added in v0.7.0
func (*Duration) UnmarshalYAML ¶ added in v0.7.0
type Iso8601Duration ¶ added in v0.12.0
Another JSON & YAML support for iso8601duration strings
func (Iso8601Duration) MarshalJSON ¶ added in v0.12.0
func (d Iso8601Duration) MarshalJSON() ([]byte, error)
func (Iso8601Duration) MarshalYAML ¶ added in v0.12.0
func (d Iso8601Duration) MarshalYAML() (interface{}, error)
func (Iso8601Duration) String ¶ added in v0.12.0
func (d Iso8601Duration) String() string
func (Iso8601Duration) ToDuration ¶ added in v0.12.0
func (d Iso8601Duration) ToDuration() time.Duration
func (*Iso8601Duration) UnmarshalJSON ¶ added in v0.12.0
func (d *Iso8601Duration) UnmarshalJSON(b []byte) error
func (*Iso8601Duration) UnmarshalYAML ¶ added in v0.12.0
func (d *Iso8601Duration) UnmarshalYAML(unmarshal func(interface{}) error) error
type Level ¶ added in v0.4.0
type Level int
Level type indicate the level of a suggestion
func NewLevel ¶ added in v0.4.0
NewLevel returns a Level value from the matching string representation
func (Level) ColoredSquare ¶ added in v0.6.0
ColoredSquare is a function that will return a string with a colored square ("■"), where the color is determined by the level
func (Level) ColoredString ¶ added in v0.6.0
func (Level) MarshalJSON ¶ added in v0.4.0
MarshalJSON is used convert a Level object into a JSON representation
func (Level) MarshalYAML ¶ added in v0.4.0
MarshalYAML is used convert a Level object into a YAML representation
type RegoModule ¶ added in v0.6.0
type Resource ¶
type Resource struct { File File StartingLine int Platform string Kind string Name string URI string }
Resource is a resource to analyze from a file. A file can contain multiple resource, indicated by the startingLine The platform indicates the platform on which the resource belongs to The kind indicates the type of the resource
type ResultSet ¶
type ResultSet []Result
ResultSet is a list of results after analysis It can contain results for multiple resources for multiple files
type SafeWriter ¶
type SafeWriter struct {
// contains filtered or unexported fields
}
SafeWriter allows to safely output to writer until an error occurs
func NewSafeWriter ¶
func NewSafeWriter(w *bufio.Writer) *SafeWriter
NewSafeWriter is a constructor function to return `*SafeWriter`
func (*SafeWriter) Writeln ¶
func (sw *SafeWriter) Writeln(s string)
Writeln safewrite writes a string with the inner io writer If an error occurred on previous write, the next strings will be ignored The string will always be terminated by a line return char, ie. it will be written if the given string does not termiate with a CRLF
type Suggestion ¶
type Suggestion struct { //Severity Score `json:"severity"` // issue severity (how problematic it is) //Confidence Score `json:"confidence"` // issue confidence (how sure we are we found it) RuleID string `json:"rule_id"` // Rule identifier RuleDef string `json:"rule_definition"` // Rule definition Message string `json:"details"` // Human readable explanation Level Level `json:"level"` // level File string `json:"file"` // File name we found it in //Code string `json:"code"` // Impacted code line Line int `json:"line"` // Line number in file Col int `json:"column"` // Column number in line Example string `json:"-" yaml:"-"` // Example of valid rule usage Platform string `json:"platform"` // Platform handling the resource Kind string `json:"type"` // Type of resource Name string `json:"name"` // Name of the resource Hash string `json:"-" yaml:"-"` // Unique Hash identifying the suggestion - not exported - used as fingerprint if specified }
Suggestion is returned by a policy if it discovers a violation with the scanned code.
func ConvertViolationsToSuggestions ¶
func ConvertViolationsToSuggestions(rs ResultSet, live bool) []*Suggestion
ConvertViolationsToSuggestions iterates over internal complex ResultSet to return a slice of Suggestion better suited for output reporting
func NewSuggestion ¶
func NewSuggestion(result Result, live bool) *Suggestion
NewSuggestion creates a new Suggestion It basically converts the inner nested structure into a simple one that holds all information needed for report formatting
func (Suggestion) FileLocation ¶
func (s Suggestion) FileLocation() string
FileLocation point out the file path and line/column numbers in file
func (Suggestion) Fingerprint ¶
func (s Suggestion) Fingerprint() string
Fingerprint generates a unqiue hash for the current suggestion based on unique context values, but not location. As better explained in the SARIF spec: This value shall be the same for results that are logically identical, and distinct for any two suggestions that are logically distinct. It must be resistant to changes that do not affect the logical identity of the result, such as location whithin a source file.
func (*Suggestion) UnmarshalJSON ¶ added in v0.4.0
func (s *Suggestion) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal json string into object by handling custom level string-to-int conversion
Directories ¶
Path | Synopsis |
---|---|
Package agent contains code for pushing metric indicators to reliably entity api
|
Package agent contains code for pushing metric indicators to reliably entity api |
cli
|
|
package kubernetes is a colletion of funtions for interactng with a live kubernetes cluster
|
package kubernetes is a colletion of funtions for interactng with a live kubernetes cluster |