Skip to content

Commit

Permalink
Merge branch 'dev' into github-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Oct 24, 2023
2 parents 06424ca + ff1ec02 commit 2fc5719
Show file tree
Hide file tree
Showing 34 changed files with 146 additions and 12 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: [email protected]]
# 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
2 changes: 2 additions & 0 deletions scanpullrequest/scanpullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func auditPullRequestInProject(repoConfig *utils.Repository, scanDetails *utils.
// Audit source branch
var sourceResults *audit.Results
workingDirs := utils.GetFullPathWorkingDirs(scanDetails.Project.WorkingDirs, sourceBranchWd)
log.Info("Scanning source branch...")
sourceResults, err = scanDetails.RunInstallAndAudit(workingDirs...)
if err != nil {
return
Expand Down Expand Up @@ -199,6 +200,7 @@ func auditTargetBranch(repoConfig *utils.Repository, scanDetails *utils.ScanDeta
// Set target branch scan details
var targetResults *audit.Results
workingDirs := utils.GetFullPathWorkingDirs(scanDetails.Project.WorkingDirs, targetBranchWd)
log.Info("Scanning target branch...")
targetResults, err = scanDetails.RunInstallAndAudit(workingDirs...)
if err != nil {
return
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
15 changes: 11 additions & 4 deletions utils/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@ const (
IacComment ReviewCommentType = "Iac"
SastComment ReviewCommentType = "Sast"

RescanRequestComment = "rescan"
RescanRequestComment = "rescan"
commentRemovalErrorMsg = "An error occurred while attempting to remove older Frogbot pull request comments:"
)

func HandlePullRequestCommentsAfterScan(issues *IssuesCollection, repo *Repository, client vcsclient.VcsClient, pullRequestID int) (err error) {
if !repo.Params.AvoidPreviousPrCommentsDeletion {
// The removal of comments may fail for various reasons,
// such as concurrent scanning of pull requests and attempts
// to delete comments that have already been removed in a different process.
// Since this task is not mandatory for a Frogbot run,
// we will not cause a Frogbot run to fail but will instead log the error.
log.Debug("Looking for an existing Frogbot pull request comment. Deleting it if it exists...")
// Delete previous PR regular comments, if exists (not related to location of a change)
if err = DeleteExistingPullRequestComments(repo, client); err != nil {
err = errors.New("couldn't delete pull request comment: " + err.Error())
log.Error(fmt.Sprintf("%s:\n%v", commentRemovalErrorMsg, err))
return
}
// Delete previous PR review comments, if exists (related to location of a change)
if err = DeleteExistingPullRequestReviewComments(repo, pullRequestID, client); err != nil {
err = errors.New("couldn't delete pull request review comment: " + err.Error())
log.Error(fmt.Sprintf("%s:\n%v", commentRemovalErrorMsg, err))
return
}
}
Expand All @@ -49,9 +55,10 @@ func HandlePullRequestCommentsAfterScan(issues *IssuesCollection, repo *Reposito
err = errors.New("couldn't add pull request comment: " + err.Error())
return
}

// Handle review comments at the pull request
if err = addReviewComments(repo, pullRequestID, client, issues); err != nil {
err = errors.New("couldn't add review comments: " + err.Error())
err = errors.New("couldn't add pull request review comments: " + err.Error())
return
}
return
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"))
}
Loading

0 comments on commit 2fc5719

Please sign in to comment.