Documentation ¶
Index ¶
Constants ¶
View Source
const ( UndetectedVulnerabilityLine = 1 DefaultQueryID = "Undefined" DefaultQueryName = "Anonymous" DefaultIssueType = model.IssueTypeIncorrectValue )
Variables ¶
View Source
var DefaultVulnerabilityBuilder = func(ctx QueryContext, v interface{}) (model.Vulnerability, error) { vOjb, ok := v.(map[string]interface{}) if !ok { return model.Vulnerability{}, ErrInvalidResult } vOjb = mergeWithMetadata(vOjb, ctx.query.metadata.Metadata) output, err := json.Marshal(vOjb) if err != nil { return model.Vulnerability{}, errors.Wrap(err, "failed to marshall query output") } fileID, err := mapKeyToString(vOjb, "documentId", false) if err != nil { return model.Vulnerability{}, errors.Wrap(err, "failed to recognize file id") } file, ok := ctx.files[*fileID] if !ok { return model.Vulnerability{}, errors.New("failed to find file from query response") } logWithFields := log.With(). Str("scanID", ctx.scanID). Str("fileID", file.ID). Str("queryName", ctx.query.metadata.Query). Logger() line := UndetectedVulnerabilityLine searchKey := "" if s, ok := vOjb["searchKey"]; ok { searchKey = s.(string) line = detectLine(ctx, &file, searchKey) } else { logWithFields.Warn().Msg("saving result. failed to detect line") } queryName := DefaultQueryName if qn, err := mapKeyToString(vOjb, "queryName", false); err == nil { queryName = *qn } else { logWithFields.Warn().Msg("saving result. failed to detect query name") } queryID := DefaultQueryID if qn, err := mapKeyToString(vOjb, "id", false); err == nil { queryID = *qn } else { logWithFields.Warn().Msg("saving result. failed to detect query id") } var severity model.Severity = model.SeverityInfo if s, err := mapKeyToString(vOjb, "severity", false); err == nil { su := strings.ToUpper(*s) var found bool for _, si := range model.AllSeverities { if su == string(si) { severity = si found = true break } } if !found { logWithFields.Warn().Str("severity", *s).Msg("saving result. invalid severity constant value") } } else { logWithFields.Info().Msg("saving result. failed to detect severity") } issueType := DefaultIssueType if v := mustMapKeyToString(vOjb, "issueType"); v != nil { issueType = model.IssueType(*v) } return model.Vulnerability{ ID: 0, ScanID: ctx.scanID, FileID: file.ID, FileName: file.FileName, QueryName: queryName, QueryID: queryID, Severity: severity, Line: line, IssueType: issueType, SearchKey: searchKey, KeyExpectedValue: ptrStringToString(mustMapKeyToString(vOjb, "keyExpectedValue")), KeyActualValue: ptrStringToString(mustMapKeyToString(vOjb, "keyActualValue")), Value: mustMapKeyToString(vOjb, "value"), Output: string(output), }, nil }
View Source
var ErrInvalidResult = errors.New("query: invalid result format")
View Source
var ErrNoResult = errors.New("query: not result")
Functions ¶
This section is empty.
Types ¶
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
func NewInspector ¶
func NewInspector( ctx context.Context, source QueriesSource, vb VulnerabilityBuilder, tracker Tracker, ) (*Inspector, error)
func (*Inspector) EnableCoverageReport ¶
func (c *Inspector) EnableCoverageReport()
func (*Inspector) GetCoverageReport ¶
type QueriesSource ¶
type QueriesSource interface {
GetQueries() ([]model.QueryMetadata, error)
}
type QueryContext ¶
type QueryContext struct {
// contains filtered or unexported fields
}
type VulnerabilityBuilder ¶
type VulnerabilityBuilder func(ctx QueryContext, v interface{}) (model.Vulnerability, error)
Click to show internal directories.
Click to hide internal directories.