Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve GitHub & Jenkins installation flow #411

Merged
merged 49 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2409470
improve docs
sverdlov93 Aug 3, 2023
a74692b
improve docs
sverdlov93 Aug 3, 2023
73684c1
improve docs
sverdlov93 Aug 3, 2023
0ee686a
improve docs
sverdlov93 Aug 3, 2023
845b897
improve docs
sverdlov93 Aug 3, 2023
1ab62c6
improve docs
sverdlov93 Aug 3, 2023
eaee6ce
improve docs
sverdlov93 Aug 3, 2023
d794f0a
Merge branch 'dev' into Improve-docs
sverdlov93 Aug 6, 2023
42f9f61
Improve internal field names (#418)
omerzi Aug 6, 2023
cd94264
Fix aggregate PRs test (#420)
sverdlov93 Aug 7, 2023
98b6d8d
Fix open pull request against the wrong branch (#421)
omerzi Aug 9, 2023
06447ed
Update Git Action dependencies (#427)
sverdlov93 Aug 9, 2023
0313d1f
Restructure source code (#419)
sverdlov93 Aug 9, 2023
f918dcc
Fix mock import (#429)
sverdlov93 Aug 9, 2023
c5686f0
Fix undefined pull request ID in scan-pull-requests (#428)
omerzi Aug 10, 2023
35946c2
Upgrade golang.org/x/net to 0.13.0 (#430)
github-actions[bot] Aug 10, 2023
d0003a9
Remove base branch from github actions (#431)
omerzi Aug 10, 2023
7d0a53c
Separate env params extraction by context (#432)
EyalDelarea Aug 13, 2023
fecc67f
Update dependencies (#435)
omerzi Aug 13, 2023
ba52020
Update git action
sverdlov93 Aug 13, 2023
8e5ee73
Update git action
sverdlov93 Aug 13, 2023
50afd87
Update git action
sverdlov93 Aug 15, 2023
d7c5384
Merge branch 'dev' of https://github.com/jfrog/frogbot into Improve-docs
sverdlov93 Aug 15, 2023
cd55629
Update git action
sverdlov93 Aug 15, 2023
8b6fb44
Update git action
sverdlov93 Aug 15, 2023
d0ced5f
Update git action
sverdlov93 Aug 15, 2023
e04ba73
Update git action
sverdlov93 Aug 15, 2023
c5d4ae6
Update git action
sverdlov93 Aug 15, 2023
b6bad60
Unify webhook url markdown
EyalDelarea Aug 15, 2023
e84bfdc
Update scan-pull-request.jenkinsfile
EyalDelarea Aug 15, 2023
5847d16
Update scan-repository.jenkinsfile
sverdlov93 Aug 15, 2023
dd6e994
Update scan-pull-request.jenkinsfile
sverdlov93 Aug 15, 2023
d7b1e49
add jenkins pipeline logo
EyalDelarea Aug 15, 2023
483b265
move position
EyalDelarea Aug 15, 2023
22db75d
change image
EyalDelarea Aug 15, 2023
53e5720
Update README.md
EyalDelarea Aug 15, 2023
b4f90d4
Merge pull request #25 from EyalDelarea/improve-docs
sverdlov93 Aug 15, 2023
e518dcc
Update README.md
sverdlov93 Aug 15, 2023
4bac1ea
Update README.md
sverdlov93 Aug 15, 2023
7338f59
Update README.md
sverdlov93 Aug 15, 2023
1903e72
Update README.md
sverdlov93 Aug 15, 2023
9f8133e
Update install-github.md
sverdlov93 Aug 15, 2023
6a90970
Delete jenkins-logo.png
sverdlov93 Aug 15, 2023
d7ef6e3
Update README.md
sverdlov93 Aug 15, 2023
0eda823
Update README.md
sverdlov93 Aug 15, 2023
d7bda7b
Update README.md
sverdlov93 Aug 15, 2023
5a9869f
Update git action
sverdlov93 Aug 15, 2023
6835f17
Merge branch 'dev' of https://github.com/jfrog/frogbot into Improve-docs
sverdlov93 Aug 15, 2023
a62ec9a
Update git action
sverdlov93 Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands/utils/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type FrogbotDetails struct {
type RepoAggregator []Repository

// NewRepoAggregator returns an initialized RepoAggregator with an empty repository
func NewRepoAggregator() RepoAggregator {
func newRepoAggregator() RepoAggregator {
return RepoAggregator{{Params: Params{Scan: Scan{Projects: []Project{{}}}}}}
}

Expand Down Expand Up @@ -341,7 +341,7 @@ func BuildRepoAggregator(configFileContent []byte, gitParamsFromEnv *Git, server
// If there is no config file, the function returns a RepoAggregator with an empty repository.
func unmarshalFrogbotConfigYaml(yamlContent []byte) (result RepoAggregator, err error) {
if len(yamlContent) == 0 {
result = NewRepoAggregator()
result = newRepoAggregator()
return
}
err = yaml.Unmarshal(yamlContent, &result)
Expand Down
4 changes: 2 additions & 2 deletions commands/utils/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestExtractParamsFromEnvError(t *testing.T) {
}

// Test extraction of env params in ScanPullRequest command
// Pull request ID is not default, which mean we don't have branches related variables defined.
// Pull request ID is not the default, which means we don't have branches related variables defined.
func TestExtractParamsFromEnvPlatformScanPullRequest(t *testing.T) {
SetEnvAndAssert(t, map[string]string{
JFrogUrlEnv: "http://127.0.0.1:8081",
Expand All @@ -48,7 +48,7 @@ func TestExtractParamsFromEnvPlatformScanPullRequest(t *testing.T) {
}

// Test extraction in ScanRepository command
// Pull request ID is default 0, which mean we will have branches related variables.
// Pull request ID's default is 0, which means we will have branches related variables.
func TestExtractParamsFromEnvPlatformScanRepository(t *testing.T) {
SetEnvAndAssert(t, map[string]string{
JFrogUrlEnv: "http://127.0.0.1:8081",
Expand Down
285 changes: 272 additions & 13 deletions docs/install-github.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,286 @@
[Go back to the main documentation page](https://github.com/jfrog/frogbot)

# Installing Frogbot on GitHub repositories
# Setting Frogbot on GitHub repositories

<summary>Install Frogbot Using GitHub Actions</summary>
## Github Prerequisites

- Make sure you have the connection details of your JFrog environment.
- Go to your **Frogbot Management Repository** settings page and save the JFrog connection details as repository secrets with the following names - **JF_URL**, **JF_ACCESS_TOKEN**

- Go to your **Frogbot Management Repository** settings page and save the JFrog connection details as repository secrets with the following names - **JF_URL**, **JF_USER**, and **JF_PASSWORD**
> **_NOTE:_** You can also use **JF_XRAY_URL** and **JF_ARTIFACTORY_URL** instead of **JF_URL**,
> and **JF_USER** + **JF_PASSWORD** instead of **JF_ACCESS_TOKEN**

> **_NOTE:_** You can also use **JF_XRAY_URL** and **JF_ARTIFACTORY_URL** instead of **JF_URL**, and **JF_ACCESS_TOKEN**
> instead of **JF_USER** and **JF_PASSWORD**

![](../images/github-repository-secrets.png)
<img src="../images/github-repository-secrets.png" width="600">

- Check the Allow GitHub Actions to create and approve pull requests check box.

![](../images/github-pr-permissions.png)
<img src="../images/github-pr-permissions.png" width="600">

- Create a new [GitHub environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment)
- For open-source projects: Create a new [GitHub environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment)
called **frogbot** and add people or public teams as reviewers. The chosen reviewers can trigger Frogbot scans on pull requests.

![](../images/github-environment.png)
<img src="../images/github-environment.png" width="600">

## Frogbot GitHub Action Templates

Use these templates to install [Frogbot](https://github.com/jfrog/frogbot/blob/master/README.md#frogbot) on your GitHub repository.
Push the workflow files to the `.github/workflows` directory at the root of your GitHub repository.

> **IMPORTANT**: The workflow files must be pushed to the target branch before Frogbot is triggered. This means that if, for example, a pull request includes the workflow files and the target branch doesn't, Frogbot will fail to run.

### 🔎Scan pull requests

Create a file named `frogbot-scan-pull-request.yml` with the content of the following template.
This will allow Frogbot to scan pull requests for security issues when the pull requests are open, and before they are merged.

<details>
<summary>Show Template</summary>

```yaml
name: "Frogbot Scan Pull Request"
on:
pull_request_target:
types: [opened, synchronize]
permissions:
pull-requests: write
contents: read
jobs:
scan-pull-request:
runs-on: ubuntu-latest
# A pull request needs to be approved before Frogbot scans it. Any GitHub user who is associated with the
# "frogbot" GitHub environment can approve the pull request to be scanned.
environment: frogbot
steps:
- uses: jfrog/frogbot@v2
env:
# [Mandatory]
# JFrog platform URL
JF_URL: ${{ secrets.JF_URL }}

# [Mandatory if JF_USER and JF_PASSWORD are not provided]
# JFrog access token with 'read' permissions on Xray service
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}

# [Mandatory if JF_ACCESS_TOKEN is not provided]
# JFrog username with 'read' permissions for Xray. Must be provided with JF_PASSWORD
# JF_USER: ${{ secrets.JF_USER }}

# [Mandatory if JF_ACCESS_TOKEN is not provided]
# JFrog password. Must be provided with JF_USER
# JF_PASSWORD: ${{ secrets.JF_PASSWORD }}

# [Mandatory]
# The GitHub token is automatically generated for the job
JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# [Optional, default: https://api.github.com]
# API endpoint to GitHub
# JF_GIT_API_ENDPOINT: https://github.example.com

# [Optional]
# By default, the Frogbot workflows download the Frogbot executable as well as other tools
# needed from https://releases.jfrog.io
# If the machine that runs Frogbot has no access to the internet, follow these steps to allow the
# executable to be downloaded from an Artifactory instance, which the machine has access to:
#
# 1. Login to the Artifactory UI, with a user who has admin credentials.
# 2. Create a Remote Repository with the following properties set.
# Under the 'Basic' tab:
# Package Type: Generic
# URL: https://releases.jfrog.io
# Under the 'Advanced' tab:
# 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: ""

##########################################################################
## If your project uses a 'frogbot-config.yml' file, you can define ##
## the following variables inside the file, instead of here. ##
##########################################################################

# [Mandatory if the two conditions below are met]
# 1. The project uses yarn 2, NuGet or .NET Core to download its dependencies
# 2. The `installCommand` variable isn't set in your frogbot-config.yml file.
#
# The command that installs the project dependencies (e.g "nuget restore")
# JF_INSTALL_DEPS_CMD: ""

# [Optional, default: "."]
# Relative path to the root of the project in the Git repository
# JF_WORKING_DIR: path/to/project/dir

# [Optional]
# Xray Watches. Learn more about them here: https://www.jfrog.com/confluence/display/JFROG/Configuring+Xray+Watches
# JF_WATCHES: <watch-1>,<watch-2>...<watch-n>

# [Optional]
# JFrog project. Learn more about it here: https://www.jfrog.com/confluence/display/JFROG/Projects
# JF_PROJECT: <project-key>

# [Optional, default: "FALSE"]
# Displays all existing vulnerabilities, including the ones that were added by the pull request.
# JF_INCLUDE_ALL_VULNERABILITIES: "TRUE"

# [Optional, default: "TRUE"]
# Fails the Frogbot task if any security issue is found.
# JF_FAIL: "FALSE"

# [Optional]
# Frogbot will download the project dependencies if they're not cached locally. To download the
# dependencies from a virtual repository in Artifactory, set the name of the repository. There's no
# need to set this value, if it is set in the frogbot-config.yml file.
# JF_DEPS_REPO: ""

# [Optional, Default: "FALSE"]
# If TRUE, Frogbot creates a single pull request with all the fixes.
# If false, Frogbot creates a separate pull request for each fix.
# JF_GIT_AGGREGATE_FIXES: "FALSE"

# [Optional, Default: "FALSE"]
# Handle vulnerabilities with fix versions only
# JF_FIXABLE_ONLY: "TRUE"

# [Optional]
# Set the minimum severity for vulnerabilities that should be fixed and commented on in pull requests
# The following values are accepted: Low, Medium, High or Critical
# JF_MIN_SEVERITY: ""
```

</details>

### 🛠️Scanning repository branches and fixing issues

Create a file named `frogbot-scan-and-fix.yml` with the content of the following template.
Make sure to follow the guidelines in the 'Using the Templates' section above.
This will make Frogbot open pull requests with fixes for security vulnerabilities found in the GitHub repository.

<details>
<summary>Show Template</summary>

```yaml
name: "Frogbot Scan Repository"
on:
workflow_dispatch:
schedule:
# The repository will be scanned once a day at 00:00 GMT.
- cron: "0 0 * * *"
permissions:
contents: write
pull-requests: write
security-events: write
jobs:
scan-repository:
runs-on: ubuntu-latest
strategy:
matrix:
# The repository scanning will be triggered periodically on the following branches.
branch: [ "dev" ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.branch }}

- uses: jfrog/frogbot@v2
env:
# [Mandatory]
# JFrog platform URL
JF_URL: ${{ secrets.JF_URL }}

# [Mandatory if JF_USER and JF_PASSWORD are not provided]
# JFrog access token with 'read' permissions on Xray service
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}

# [Mandatory if JF_ACCESS_TOKEN is not provided]
# JFrog username with 'read' permissions for Xray. Must be provided with JF_PASSWORD
# JF_USER: ${{ secrets.JF_USER }}

# [Mandatory if JF_ACCESS_TOKEN is not provided]
# JFrog password. Must be provided with JF_USER
# JF_PASSWORD: ${{ secrets.JF_PASSWORD }}

# [Mandatory]
# The GitHub token automatically generated for the job
JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# [Optional, default: https://api.github.com]
# API endpoint to GitHub
# JF_GIT_API_ENDPOINT: https://github.example.com

# [Optional]
# By default, the Frogbot workflows download the Frogbot executable as well as other tools
# needed from https://releases.jfrog.io
# If the machine that runs Frogbot has no access to the internet, follow these steps to allow the
# executable to be downloaded from an Artifactory instance, which the machine has access to:
#
# 1. Login to the Artifactory UI, with a user which has admin credentials.
# 2. Create a Remote Repository with the following properties set.
# Under the 'Basic' tab:
# Package Type: Generic
# URL: https://releases.jfrog.io
# Under the 'Advanced' tab:
# 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: ""

##########################################################################
## If your project uses a 'frogbot-config.yml' file, you can define ##
## the following variables inside the file, instead of here. ##
##########################################################################

# [Optional, default: "."]
# Relative path to the root of the project in the Git repository
# JF_WORKING_DIR: path/to/project/dir

# [Optional]
# Xray Watches. Learn more about them here: https://www.jfrog.com/confluence/display/JFROG/Configuring+Xray+Watches
# JF_WATCHES: <watch-1>,<watch-2>...<watch-n>

# [Optional]
# JFrog project. Learn more about it here: https://www.jfrog.com/confluence/display/JFROG/Projects
# JF_PROJECT: <project-key>

# [Optional, default: "TRUE"]
# Fails the Frogbot task if any security issue is found.
# JF_FAIL: "FALSE"

# [Optional]
# Frogbot will download the project dependencies, if they're not cached locally. To download the
# dependencies from a virtual repository in Artifactory, set the name of the repository. There's no
# need to set this value, if it is set in the frogbot-config.yml file.
# JF_DEPS_REPO: ""

# [Optional]
# Template for the branch name generated by Frogbot when creating pull requests with fixes.
# The template must include ${BRANCH_NAME_HASH}, to ensure that the generated branch name is unique.
# The template can optionally include the ${IMPACTED_PACKAGE} and ${FIX_VERSION} variables.
# JF_BRANCH_NAME_TEMPLATE: "frogbot-${IMPACTED_PACKAGE}-${BRANCH_NAME_HASH}"

# [Optional]
# Template for the commit message generated by Frogbot when creating pull requests with fixes
# The template can optionally include the ${IMPACTED_PACKAGE} and ${FIX_VERSION} variables.
# JF_COMMIT_MESSAGE_TEMPLATE: "Upgrade ${IMPACTED_PACKAGE} to ${FIX_VERSION}"

# [Optional]
# Template for the pull request title generated by Frogbot when creating pull requests with fixes.
# The template can optionally include the ${IMPACTED_PACKAGE} and ${FIX_VERSION} variables.
# JF_PULL_REQUEST_TITLE_TEMPLATE: "[🐸 Frogbot] Upgrade ${IMPACTED_PACKAGE} to ${FIX_VERSION}"

# [Optional, Default: "FALSE"]
# If TRUE, Frogbot creates a single pull request with all the fixes.
# If FALSE, Frogbot creates a separate pull request for each fix.
# JF_GIT_AGGREGATE_FIXES: "FALSE"

# [Optional, Default: "FALSE"]
# Handle vulnerabilities with fix versions only
# JF_FIXABLE_ONLY: "TRUE"

# [Optional]
# Set the minimum severity for vulnerabilities that should be fixed and commented on in pull requests
# The following values are accepted: Low, Medium, High or Critical
# JF_MIN_SEVERITY: ""

- Use our [GitHub Actions templates](templates/github-actions/README.md#frogbot-gitHub-actions-templates) to add Frogbot workflows to your project.
# [Optional, Default: eco-system+frogbot@jfrog.com]
# Set the email of the commit author
# JF_GIT_EMAIL_AUTHOR: ""

- Push the workflow files to the **.github/workflows** directory in the root of your **Frogbot Management Repository**.
```
</details>
45 changes: 0 additions & 45 deletions docs/templates/github-actions/README.md

This file was deleted.

Loading