Documentation
¶
Index ¶
- Constants
- Variables
- func FilterSeverityASC(original []string, severityMinLevel string) []string
- func HTMLToAnsi(_, cssClass, originalContent string) string
- func IsHTML(str string) bool
- func NewJSONWriter(next io.Writer, stripWhitespaces bool) io.Writer
- func RenderDivider() string
- func RenderError(ctx context.Context, err *snyk_errors.Error) string
- func RenderLink(str string) string
- func RenderTip(str string) string
- func RenderTitle(str string) string
- type ElementCallback
- type HTMLpresenter
- type JSONWriter
- type SummaryPayload
- type TemplateImplFunction
- type UnifiedFindingPresenter
- type UnifiedFindingPresenterOptions
- type UnifiedProjectResult
Constants ¶
const ( // SnykDocsURL is the base URL for Snyk's documentation. SnykDocsURL = "https://docs.snyk.io" // SnykDocsErrorCatalogPath is the path to the error catalog on Snyk's documentation website. SnykDocsErrorCatalogPath = "/scan-with-snyk/error-catalog" )
const ApplicationJSONMimeType = "application/json"
ApplicationJSONMimeType is the mime type for application/json.
const ConfigJSONStripWhitespaces = "internal_json_no_whitespaces"
ConfigJSONStripWhitespaces is the configuration key to strip whitespaces from JSON output.
const DefaultMimeType = "text/cli"
DefaultMimeType is the default mime type for the presenter.
const NoneMimeType = "unknown"
NoneMimeType is the mime type for when no mime type is specified.
Variables ¶
var DefaultTemplateFiles = []string{
"templates/unified_finding.tmpl",
"templates/finding.component.tmpl",
}
DefaultTemplateFiles is an instance of TemplatePathsStruct with the template paths.
Functions ¶
func FilterSeverityASC ¶
FilterSeverityASC filters a slice of severities based on a minimum level.
func HTMLToAnsi ¶
HTMLToAnsi converts HTML content to ANSI formatted text.
func NewJSONWriter ¶
NewJSONWriter creates a new JSON writer that can optionally strip whitespaces.
func RenderError ¶
func RenderError(ctx context.Context, err *snyk_errors.Error) string
RenderError renders a snyk_errors.Error to a string.
Types ¶
type ElementCallback ¶
ElementCallback is a function that can be used to transform an HTML element.
type HTMLpresenter ¶
type HTMLpresenter struct {
Callback ElementCallback
}
HTMLpresenter is a presenter that can convert HTML to plain text.
func NewHTMLPresenter ¶
func NewHTMLPresenter(callback ElementCallback) *HTMLpresenter
NewHTMLPresenter creates a new HTML presenter with the given callback.
type JSONWriter ¶
type JSONWriter struct {
// contains filtered or unexported fields
}
JSONWriter is a writer that can optionally strip whitespaces from JSON output.
type SummaryPayload ¶
type SummaryPayload struct { Summary *json_schemas.TestSummary `json:"summary"` DependencyCount int `json:"dependencyCount"` PackageManager string `json:"packageManager"` ProjectName string `json:"projectName"` DisplayTargetFile string `json:"displayTargetFile"` UniqueCount int32 `json:"uniqueCount"` VulnerablePathsCount int `json:"vulnerablePathsCount"` }
SummaryPayload is a wrapper for the test summary and additional metadata needed for the unified output.
type TemplateImplFunction ¶
TemplateImplFunction is a function that returns a template, a function map, and an error.
type UnifiedFindingPresenter ¶
type UnifiedFindingPresenter struct { Input []*UnifiedProjectResult // contains filtered or unexported fields }
UnifiedFindingPresenter is responsible for rendering unified findings data.
func NewUnifiedFindingsRenderer ¶
func NewUnifiedFindingsRenderer( unifiedFindingsDoc []*UnifiedProjectResult, config configuration.Configuration, writer io.Writer, options ...UnifiedFindingPresenterOptions, ) *UnifiedFindingPresenter
NewUnifiedFindingsRenderer creates a new presenter for unified findings. Note: This new renderer works directly with the testapi.FindingData model. The templates used will need to be compatible with this data structure.
func (*UnifiedFindingPresenter) RenderTemplate ¶
func (p *UnifiedFindingPresenter) RenderTemplate(templateFiles []string, mimeType string) error
RenderTemplate renders the template with the given files and MIME type.
type UnifiedFindingPresenterOptions ¶
type UnifiedFindingPresenterOptions func(presentation *UnifiedFindingPresenter)
UnifiedFindingPresenterOptions configures the UnifiedFindingPresenter.
func WithUnifiedRuntimeInfo ¶
func WithUnifiedRuntimeInfo(ri runtimeinfo.RuntimeInfo) UnifiedFindingPresenterOptions
WithUnifiedRuntimeInfo adds runtime information to the presenter.
type UnifiedProjectResult ¶
type UnifiedProjectResult struct { Findings []testapi.FindingData Summary *json_schemas.TestSummary DependencyCount int PackageManager string ProjectName string DisplayTargetFile string UniqueCount int VulnerablePathsCount int }
UnifiedProjectResult holds the findings and summary for a single project from the unified flow.