As a Black Duck® SCA customer, you can use Bridge CLI to automate SCA scanning in your CI pipeline.
- Run Black Duck® SCA in air gap mode. In this mode, Bridge CLI doesn't download Detect from the public Internet.
- Configure Black Duck® SCA to run with a proxy.
Running Black Duck® SCA scans with a JSON file
Pass sensitive information such as username and token using environmental variables, and run Bridge CLI and pass the JSON file using the --input command line option.
export BRIDGE_BLACKDUCKSCA_TOKEN=<BLACKDUCKSCA_TOKEN>
bridge-cli --stage blackducksca --input input.json BRIDGE_BLACKDUCKSCA_TOKENenvironment variable to pass sensitive information such as password or access token to Bridge CLI (recommended for security purposes). Note that Bridge CLI automatically picks up values passed through these environment variables.--stageargument to specify the Black Duck security product you are integrating with.
input.json file:{
"data": {
"blackducksca": {
"url": "<BLACKDUCKSCA_URL>",
"scan": {
"full": true,
"failure": {
"severities": ["CRITICAL"]
}
}
}
}
}
blackducksca.urlfor Black Duck® SCA URL.blackducksca.scan.fullshould be set totrueso that a full /intelligent scan is run by Bridge CLI. For pull request scans, this should be set tofalse.blackducksca.scan.failure.severitiesis a list of severities used by Bridge CLI to decide if the CI pipeline should be failed or not.
For the required minimum set of arguments that you need to pass to integrate Bridge CLI with Polaris, refer to the Polaris specific resources page under Schema Resources and Extensions.
For a complete list of environment variables and command line arguments, see Complete list of Bridge arguments.
Running Black Duck® SCA scans on the command line
Instead of using a JSON file, you can pass all arguments on the command line.
export BRIDGE_BLACKDUCKSCA_TOKEN=<BLACKDUCKSCA_TOKEN>
bridge-cli --stage blackducksca \
blackducksca.url=<BLACKDUCKSCA_URL> \
blackducksca.scan.failure.severities=CRITICAL,HIGH \
blackducksca.scan.full=trueBRIDGE_BLACKDUCKSCA_TOKENenvironment variable to pass sensitive information such as password or access token to Bridge CLI (recommended for security purposes). Note that Bridge CLI automatically picks up values passed through these environment variables.--stageargument to specify the Black Duck security product you are integrating with.blackducksca.urlfor Black Duck® SCA URL.blackducksca.scan.fullshould be set totrueso that a full/intelligent scan is run by Bridge CLI. For pull request scans, this should be set tofalse.blackducksca.scan.failure.severitiesis a comma separated list of severities used by Bridge CLI to decide if the CI pipeline should be failed or not.
For a complete list of environment variables and command line arguments, see Complete List of Bridge Arguments.
Adding comments to pull requests
Bridge CLI can add comments to pull requests when you perform a pull request scan. To add comments:
- Set blackducksca.automation.prcomment to true for pull request scans
- Pass SCM token as shown in the example below.
github.user.tokenfor GitHubgitlab.user.tokenfor GitLabazure.user.tokenfor Azure DevOps
- Pass additional options as necessary
Below is an example of passing pull request comments using an input.json file. Pass access tokens using environmental variables:
export BRIDGE_BLACKDUCKSCA_TOKEN=<BLACKDUCKSCA_TOKEN>
export GITHUB_USER_TOKEN=<GITHUB_USER_TOKEN> Create an input file as follows: {
"data": {
"blackducksca": {
"url": "<Black Duck URL>",
"scan":{
"full": true
},
"automation":{
"prComment": true
}
},
"github": {
"repository": {
"name": "<GitHub Repo Name>",
"owner": {
"name": "<GitHub Owner Name>"
},
"branch": {
"name": "<Branch Name>"
},
"pull": {
"number": <Pull Request Number>
}
}
}
}
}
If the file were called input.json you would use it by executing the following in a terminal:
bridge-cli --stage blackducksca --input input.jsonSee the previous section on this page about running Black Duck® SCA with a JSON file.
Creating fix pull requests
Bridge CLI can create fix PRs when you perform a full scan of your main branch. For each vulnerable direct dependency found by Black Duck® SCA, Bridge can open a pull request in your SCM with a change that updates the component version.
To create fix pull requests:
- Set
blackducksca.fixpr.enabledto true in your input file - Pass SCM token as shown in the example below
- Github.user.token for GitHub
- Gitlab.user.token for GitLab
- azure.user.token for Azure DevOps
- · Pass additional options as necessary
export BRIDGE_BLACKDUCKSCA_TOKEN=<BLACKDUCKSCA_TOKEN>
export GITHUB_USER_TOKEN=<GITHUB_USER_TOKEN>Create an input file as follows:
{
"data": {
"blackducksca": {
"url": "<URL>",
"scan": {
"full": "true"
},
"fixpr": {
"enabled": true,
"maxcount": 25,
"severities":["HIGH", "CRITICAL"]
}
},
"github": {
"repository" : {
"name": "<GitHub_Repository",
"branch": {
"name": "main"
},
"owner": {
"name" :"<REPO-OWNER>"
}
}
},
"environment":{
"scan": {
"pull": false
}
}
}
}
If the file were called input.json you would use it by executing the following in a terminal:
bridge-cli --stage blackducksca --input input.jsonSee the previous section on this page about running Black Duck® SCA with a JSON file.
Exporting a SARIF file
Bridge CLI allows you to export findings in a SARIF file.
{
"data":{
"blackducksca": {
"url": "<BLACKDUCKSCA_URL>",
"token": "<MY_TOKEN>",
"reports":
{
"sarif":{
"create":true,
"file":{
"path":"<PATH_TO_SARIF_FILE>"
}
"severities":[CRITICAL", "HIGH"],
"groupSCAissues":true
}
}
}
} Running Black Duck® SCA in air gap mode
- Download an appropriate version of Detect, either air-gap.zip or air-gap-no-docker.zip. Install it at one of the following locations:
<home>/.bridge/tools/blackducksca(default location), or- A location configured using
<detect.install.directory>to override the default.
- Set air gap to true, by either:
- Passing on the command line (
):network.airgap=true
orbridge-cli --stage blackducksca \ blackducksca.url=<BLACKDUCK_URL> \ blackducksca.scan.failure.severities=CRITICAL,HIGH \ blackducksca.scan.full=true \ network.airgap=true - Passing it as an argument in your JSON input file:
{ "data": { "blackducksca": { … }, "network": { "airgap": true } } }
- Passing on the command line (
- If using the PR Comment or Create Fix Pull request features, set the appropriate API URL.
github.api.urlfor GitHubgitlab.api.urlfor GitLabazure.api.urlfor Azure DevOps
Configuring proxy for Black Duck® SCA Detect
If proxy is configured using environment variables as described in Configuring proxy for Bridge, Bridge will automatically set the following Detect environment variables if they are not already set:
- BLACKDUCK_PROXY_HOST
- BLACKDUCK_PROXY_PORT
- BLACKDUCK_PROXY_IGNORED_HOSTS
If the proxy requires authentication information, you must set the following Detect environment variables :
- BLACKDUCK_PROXY_USERNAME
- BLACKDUCK_PROXY_PASSWORD