Documentation
¶
Index ¶
- Constants
- Variables
- func ApplicableCveReviewContent(issue issues.ApplicableEvidences, writer OutputWriter) string
- func ConvertContentToComments(content []string, writer OutputWriter, commentDecorators ...CommentDecorator) (comments []string)
- func GenerateReviewCommentContent(content string, writer OutputWriter) string
- func GetApplicabilityDescriptionTable(severity, issueId, impactedDependency, finding string, writer OutputWriter) string
- func GetBanner(banner ImageSource) string
- func GetExpectedTestCaseOutput(t *testing.T, testCase OutputTestCase) []string
- func GetExpectedTestOutput(t *testing.T, testCase OutputTestCase) string
- func GetFallbackReviewCommentContent(content string, location formats.Location) string
- func GetIconTag(imageSource ImageSource, alt string) string
- func GetImgTag(imageSource ImageSource, alt string) string
- func GetJsonBodyOutputFromFile(t *testing.T, filePath string) []byte
- func GetMainCommentContent(contentForComments []string, issuesExists, isComment bool, ...) (comments []string)
- func GetMarkdownCenterTag(content string) string
- func GetOutputFromFile(t *testing.T, filePath string) string
- func GetSimplifiedTitle(is ImageSource) string
- func GetVulnerabilitiesContent(vulnerabilities []formats.VulnerabilityOrViolationRow, writer OutputWriter) (content []string)
- func IacReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
- func IsFrogbotComment(content string) bool
- func MarkAsBold(content string) string
- func MarkAsBullet(content string) string
- func MarkAsCodeSnippet(snippet string) string
- func MarkAsLink(content, link string) string
- func MarkAsQuote(content string) string
- func MarkdownComment(text string) string
- func NormalizeJsonBodyLineEndings(t *testing.T, payload []byte) []byte
- func PolicyViolationsContent(issues issues.ScansIssuesCollection, writer OutputWriter) (policyViolationContent []string)
- func SastReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
- func ScanSummaryContent(issues issues.ScansIssuesCollection, context results.ResultContext, ...) string
- func SecretReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
- func SectionDivider() string
- func SnippetReviewContent(violation bool, writer OutputWriter, licenses []formats.LicenseViolationRow, ...) string
- func StripScanResultsLinkFromJsonBody(t *testing.T, payload []byte) (stripped []byte, found bool)
- func WriteContent(builder *strings.Builder, contents ...string)
- func WriteNewLine(builder *strings.Builder)
- type CellData
- type CommentDecorator
- type IconName
- type ImageSource
- type MarkdownColumn
- type MarkdownColumnType
- type MarkdownOutput
- func (mo *MarkdownOutput) HasInternetConnection() bool
- func (mo *MarkdownOutput) IsEntitledForJas() bool
- func (mo *MarkdownOutput) IsShowingCaColumn() bool
- func (mo *MarkdownOutput) PullRequestCommentTitle() string
- func (mo *MarkdownOutput) SetHasInternetConnection(connected bool)
- func (mo *MarkdownOutput) SetJasOutputFlags(entitled, showCaColumn bool)
- func (mo *MarkdownOutput) SetPullRequestCommentTitle(pullRequestCommentTitle string)
- func (mo *MarkdownOutput) SetSizeLimit(client vcsclient.VcsClient)
- func (mo *MarkdownOutput) SetVcsProvider(provider vcsutils.VcsProvider)
- func (mo *MarkdownOutput) SizeLimit(comment bool) int
- func (mo *MarkdownOutput) VcsProvider() vcsutils.VcsProvider
- type MarkdownTableBuilder
- func (t *MarkdownTableBuilder) AddRow(values ...string) *MarkdownTableBuilder
- func (t *MarkdownTableBuilder) AddRowWithCellData(values ...CellData) *MarkdownTableBuilder
- func (t *MarkdownTableBuilder) Build() string
- func (t *MarkdownTableBuilder) GetColumnInfo(name string) *MarkdownColumn
- func (t *MarkdownTableBuilder) HasContent() bool
- func (t *MarkdownTableBuilder) SetDelimiter(delimiter string) *MarkdownTableBuilder
- type OutputTestCase
- type OutputWriter
- type SimplifiedOutput
- func (smo *SimplifiedOutput) FormattedSeverity(severity, _ string) string
- func (smo *SimplifiedOutput) Image(source ImageSource) string
- func (smo *SimplifiedOutput) MarkAsDetails(summary string, subTitleDepth int, content string) string
- func (smo *SimplifiedOutput) MarkAsTitle(title string, subTitleDepth int) string
- func (smo *SimplifiedOutput) MarkInCenter(content string) string
- func (smo *SimplifiedOutput) Separator() string
- func (smo *SimplifiedOutput) SeverityIcon(severity severityutils.Severity) string
- type StandardOutput
- func (so *StandardOutput) FormattedSeverity(severity, applicability string) string
- func (so *StandardOutput) Image(source ImageSource) string
- func (so *StandardOutput) MarkAsDetails(summary string, _ int, content string) string
- func (so *StandardOutput) MarkAsTitle(title string, subTitleDepth int) string
- func (so *StandardOutput) MarkInCenter(content string) string
- func (so *StandardOutput) Separator() string
- func (so *StandardOutput) SeverityIcon(severity severityutils.Severity) string
- type TestBodyResponse
Constants ¶
const ( FrogbotTitlePrefix = "[🐸 Frogbot]" FrogbotRepoUrl = "https://github.com/jfrog/frogbot" FrogbotDocumentationUrl = "https://jfrog.com/help/r/jfrog-security-user-guide/shift-left-on-security/frogbot" JfrogSupportUrl = "https://jfrog.com/support/" ReviewCommentId = "FrogbotReviewComment" )
Variables ¶
var (
CommentGeneratedByFrogbot = MarkAsLink("🐸 JFrog Frogbot", FrogbotDocumentationUrl)
)
var ( // Used for tests that are outside the outputwriter package. TestMessagesDir = filepath.Join("..", "testdata", "messages") )
Functions ¶
func ApplicableCveReviewContent ¶
func ApplicableCveReviewContent(issue issues.ApplicableEvidences, writer OutputWriter) string
func ConvertContentToComments ¶
func ConvertContentToComments(content []string, writer OutputWriter, commentDecorators ...CommentDecorator) (comments []string)
ConvertContentToComments converts the given content to comments, and returns the comments as a list of strings. The content is split into comments based on the size limit of the output writer. The commentDecorators are applied to each comment.
func GenerateReviewCommentContent ¶
func GenerateReviewCommentContent(content string, writer OutputWriter) string
For review comment Frogbot creates on Scan PR
func GetApplicabilityDescriptionTable ¶
func GetApplicabilityDescriptionTable(severity, issueId, impactedDependency, finding string, writer OutputWriter) string
func GetBanner ¶
func GetBanner(banner ImageSource) string
func GetExpectedTestCaseOutput ¶
func GetExpectedTestCaseOutput(t *testing.T, testCase OutputTestCase) []string
func GetExpectedTestOutput ¶
func GetExpectedTestOutput(t *testing.T, testCase OutputTestCase) string
func GetFallbackReviewCommentContent ¶
When can't create review comment, create a fallback comment by adding the location description to the content as a prefix
func GetIconTag ¶
func GetIconTag(imageSource ImageSource, alt string) string
func GetImgTag ¶
func GetImgTag(imageSource ImageSource, alt string) string
func GetMainCommentContent ¶
func GetMainCommentContent(contentForComments []string, issuesExists, isComment bool, resultsPlatformURL string, writer OutputWriter) (comments []string)
Summary comment, including banner, footer wrapping the content with a decorator
func GetMarkdownCenterTag ¶
func GetSimplifiedTitle ¶
func GetSimplifiedTitle(is ImageSource) string
func GetVulnerabilitiesContent ¶
func GetVulnerabilitiesContent(vulnerabilities []formats.VulnerabilityOrViolationRow, writer OutputWriter) (content []string)
func IacReviewContent ¶
func IacReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
func IsFrogbotComment ¶
func MarkAsBold ¶
func MarkAsBullet ¶
func MarkAsCodeSnippet ¶
func MarkAsLink ¶
func MarkAsQuote ¶
func MarkdownComment ¶
func NormalizeJsonBodyLineEndings ¶ added in v3.4.0
NormalizeJsonBodyLineEndings rewrites CRLF to LF in the body of a comment creation payload. Issue descriptions served by the platform sometimes carry CRLF, while the golden files they are compared against are read through GetOutputFromFile, which normalizes them away.
func PolicyViolationsContent ¶
func PolicyViolationsContent(issues issues.ScansIssuesCollection, writer OutputWriter) (policyViolationContent []string)
Summary content for the security violations that we can't yet have location on (SCA, License)
func SastReviewContent ¶
func SastReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
func ScanSummaryContent ¶
func ScanSummaryContent(issues issues.ScansIssuesCollection, context results.ResultContext, includeSecrets bool, writer OutputWriter) string
func SecretReviewContent ¶
func SecretReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
func SectionDivider ¶
func SectionDivider() string
func SnippetReviewContent ¶
func SnippetReviewContent( violation bool, writer OutputWriter, licenses []formats.LicenseViolationRow, externalReferences []string, ) string
func StripScanResultsLinkFromJsonBody ¶ added in v3.4.0
StripScanResultsLinkFromJsonBody removes the scan results platform link title from the body of a comment creation payload, so that the rest of the body can be compared against a golden file. It reports whether such a link was present.
func WriteContent ¶
func WriteNewLine ¶
Types ¶
type CellData ¶
type CellData []string
CellData represents the data of a cell in the markdown table. Each cell can contain multiple values.
func NewCellData ¶
type CommentDecorator ¶
func GetFrogbotCommentBaseDecorator ¶
func GetFrogbotCommentBaseDecorator(writer OutputWriter) CommentDecorator
Adding markdown prefix to identify Frogbot comment and a footer with the link to the documentation
type ImageSource ¶
type ImageSource string
const ( NoVulnerabilityPrBannerSource ImageSource = "v2/noVulnerabilityBannerPR.png" NoVulnerabilityMrBannerSource ImageSource = "v2/noVulnerabilityBannerMR.png" VulnerabilitiesPrBannerSource ImageSource = "v2/vulnerabilitiesBannerPR.png" VulnerabilitiesMrBannerSource ImageSource = "v2/vulnerabilitiesBannerMR.png" VulnerabilitiesFixPrBannerSource ImageSource = "v2/vulnerabilitiesFixBannerPR.png" VulnerabilitiesFixMrBannerSource ImageSource = "v2/vulnerabilitiesFixBannerMR.png" )
func NoIssuesTitleSrc ¶
func NoIssuesTitleSrc(vcsProvider vcsutils.VcsProvider) ImageSource
func PRSummaryCommentTitleSrc ¶
func PRSummaryCommentTitleSrc(vcsProvider vcsutils.VcsProvider) ImageSource
type MarkdownColumn ¶
type MarkdownColumn struct {
Name string
Centered bool
OmitEmpty bool
ColumnType MarkdownColumnType
DefaultValue string
// contains filtered or unexported fields
}
func NewMarkdownTableSingleValueColumn ¶
func NewMarkdownTableSingleValueColumn(name, defaultValue string, centered bool) *MarkdownColumn
type MarkdownColumnType ¶
type MarkdownColumnType string
const ( // (Default value for columns) If more than one value exists in a cell, the values will be separated by the delimiter. SeparatorDelimited MarkdownColumnType = "single" // If more than one value exists in a cell, for each value a new row will be created. // The first row will contain the other columns values, and the rest of the rows will contain the values of the multi value column only. // Only works if exists up to one MultiRowColumn in the table. MultiRowColumn MarkdownColumnType = "multi" )
type MarkdownOutput ¶
type MarkdownOutput struct {
// contains filtered or unexported fields
}
func (*MarkdownOutput) HasInternetConnection ¶
func (mo *MarkdownOutput) HasInternetConnection() bool
func (*MarkdownOutput) IsEntitledForJas ¶
func (mo *MarkdownOutput) IsEntitledForJas() bool
func (*MarkdownOutput) IsShowingCaColumn ¶
func (mo *MarkdownOutput) IsShowingCaColumn() bool
func (*MarkdownOutput) PullRequestCommentTitle ¶
func (mo *MarkdownOutput) PullRequestCommentTitle() string
func (*MarkdownOutput) SetHasInternetConnection ¶
func (mo *MarkdownOutput) SetHasInternetConnection(connected bool)
func (*MarkdownOutput) SetJasOutputFlags ¶
func (mo *MarkdownOutput) SetJasOutputFlags(entitled, showCaColumn bool)
func (*MarkdownOutput) SetPullRequestCommentTitle ¶
func (mo *MarkdownOutput) SetPullRequestCommentTitle(pullRequestCommentTitle string)
func (*MarkdownOutput) SetSizeLimit ¶
func (mo *MarkdownOutput) SetSizeLimit(client vcsclient.VcsClient)
func (*MarkdownOutput) SetVcsProvider ¶
func (mo *MarkdownOutput) SetVcsProvider(provider vcsutils.VcsProvider)
func (*MarkdownOutput) SizeLimit ¶
func (mo *MarkdownOutput) SizeLimit(comment bool) int
func (*MarkdownOutput) VcsProvider ¶
func (mo *MarkdownOutput) VcsProvider() vcsutils.VcsProvider
type MarkdownTableBuilder ¶
type MarkdownTableBuilder struct {
// contains filtered or unexported fields
}
Create a markdown table using the provided columns and rows, and construct a markdown string with the table's content. Each cell in the table can contain no values (represented as column default value), single or multiple values (separated by the table delimiter).
func NewMarkdownTable ¶
func NewMarkdownTable(columns ...string) *MarkdownTableBuilder
Create a markdown table builder with the provided columns.
func NewMarkdownTableWithColumns ¶
func NewMarkdownTableWithColumns(columnsInfo ...*MarkdownColumn) *MarkdownTableBuilder
func NewNoHeaderMarkdownTable ¶
func NewNoHeaderMarkdownTable(nColumns int, firstColumnCentered bool) *MarkdownTableBuilder
Create a markdown table builder with the provided number of columns.
func (*MarkdownTableBuilder) AddRow ¶
func (t *MarkdownTableBuilder) AddRow(values ...string) *MarkdownTableBuilder
Add a row to the markdown table, each value will be added to the corresponding column. Use to add row with single value columns only.
func (*MarkdownTableBuilder) AddRowWithCellData ¶
func (t *MarkdownTableBuilder) AddRowWithCellData(values ...CellData) *MarkdownTableBuilder
Add a row to the markdown table, each value will be added to the corresponding column. Use to add row with multiple value columns.
func (*MarkdownTableBuilder) Build ¶
func (t *MarkdownTableBuilder) Build() string
func (*MarkdownTableBuilder) GetColumnInfo ¶
func (t *MarkdownTableBuilder) GetColumnInfo(name string) *MarkdownColumn
Get the column information output controller by the provided name.
func (*MarkdownTableBuilder) HasContent ¶
func (t *MarkdownTableBuilder) HasContent() bool
func (*MarkdownTableBuilder) SetDelimiter ¶
func (t *MarkdownTableBuilder) SetDelimiter(delimiter string) *MarkdownTableBuilder
Set the delimiter that will be used to separate multiple values in a cell.
type OutputTestCase ¶
type OutputTestCase struct {
// contains filtered or unexported fields
}
type OutputWriter ¶
type OutputWriter interface {
// Options
SetJasOutputFlags(entitled, showCaColumn bool)
IsShowingCaColumn() bool
IsEntitledForJas() bool
SetPullRequestCommentTitle(pullRequestCommentTitle string)
PullRequestCommentTitle() string
SetHasInternetConnection(connected bool)
HasInternetConnection() bool
SizeLimit(comment bool) int
SetSizeLimit(client vcsclient.VcsClient)
// VCS info
VcsProvider() vcsutils.VcsProvider
SetVcsProvider(provider vcsutils.VcsProvider)
// Markdown interface
SeverityIcon(severity severityutils.Severity) string
FormattedSeverity(severity, applicability string) string
Separator() string
MarkInCenter(content string) string
MarkAsDetails(summary string, subTitleDepth int, content string) string
MarkAsTitle(title string, subTitleDepth int) string
Image(source ImageSource) string
}
The OutputWriter interface allows Frogbot output to be written in an appropriate way for each git provider. Some git providers support markdown only partially, whereas others support it fully.
func GetCompatibleOutputWriter ¶
func GetCompatibleOutputWriter(provider vcsutils.VcsProvider, hasInternetConnection bool) OutputWriter
type SimplifiedOutput ¶
type SimplifiedOutput struct {
MarkdownOutput
}
func (*SimplifiedOutput) FormattedSeverity ¶
func (smo *SimplifiedOutput) FormattedSeverity(severity, _ string) string
func (*SimplifiedOutput) Image ¶
func (smo *SimplifiedOutput) Image(source ImageSource) string
func (*SimplifiedOutput) MarkAsDetails ¶
func (smo *SimplifiedOutput) MarkAsDetails(summary string, subTitleDepth int, content string) string
func (*SimplifiedOutput) MarkAsTitle ¶
func (smo *SimplifiedOutput) MarkAsTitle(title string, subTitleDepth int) string
func (*SimplifiedOutput) MarkInCenter ¶
func (smo *SimplifiedOutput) MarkInCenter(content string) string
func (*SimplifiedOutput) Separator ¶
func (smo *SimplifiedOutput) Separator() string
func (*SimplifiedOutput) SeverityIcon ¶
func (smo *SimplifiedOutput) SeverityIcon(severity severityutils.Severity) string
type StandardOutput ¶
type StandardOutput struct {
MarkdownOutput
}
func (*StandardOutput) FormattedSeverity ¶
func (so *StandardOutput) FormattedSeverity(severity, applicability string) string
func (*StandardOutput) Image ¶
func (so *StandardOutput) Image(source ImageSource) string
func (*StandardOutput) MarkAsDetails ¶
func (so *StandardOutput) MarkAsDetails(summary string, _ int, content string) string
func (*StandardOutput) MarkAsTitle ¶
func (so *StandardOutput) MarkAsTitle(title string, subTitleDepth int) string
func (*StandardOutput) MarkInCenter ¶
func (so *StandardOutput) MarkInCenter(content string) string
func (*StandardOutput) Separator ¶
func (so *StandardOutput) Separator() string
func (*StandardOutput) SeverityIcon ¶
func (so *StandardOutput) SeverityIcon(severity severityutils.Severity) string
type TestBodyResponse ¶
type TestBodyResponse struct {
Body string `json:"body"`
}