Skip to content

Commit

Permalink
New variable for skipping extra messages (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Oct 23, 2023
1 parent 75b2f6e commit ff1ec02
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 8 deletions.
10 changes: 9 additions & 1 deletion docs/install-azure-pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ jobs:
# Uncheck the 'Store Artifacts Locally' option
# 3. Set the value of the 'JF_RELEASES_REPO' variable with the Repository Key you created.
# JF_RELEASES_REPO: ""


# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down Expand Up @@ -267,6 +271,10 @@ jobs:
# [Mandatory if JF_SMTP_SERVER is set]
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
Expand Down
4 changes: 4 additions & 0 deletions docs/install-gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ frogbot-scan:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/github-actions/frogbot-scan-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ jobs:
# The full list of licenses can be found in:
# https://github.com/jfrog/frogbot/blob/master/docs/licenses.md
# JF_ALLOWED_LICENSES: "MIT, Apache-2.0"

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"
4 changes: 4 additions & 0 deletions docs/templates/github-actions/frogbot-scan-repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,7 @@ jobs:
# [Optional, Default: eco-system+frogbot@jfrog.com]
# Set the email of the commit author
# JF_GIT_EMAIL_AUTHOR: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"
4 changes: 4 additions & 0 deletions docs/templates/jenkins/scan-pull-request.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pipeline {
// The password associated with the username required for authentication with the SMTP server.
// JF_SMTP_PASSWORD= ""

// [Optional]
// Avoid adding extra info to pull request comments. that isn't related to the scan findings.
// JF_AVOID_EXTRA_MESSAGES= "TRUE"

///////////////////////////////////////////////////////////////////////////
// If your project uses a 'frogbot-config.yml' file, you should define //
// the following variables inside the file, instead of here. //
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jenkins/scan-repository.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pipeline {
// The 'frogbot' executable and other tools it needs will be downloaded through this repository.
// JF_RELEASES_REPO= ""

// [Optional]
// Avoid adding extra info to pull request comments. that isn't related to the scan findings.
// JF_AVOID_EXTRA_MESSAGES= "TRUE"

///////////////////////////////////////////////////////////////////////////
// If your project uses a 'frogbot-config.yml' file, you should define //
// the following variables inside the file, instead of here. //
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-pipenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
4 changes: 4 additions & 0 deletions docs/templates/jfrog-pipelines/pipelines-yarn2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pipelines:
# The password associated with the username required for authentication with the SMTP server.
# JF_SMTP_PASSWORD: ""

# [Optional]
# Avoid adding extra info to pull request comments. that isn't related to the scan findings.
# JF_AVOID_EXTRA_MESSAGES: "TRUE"

###########################################################################
## If your project uses a 'frogbot-config.yml' file, you should define ##
## the following variables inside the file, instead of here. ##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
```
some content
```
<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -16,6 +18,7 @@ some content

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
```
some content
```
<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -16,6 +18,7 @@ some content

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
some content
```

Note:

---
**Frogbot** also supports **Contextual Analysis, Secret Detection, IaC and SAST Vulnerabilities Scanning**. This features are included as part of the [JFrog Advanced Security](https://jfrog.com/advanced-security) package, which isn't enabled on your system.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
```
some content
```
<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -16,6 +18,7 @@ some content

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

</div>

<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -12,6 +14,7 @@

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
```
some content
```
<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -16,6 +18,7 @@ some content

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

</div>

<details>
<summary>Note</summary>

---
<div align='center'>
Expand All @@ -12,6 +14,7 @@

</div>

</details>

---
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
some content
```

Note:

---
**Frogbot** also supports **Contextual Analysis, Secret Detection, IaC and SAST Vulnerabilities Scanning**. This features are included as part of the [JFrog Advanced Security](https://jfrog.com/advanced-security) package, which isn't enabled on your system.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**👍 Frogbot scanned this pull request and found that it did not add vulnerable dependencies.**

Note:

---
**Frogbot** also supports **Contextual Analysis, Secret Detection, IaC and SAST Vulnerabilities Scanning**. This features are included as part of the [JFrog Advanced Security](https://jfrog.com/advanced-security) package, which isn't enabled on your system.

Expand Down
3 changes: 3 additions & 0 deletions utils/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const (
FixVersionPlaceHolder = "{FIX_VERSION}"
BranchHashPlaceHolder = "{BRANCH_NAME_HASH}"

// General flags
AvoidExtraMessages = "JF_AVOID_EXTRA_MESSAGES"

// Default naming templates
BranchNameTemplate = "frogbot-" + PackagePlaceHolder + "-" + BranchHashPlaceHolder
AggregatedBranchNameTemplate = "frogbot-update-" + BranchHashPlaceHolder + "-dependencies"
Expand Down
4 changes: 2 additions & 2 deletions utils/outputwriter/outputcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ func fixCVETitleSrc(vcsProvider vcsutils.VcsProvider) ImageSource {
}

func untitledForJasMsg(writer OutputWriter) string {
if writer.IsEntitledForJas() {
if writer.AvoidExtraMessages() || writer.IsEntitledForJas() {
return ""
}
return fmt.Sprintf("%s\n%s", SectionDivider(), writer.MarkInCenter(jasFeaturesMsgWhenNotEnabled))
return writer.MarkAsCollapsible("Note", fmt.Sprintf("%s\n%s", SectionDivider(), writer.MarkInCenter(jasFeaturesMsgWhenNotEnabled)))
}

func footer(writer OutputWriter) string {
Expand Down
7 changes: 7 additions & 0 deletions utils/outputwriter/outputcontent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,3 +853,10 @@ func TestSastReviewContent(t *testing.T) {
}
}
}

func TestMarkAsCollapsible(t *testing.T) {
so := &StandardOutput{}
assert.Equal(t, "<details>\n<summary>title</summary>\ndescription\n</details>", so.MarkAsCollapsible("title", "description"))
smo := &SimplifiedOutput{}
assert.Equal(t, "\ntitle:\ndescription", smo.MarkAsCollapsible("title", "description"))
}
18 changes: 15 additions & 3 deletions utils/outputwriter/outputwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,26 @@ type OutputWriter interface {
SetJasOutputFlags(entitled, showCaColumn bool)
IsShowingCaColumn() bool
IsEntitledForJas() bool
SetAvoidExtraMessages(avoidExtraMessages bool)
AvoidExtraMessages() bool
// VCS info
VcsProvider() vcsutils.VcsProvider
SetVcsProvider(provider vcsutils.VcsProvider)
// Markdown interface
FormattedSeverity(severity, applicability string) string
Separator() string
MarkAsCollapsible(title, content string) string
MarkInCenter(content string) string
MarkAsDetails(summary string, subTitleDepth int, content string) string
MarkAsTitle(title string, subTitleDepth int) string
Image(source ImageSource) string
}

type MarkdownOutput struct {
showCaColumn bool
entitledForJas bool
vcsProvider vcsutils.VcsProvider
avoidExtraMessages bool
showCaColumn bool
entitledForJas bool
vcsProvider vcsutils.VcsProvider
}

func (mo *MarkdownOutput) SetVcsProvider(provider vcsutils.VcsProvider) {
Expand All @@ -117,6 +121,14 @@ func (mo *MarkdownOutput) VcsProvider() vcsutils.VcsProvider {
return mo.vcsProvider
}

func (mo *MarkdownOutput) SetAvoidExtraMessages(avoidExtraMessages bool) {
mo.avoidExtraMessages = avoidExtraMessages
}

func (mo *MarkdownOutput) AvoidExtraMessages() bool {
return mo.avoidExtraMessages
}

func (mo *MarkdownOutput) SetJasOutputFlags(entitled, showCaColumn bool) {
mo.entitledForJas = entitled
mo.showCaColumn = showCaColumn
Expand Down
4 changes: 4 additions & 0 deletions utils/outputwriter/simplifiedoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func (smo *SimplifiedOutput) MarkInCenter(content string) string {
return content
}

func (smo *SimplifiedOutput) MarkAsCollapsible(title, content string) string {
return fmt.Sprintf("\n%s:\n%s", title, content)
}

func (smo *SimplifiedOutput) MarkAsDetails(summary string, subTitleDepth int, content string) string {
return fmt.Sprintf("%s\n%s", smo.MarkAsTitle(summary, subTitleDepth), content)
}
Expand Down
Loading

0 comments on commit ff1ec02

Please sign in to comment.