Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidArg = fmt.Errorf("invalid argument") ErrInvalidFormat = fmt.Errorf("invalid format") )
View Source
var ( ErrCantConvert = fmt.Errorf("error converting value to a valid type") ErrCantConvertToInt = fmt.Errorf("error converting value to int") ErrCantConvertToString = fmt.Errorf("error converting value to string") ErrCantCompileRegex = fmt.Errorf("error compiling regex") ErrUnsupportedType = fmt.Errorf("unsupported type") ErrJSONNotArray = fmt.Errorf("json is not an array") ErrJSONNotMap = fmt.Errorf("json is not a map") ErrJSONNoSuchKey = fmt.Errorf("json does not contain key") )
Functions ¶
func PrintFindings ¶
Types ¶
type Finding ¶
type Finding struct {
ToolName string `json:"toolName"`
RuleID string `json:"ruleID"`
Level string `json:"level"`
FilePath string `json:"filePath"`
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
StartCol int `json:"startCol"`
EndCol int `json:"endCol"`
Message string `json:"message"`
}
type JsonInfos ¶
type JsonInfos struct {
// Type or linter output to parse
// Default is handling json array of findings
// "plain": Handle plain text output, where any output is considered a finding, with such finding
// being populated with the OverrideKey values from the jsonMappingInfo
// "stream": Handle JSON stream output, internally converted to simple JSON array
Type string
// Whether to read the JSON from stderr instead of stdout
ReadFromStderr bool
Mappings JsonToFindingsMappings
}
type JsonMappingInfo ¶
type JsonMappingInfo struct {
// JSON key to find, can use dot notation to find nested keys like `foo.bar.baz`. Keys whose value is a string array will be
// converted to a string by joining the values with " - ".
Key string
// Value to use if the key is not found or is empty. Internally uses strconv.Atoi to convert the value to an int if mapping type is int
DefaultValue string
// Do not try to find key and use this value instead
OverrideValue string
// Transform found value using this regex
ValueTransformerRegex string
// Discard whole finding if this regex for current key does not match
GlobalSelectorRegex string
// Select if the regex does not match (kind-of global negative lookahead, not supported in Go)
InvertGlobalSelector bool
// Another jsonMappingInfo to use as a suffix
// Can be used to compose a value from multiple sources, like <mapping1 result><mapping2 result><mapping3 result>
// Use in conjunction with OverrideKey to set constant values
// Only enabled for string values
Suffix *JsonMappingInfo
}
type JsonToFindingsMappings ¶
type JsonToFindingsMappings struct {
// Key containing the array of findings in which to search using jsonMappingInfo
BaseArrayKey string
ToolName JsonMappingInfo
RuleID JsonMappingInfo
// Severity level of the finding, valid values are `debug`, `notice`, `warning`, `error`
// Based on GitHub workflow commands, see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-debug-message
// Other common values are mapped automatically:
// `info` -> `notice`
// `low` -> `notice`
// `medium` -> `warning`
// `critical` -> `error`
// `high` -> `error`
Level JsonMappingInfo
FilePath JsonMappingInfo
StartLine JsonMappingInfo
EndLine JsonMappingInfo
StartCol JsonMappingInfo
EndCol JsonMappingInfo
Message JsonMappingInfo
}
Click to show internal directories.
Click to hide internal directories.