presenters

package
v0.0.0-...-7a253ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ApplicationJSONMimeType = "application/json"
View Source
const ApplicationSarifMimeType = content_type.SARIF_JSON
View Source
const CONFIG_JSON_STRIP_WHITESPACES = "internal_json_no_whitespaces"
View Source
const DefaultMimeType = "text/cli"
View Source
const NoneMimeType = "unknown"

Variables

View Source
var ApplicationSarifTemplates = []string{
	"templates/local_finding.sarif.tmpl",
}
View Source
var DefaultTemplateFiles = []string{
	"templates/local_finding.tmpl",
	"templates/finding.component.tmpl",
}

DefaultTemplateFiles is an instance of TemplatePathsStruct with the template paths.

Functions

func FilterSeverityASC

func FilterSeverityASC(original []string, severityMinLevel string) []string

func NewJsonWriter

func NewJsonWriter(next io.Writer, stripWhitespaces bool) io.Writer

* This Writer can be used to strip away whitespaces from json content to reduce the final size

func RenderDivider

func RenderDivider() string

func RenderError

func RenderError(err snyk_errors.Error) string

func RenderFinding

func RenderFinding(finding Finding) string

func RenderFindings

func RenderFindings(findings []Finding, showIgnored bool, isSeverityThresholdApplied bool) string
func RenderLink(str string) string

func RenderSummary

func RenderSummary(summary *json_schemas.TestSummary, orgName string, testPath string, severityMinLevel string) (string, error)

func RenderTip

func RenderTip(str string) string

func RenderTitle

func RenderTitle(str string) string

Types

type Finding

type Finding struct {
	ID         string
	Severity   string
	Title      string
	Ignored    bool
	Properties []FindingProperty
}

func FilterFindingsBySeverity

func FilterFindingsBySeverity(findings []Finding, minLevel string, severityOrder []string) []Finding

func SortFindings

func SortFindings(findings []Finding, order []string) []Finding

type FindingProperty

type FindingProperty struct {
	Label string
	Value string
}

type JsonWriter

type JsonWriter struct {
	// contains filtered or unexported fields
}

func (*JsonWriter) Write

func (w *JsonWriter) Write(p []byte) (n int, err error)

type LocalFindingPresenter

type LocalFindingPresenter struct {
	TestPath string
	Input    []*local_models.LocalFinding
	// contains filtered or unexported fields
}

func NewLocalFindingsRenderer

func NewLocalFindingsRenderer(localFindingsDoc []*local_models.LocalFinding, config configuration.Configuration, writer io.Writer, options ...LocalFindingPresenterOptions) *LocalFindingPresenter

func (*LocalFindingPresenter) RegisterMimeType

func (p *LocalFindingPresenter) RegisterMimeType(mimeType string, implFactory TemplateImplFunction) error

func (*LocalFindingPresenter) RenderTemplate

func (p *LocalFindingPresenter) RenderTemplate(templateFiles []string, mimeType string) error

type LocalFindingPresenterOptions

type LocalFindingPresenterOptions func(presentation *LocalFindingPresenter)

type PresenterOption

type PresenterOption func(*SarifPresenter)

func WithIgnored

func WithIgnored(showIgnored bool) PresenterOption

func WithOrgName

func WithOrgName(orgName string) PresenterOption

func WithSeverityThershold

func WithSeverityThershold(severityMinLevel string) PresenterOption

func WithTestPath

func WithTestPath(testPath string) PresenterOption

type SarifPresenter

type SarifPresenter struct {
	ShowIgnored      bool
	Input            sarif.SarifDocument
	OrgName          string
	TestPath         string
	SeverityMinLevel string
}

func SarifTestResults

func SarifTestResults(sarifDocument sarif.SarifDocument, options ...PresenterOption) *SarifPresenter

func (*SarifPresenter) Render

func (p *SarifPresenter) Render() (string, error)

type SummaryData

type SummaryData struct {
	SummaryTitle                    string
	Org                             string
	TestPath                        string
	Type                            string
	TotalIssueCount                 int
	IgnoreIssueCount                int
	OpenIssueCountWithSeverities    string
	IgnoredIssueCountWithSeverities string
}

func PrepareSummary

func PrepareSummary(summary *json_schemas.TestSummary, orgName string, testPath string, severityMinLevel string) (data SummaryData)

type TemplateImplFunction

type TemplateImplFunction func() (*template.Template, template.FuncMap, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL