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, writer OutputWriter) (comments []string)
- func GetMarkdownCenterTag(content string) string
- func GetMarkdownSizeLimit(client vcsclient.VcsClient) int
- func GetOutputFromFile(t *testing.T, filePath string) string
- func GetPRSummaryContentNoIssues(t *testing.T, summaryTestDir string, entitled, simplified bool) 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 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 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) AvoidExtraMessages() bool
- func (mo *MarkdownOutput) HasInternetConnection() bool
- func (mo *MarkdownOutput) IsEntitledForJas() bool
- func (mo *MarkdownOutput) IsShowingCaColumn() bool
- func (mo *MarkdownOutput) PullRequestCommentTitle() string
- func (mo *MarkdownOutput) SetAvoidExtraMessages(avoidExtraMessages bool)
- 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://docs.jfrog-applications.jfrog.io/jfrog-applications/frogbot" JfrogSupportUrl = "https://jfrog.com/support/" ReviewCommentId = "FrogbotReviewComment" )
const ( SecretsEmailCSS = `` /* 876-byte string literal not displayed */ //#nosec G101 -- full secrets would not be hard coded SecretsEmailHTMLTemplate = `` /* 873-byte string literal not displayed */ //#nosec G101 -- full secrets would not be hard coded SecretsEmailTableRow = ` <tr> <td> %s </td> <td> %d:%d </td> <td> %s </td> </tr>` )
Variables ¶
var ( // Used for tests that are outside the outputwriter package. TestMessagesDir = filepath.Join("..", "testdata", "messages") TestSummaryCommentDir = filepath.Join(TestMessagesDir, "summarycomment") )
var (
CommentGeneratedByFrogbot = MarkAsLink("🐸 JFrog Frogbot", FrogbotDocumentationUrl)
)
Functions ¶
func ApplicableCveReviewContent ¶
func ApplicableCveReviewContent(issue issues.ApplicableEvidences, writer OutputWriter) string
func ConvertContentToComments ¶ added in v2.20.0
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 ¶ added in v2.20.0
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 ¶ added in v2.24.0
func GetImgTag(imageSource ImageSource, alt string) string
func GetMainCommentContent ¶ added in v2.24.0
func GetMainCommentContent(contentForComments []string, issuesExists, isComment bool, writer OutputWriter) (comments []string)
Summary comment, including banner, footer wrapping the content with a decorator
func GetMarkdownCenterTag ¶
func GetMarkdownSizeLimit ¶ added in v2.20.0
func GetSimplifiedTitle ¶
func GetSimplifiedTitle(is ImageSource) string
func GetVulnerabilitiesContent ¶ added in v2.24.0
func GetVulnerabilitiesContent(vulnerabilities []formats.VulnerabilityOrViolationRow, writer OutputWriter) (content []string)
func IacReviewContent ¶
func IacReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
func IsFrogbotComment ¶ added in v2.20.0
func MarkAsBold ¶
func MarkAsBullet ¶ added in v2.24.0
func MarkAsCodeSnippet ¶
func MarkAsLink ¶
func MarkAsQuote ¶
func MarkdownComment ¶
func PolicyViolationsContent ¶ added in v2.24.0
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 ¶ added in v2.24.0
func ScanSummaryContent(issues issues.ScansIssuesCollection, context results.ResultContext, includeSecrets bool, writer OutputWriter) string
func SecretReviewContent ¶ added in v2.23.7
func SecretReviewContent(violation bool, writer OutputWriter, issues ...formats.SourceCodeRow) string
func SectionDivider ¶
func SectionDivider() string
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 ¶ added in v2.20.0
func GetFrogbotCommentBaseDecorator ¶ added in v2.20.0
func GetFrogbotCommentBaseDecorator(writer OutputWriter) CommentDecorator
Adding markdown prefix to identify Frogbot comment and a footer with the link to the documentation
func GetPRSummaryMainCommentDecorator ¶ added in v2.20.0
func GetPRSummaryMainCommentDecorator(issuesExists, isComment bool, writer OutputWriter) CommentDecorator
Adding a banner, custom title and untitled Jas message to the content
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 ¶ added in v2.24.0
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) AvoidExtraMessages ¶
func (mo *MarkdownOutput) AvoidExtraMessages() bool
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) SetAvoidExtraMessages ¶
func (mo *MarkdownOutput) SetAvoidExtraMessages(avoidExtraMessages bool)
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 ¶ added in v2.20.0
func (mo *MarkdownOutput) SetSizeLimit(client vcsclient.VcsClient)
func (*MarkdownOutput) SetVcsProvider ¶
func (mo *MarkdownOutput) SetVcsProvider(provider vcsutils.VcsProvider)
func (*MarkdownOutput) SizeLimit ¶ added in v2.20.0
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 ¶ added in v2.24.0
func NewMarkdownTableWithColumns(columnsInfo ...*MarkdownColumn) *MarkdownTableBuilder
func NewNoHeaderMarkdownTable ¶ added in v2.24.0
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 ¶ added in v2.24.0
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 SetAvoidExtraMessages(avoidExtraMessages bool) AvoidExtraMessages() 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) 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 ¶ added in v2.24.0
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 ¶ added in v2.24.0
func (so *StandardOutput) SeverityIcon(severity severityutils.Severity) string
type TestBodyResponse ¶
type TestBodyResponse struct {
Body string `json:"body"`
}