Containers CI/CD Plugin
Feature availability notice
Rapid7 no longer offers Container Security for new InsightVM customers. This feature is available to eligible InsightVM users only. If interested in this feature, see our Cloud Risk Complete offering.
InsightVM features a container assessment plugin that you can utilize via a Continuous Integration, Continuous Delivery (CI/CD) tool. Use this plugin to analyze a container image for vulnerability assessment on the Insight platform.
The plugin has the following capabilities:
- Configure custom rules for compliant container images
- Trigger build actions based on compliance to your rules
- Generate an assessment report
Container assessment plugin results are available both through your CI/CD tool and the Builds tab of InsightVM’s “Containers” screen.
Configure firewall rules to allow Insight Platform traffic
Is your Rapid7 product subscription provisioned for the United States? Check your region code first!
As of April 12th, 2021, all new customers subscribing to Rapid7 Insight products that elect to store their data in the United States will be provisioned for one of three data centers. Since these data centers have unique endpoints, any firewall rules you configure must correspond to the data center your organization is assigned to. Follow these steps to determine which United States data center your organization is part of:
- Go to insight.rapid7.com and sign in with your Insight account email address and password.
- Navigate to the Platform Home page.
- If you are not taken to this page by default, expand the product dropdown in the upper left and click My Account.
- Look for the Data Storage Region tag in the upper right corner of the page below your account name. Your United States region tag will show one of the following data centers:
- United States - 1
- United States - 2
- United States - 3
The plugin uses the following hostnames to communicate with the Insight Platform:
Region | Hostname |
---|---|
United States - 1 | us.api.insight.rapid7.com |
United States - 2 | us2.api.insight.rapid7.com |
United States - 3 | us3.api.insight.rapid7.com |
Canada | ca.api.insight.rapid7.com |
Europe | eu.api.insight.rapid7.com |
Japan | ap.api.insight.rapid7.com |
Australia | au.api.insight.rapid7.com |
In order for the plugin to transmit data, you must configure your network to allow traffic to the corresponding hostname of your designated InsightVM region.
NOTE
The region you chose for your plugin MUST match the region that has been selected previously in InsightVM. The plugin cannot communicate through a different region.
Install and configure the Jenkins plugin
Complete the following steps to configure your Jenkins plugin:
Generate the Rapid7 API key
To use the Jenkins plugin, you need the Rapid7 API key to access the Rapid7 Insight Platform.
In order to access the Rapid7 Insight Platform, you will need a Rapid7 Insight account, which is different from your Security Console user account.
Here's how to get a Rapid7 Insight Platform account:
- If you are an InsightIDR, InsightAppSec, or InsightOps customer, you already have a Rapid7 Insight Platform account. You can link your existing InsightVM Security Console to the Rapid7 Insight Platform account you created with your other Rapid7 product by following the instructions here.
- If you are already using the cloud capabilities of InsightVM and don’t have a Rapid7 Insight Platform account, contact the Rapid7 Technical Support team to request one.
Follow these steps to generate the Rapid7 API key:
- Go to insight.rapid7.com and sign in with your Insight account email address and password.
- Go to API Keys.
- Under Organization Key, click on New Organization Key.
- In the Organization dropdown menu, select your InsightVM organization name.
- Enter a name for your key in the field.
- Click Generate.
- Copy and save the provided API key.
NOTE
This is the only time you will be able to see the API key, so store it in a safe place. If you misplace your API key, you can always generate a new one.
- Click Done.
- Your new API key will display in the “Organization Key” table.
Install the Jenkins plugin
There are two ways to install the Jenkins plugin. Both ways require Jenkins administrative privileges. Jenkins version 2.89.3 is the minimum supported version.
NOTE
For the latest version information and dependency requirements, see https://plugins.jenkins.io/rapid7-insightvm-container-assessment.
Install the Jenkins plugin through the Jenkins Update Center
We recommend this method to install the Jenkins plugin because it’s the simplest and most common way to install plugins. You must be a Jenkins administrator to navigate through this path: Manage Jenkins > Manage Plugins
- In the "Filter" box, search for "InsightVM."
- Under the Available tab, select the checkbox for the InsightVM Container Image Scanner.
- Click the desired install button.
Install the Jenkins plugin manually
Follow these steps for manual installation:
- Download the plugin from Jenkins website. Verify your download with SHA1.
- Log into Jenkins as an admin user.
- Click Manage Jenkins in your navigation menu.
- On the “Manage Jenkins” page, click Manage Plugins.
- Click the Advanced tab.
- Under the “Upload Plugin” section, click Choose file to browse to the Rapid7 Jenkins plugin.
- Click Upload.
- Select the “Restart Jenkins” option.
Configure the Jenkins plugin
Use the API key and follow these steps:
- After Jenkins restarts, return to the “Manage Jenkins” page.
- Click Configure System.
- Scroll to the “Rapid7 InsightVM Container Assessment” section.
- In the “InsightVM Region” field, select the region that InsightVM uses to access the Insight Platform.
- In the “Insight Platform API Key” field, click Add. In the dropdown menu, select “Jenkins” to configure the Insight platform API key that you generated earlier.
- In the window that appears, complete these fields:
- In the “Domain” field, select "Global credentials (unrestricted)."
- In the “Kind” field, select "Secret text."
- In the "Scope" field, select “Global (Jenkins, nodes, items, all child items, etc).”
- In the “Secret” field, enter your API key.
- Leave the “ID” field blank.
- Enter a description for your reference.
- Click Add.
- Select your newly configured credential from the dropdown menu.
NOTE
Click Test Connection to verify that the region and token are valid.
- Click Save to complete your plugin configuration.
Job setup
You must configure your build jobs to use the plugin after installation. Complete the steps for your chosen CI/CD tool:
Jenkins build bob setup
The plugin supports the following Jenkins build methods:
Freestyle build
“Freestyle” is the classic job builder. Build steps can be added or removed via the user interface:
- In a new or existing job, click Add build step.
- Select Assess Container Image with Rapid7 InsightVM. This will add a build step with a blank configuration.
- Configure the items under “Options” as desired.
- Click Add under the respective “Rules” section to configure the conditions that will trigger a build action. Two rule types are available:
- “Threshold Rules” - Sets a numeric limit. Values that exceed this limit will trigger the build action.
- “Name Rules” - Matches text using the “contains” operator. A match will trigger the build action.
NOTE
The order of your configured rules will not matter when the job is run. Any individual rule can trigger the build action specified.
- Click Save when finished.
Pipeline build
The “Pipeline” method involves generating build step scripts from the plugin and adding them to the existing Pipeline script:
- In a new or existing job, browse to the “Pipeline” section.
- Click Pipeline Syntax below the “Script” field.
- Open the dropdown next to “Sample Step” and select "assessContainerImage: Assess Container Image with Rapid7 InsightVM".
- Configure your build options and rules in the same manner as before.
- Click Generate Pipeline Script when finished.
- Add your new step script to the existing Pipeline script.
Pipeline Script
1// Assess the image2assessContainerImage failOnPluginError: true,3imageId: "${my_image.id}",4thresholdRules: [5exploitableVulnerabilities(action: 'Mark Unstable', threshold: '1')6],7nameRules: [8vulnerablePackageName(action: 'Fail', contains: 'nginx')9]10
- See the following example for correct location and syntax:
Pipeline Script Example
1node {2// Define a variable to use across stages3def my_image4stage('Build') {5// Get Dockerfile and code from Git (or other source control)6checkout scm7// Build Docker image and set image reference8my_image = docker.build("test-app:${env.BUILD_ID}")9echo "Built image ${my_image.id}"10}11stage('Test') {12// Assess the image13assessContainerImage failOnPluginError: true,14imageId: "${my_image.id}",15thresholdRules: [16exploitableVulnerabilities(action: 'Mark Unstable', threshold: '1')17],18nameRules: [19vulnerablePackageName(action: 'Fail', contains: 'nginx')20]21}22stage('Deploy') {23echo "Deploying image ${my_image.id} to somewhere..."24// Push image and deploy a container25}26}27
- Click Save when finished.
NOTE
Threshold rules must be unique per type. For example, you cannot have two rules for Critical Vulnerabilities. Only one instance of the rule will be applied.
View assessment results
After running a build, you can view assessment results in the following ways:
Assessment results in Jenkins
Jenkins will generate an assessment report once the build finishes.
- Open the individual build that ran the plugin.
- Click Rapid7 Assessment on your navigation menu.
Assessment results in InsightVM
The results of your build jobs are viewable on the Builds tab of the “Containers” screen in InsightVM. See Containers Build Interface to learn more about this feature.