Documentation
¶
Index ¶
- Constants
- Variables
- func CleanReportPath(path, tmpRoot, imageURI string) string
- func ExtractImageURI(files map[string]*malcontent.FileReport) string
- func ExtractTmpRoot(files map[string]*malcontent.FileReport) string
- func FormatReportKey(path, tmpRoot, imageURI string) string
- func Generate(ctx context.Context, path string, mrs *yarax.ScanResults, c malcontent.Config, ...) (*malcontent.FileReport, error)
- func HighestMatchRisk(mrs *yarax.ScanResults) int
- func Load(data []byte) (malcontent.ScanResult, error)
- func TrimPrefixes(path string, prefixes []string) string
- type StringPool
Constants ¶
const ( INVALID int = iota - 1 HARMLESS LOW MEDIUM HIGH CRITICAL )
const NAME string = "malcontent"
Variables ¶
var Levels = map[string]int{ "ignore": INVALID, "none": INVALID, "harmless": HARMLESS, "low": LOW, "notable": MEDIUM, "medium": MEDIUM, "suspicious": HIGH, "weird": HIGH, "high": HIGH, "crit": CRITICAL, "critical": CRITICAL, }
Map to handle RiskLevel -> RiskScore conversions.
var RiskLevels = map[int]string{ INVALID: "NONE", HARMLESS: "NONE", LOW: "LOW", MEDIUM: "MEDIUM", HIGH: "HIGH", CRITICAL: "CRITICAL", }
Map to handle RiskScore -> RiskLevel conversions.
Functions ¶
func CleanReportPath ¶ added in v1.19.0
CleanReportPath preserves existing image URIs in a path or removes the temporary directory root from a path.
func ExtractImageURI ¶ added in v1.19.0
func ExtractImageURI(files map[string]*malcontent.FileReport) string
ExtractImageURI extracts the image URI from paths in a report.
func ExtractTmpRoot ¶ added in v1.19.0
func ExtractTmpRoot(files map[string]*malcontent.FileReport) string
ExtractTmpRoot extracts the temporary directory root from paths in a report.
func FormatReportKey ¶ added in v1.19.0
FormatReportKey creates an appropriate key for a file from a loaded report.
func Generate ¶
func Generate(ctx context.Context, path string, mrs *yarax.ScanResults, c malcontent.Config, expath string, _ *clog.Logger, fc []byte, size int64, checksum string, kind *programkind.FileType, highestRisk int) (*malcontent.FileReport, error)
func HighestMatchRisk ¶ added in v1.10.0
func HighestMatchRisk(mrs *yarax.ScanResults) int
HighestMatchRisk returns the highest risk score from a slice of MatchRules.
func Load ¶ added in v1.19.0
func Load(data []byte) (malcontent.ScanResult, error)
func TrimPrefixes ¶ added in v1.5.0
TrimPrefixes removes the specified prefix from a given path for the purposes of sample test data generation. This function will only be used via the refresh package.
Types ¶
type StringPool ¶ added in v1.8.0
StringPool holds data to handle string interning.
func NewStringPool ¶ added in v1.8.0
func NewStringPool(length int) *StringPool
NewStringPool creates a new string pool.
func (*StringPool) Intern ¶ added in v1.8.0
func (sp *StringPool) Intern(s string) string
Intern returns an interned version of the input string.