Before running a pipeline using the Black Duck Security Scan Template with Polaris, you must set the appropriate applications and entitlements in your Polaris environment.
Using the Black Duck Security Scan Template, you can perform scans on push events to main branches.
Client scan tools can be configured using the Bridge CLI environment variables within the Black Duck Security Scan Template. For SAST scans the Coverity version can be selected using the BRIDGE_COVERITY_VERSION environment variable. Please refer to Complete List Of Bridge Commands for further details.
It is recommended that you configure sensitive information such as access tokens and URLs using GitLab secrets.
A Polaris Project is created as necessary. If you don't want the project to be created, set polaris.onboarding to false.
For an overview about using PR Comments, please see the following documentation page: Pull request (PR) comments.
For an overview about using Fix Pull Requests, please see the following documentation page: Fix pull requests (Fix PRs).
To use the GitLab Template, add .gitlab-ci.yml to your project by using an include entry, as shown in the examples below.
Simplified example
include:
- project: blackduck-inc/black-duck-security-scan
ref: v2
file: templates/security_scan.yml
### Use below configuration for accessing blackduck-security-scan in Gitlab self-managed
# - remote: 'https://gitlab.com/blackduck-inc/black-duck-security-scan/-/raw/main/templates/security_scan.yml'
stages:
- security
variables:
SCAN_BRANCHES: "/^(main|master|develop|stage|release|feature_branch)$/" # Add branches where you want to run Black Duck scan
Polaris:
stage: security
extends: .run-black-duck-tools # Used for bash.
# extends: .run-black-duck-tools-powershell # Used for powershell
variables:
BRIDGE_POLARIS_SERVERURL: $POLARIS_SERVERURL
BRIDGE_POLARIS_ACCESSTOKEN: $POLARIS_ACCESSTOKEN
BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SAST,SCA'
### Required When PR comments or Fix PR enabled
# BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
### Pull Request Comments
# BRIDGE_POLARIS_PRCOMMENT_ENABLED: 'true'
### Fix Pull Request Creation
# BRIDGE_POLARIS_FIXPR_ENABLED: 'true'
### SARIF Report Creation
# BRIDGE_POLARIS_REPORTS_SARIF_CREATE: 'true'
### Create and Upload GitLab Security Report
# BRIDGE_POLARIS_REPORTS_GITLAB_CREATE: 'true'
### Enable Bridge CLI diagnostics
# INCLUDE_DIAGNOSTICS: 'true'
rules:
- if: ($CI_COMMIT_REF_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
before_script:
- apt-get -qq update && apt-get install -y curl unzip
artifacts:
name: "bridge-logs"
when: always
### Uncomment to Upload Gitlab Security Report
# reports:
# sast: $CI_PROJECT_DIR/.blackduck/integrations/polaris/gitlab_report/sast.json
# dependency_scanning: $CI_PROJECT_DIR/.blackduck/integrations/polaris/gitlab_report/sca.json
### Uncomment to Upload Diagnostics or SARIF Report
# paths:
# - .bridge # Upload bridge diagnostics to artifact
# - .blackduck/integrations/polaris/sarif/report.sarif.json # Used when BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled
# expire_in: 30 days
Once you push the changes above, an active runner will pick up the job and initiate the pipeline.
Detailed example
include:
- project: blackduck-inc/black-duck-security-scan
ref: v2
file: templates/security_scan.yml
### Use below configuration for accessing blackduck-security-scan in Gitlab self-managed
# - remote: 'https://gitlab.com/blackduck-inc/black-duck-security-scan/-/raw/main/templates/security_scan.yml'
stages:
- polaris_scan
variables:
SCAN_BRANCHES: "/^(main|master|develop|stage|release|feature_branch)$/" # Add branches where you want to run Polaris scan
blackduck_security_scan_execution:
stage: polaris_scan
variables:
BRIDGE_POLARIS_SERVERURL: $POLARIS_SERVER_URL
BRIDGE_POLARIS_ACCESSTOKEN: $POLARIS_ACCESS_TOKEN
BRIDGE_POLARIS_APPLICATION_NAME: $CI_PROJECT_NAME
BRIDGE_POLARIS_PROJECT_NAME: $CI_PROJECT_NAME
BRIDGE_POLARIS_BRANCH_NAME: $CI_COMMIT_REF_NAME
BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SCA,SAST'
### Uncomment to specify the directory to scan. Default value is repository root
#BRIDGE_PROJECT_DIRECTORY: $PROJECT_DIRECTORY
### Uncomment below to add arbitrary CL parameters
#BRIDGE_COVERITY_BUILD_COMMAND: 'mvn clean install'
#BRIDGE_COVERITY_CLEAN_COMMAND: 'mvn clean'
#BRIDGE_COVERITY_CONFIG_PATH: '/USERS/USER/coverity.yml'
#BRIDGE_COVERITY_ARGS: '-c /USERS/USER/coverity.yml -o capture.build.clean-command="mvn clean" -- mvn clean install'
#BRIDGE_COVERITY_VERSION: '2025.6.2'
#BRIDGE_DETECT_SEARCH_DEPTH: 1
#BRIDGE_DETECT_CONFIG_PATH: '/USERS/USER/application.properties'
#BRIDGE_DETECT_ARGS: '--detect.diagnostic=true'
### Uncomment this to use Source Upload method. Default value is hybrid (build based)
#BRIDGE_POLARIS_TEST_SAST_LOCATION: 'remote'
#BRIDGE_POLARIS_TEST_SCA_LOCATION: 'remote'
#BRIDGE_PROJECT_SOURCE_ARCHIVE: $PROJECT_ARCHIVE
#BRIDGE_PROJECT_SOURCE_EXCLUDES: $PROJECT_SOURCE_EXCLUDES
#### Uncomment this to use Local Analysis feature
#Please use Local Analysis or Source Upload exclusively
#BRIDGE_POLARIS_TEST_SAST_LOCATION: 'local'
### Enable Bridge CLI diagnostics
INCLUDE_DIAGNOSTICS: 'true'
### Mark build status if policy violating issues are found
#MARK_BUILD_STATUS: 'success'
rules:
### Post scan options for push events to main, develop, staging or release branches,
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
### Fix PR configurations
BRIDGE_POLARIS_FIXPR_ENABLED: 'true' # When Fix PR enabled $GITLAB_USER_TOKEN is mandatory
BRIDGE_POLARIS_FIXPR_MAXCOUNT: '5'
BRIDGE_POLARIS_FIXPR_USEUPGRADEGUIDANCE: 'SHORT_TERM,LONG_TERM'
BRIDGE_POLARIS_FIXPR_FILTER_SEVERITIES: 'CRITICAL,HIGH'
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
### SARIF report configurations
BRIDGE_POLARIS_REPORTS_SARIF_CREATE: 'true'
BRIDGE_POLARIS_REPORTS_SARIF_FILE_PATH: $CI_PROJECT_DIR/report.sarif.json
BRIDGE_POLARIS_REPORTS_SARIF_ISSUE_TYPES: 'SCA,SAST'
BRIDGE_POLARIS_REPORTS_SARIF_SEVERITIES: 'CRITICAL,HIGH'
BRIDGE_POLARIS_REPORTS_SARIF_GROUPSCAISSUES: 'true'
### Uncomment this to use Gitlab Security Report
#BRIDGE_POLARIS_REPORTS_GITLAB_CREATE: 'true'
#BRIDGE_POLARIS_REPORTS_GITLAB_DIR_PATH: $CI_PROJECT_DIR
#BRIDGE_POLARIS_REPORTS_GITLAB_ISSUE_TYPES: 'SCA,SAST'
#BRIDGE_POLARIS_REPORTS_GITLAB_SEVERITIES: 'CRITICAL,HIGH'
#BRIDGE_POLARIS_REPORTS_GITLAB_GROUPSCAISSUES: 'true'
#BRIDGE_POLARIS_WAITFORSCAN: 'false' # Used to support the async mode
### Signature scan
#BRIDGE_POLARIS_TEST_SCA_TYPE:'SCA-SIGNATURE'
### Uncomment below to run SCA Binary Scan
#BRIDGE_POLARIS_TEST_SCA_TYPE: 'SCA-BINARY'
#BRIDGE_POLARIS_ARTIFACTTOUPLOAD: '/path/to/source.zip'
### Polaris PR scan
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
variables:
BRIDGE_POLARIS_PRCOMMENT_ENABLED: 'true' # When PR comments is enabled $GITLAB_USER_TOKEN is mandatory
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
BRIDGE_POLARIS_PRCOMMENT_SEVERITIES: 'CRITICAL,HIGH'
tags:
- linux # Name of your Gitlab runner
extends: .run-black-duck-tools # Used for bash.
# extends: .run-black-duck-tools-powershell # Used for powershell
### Use below configuration for uploading job artifacts if you have enabled INCLUDE_DIAGNOSTICS or BRIDGE_POLARIS_REPORTS_SARIF_CREATE
artifacts:
when: always
### Uncomment this to use Gitlab Security Report
#reports:
#sast: $CI_PROJECT_DIR/.blackduck/integrations/polaris/gitlab_report/sast.json # BRIDGE_POLARIS_REPORTS_GITLAB_CREATE enabled and BRIDGE_POLARIS_REPORTS_GITLAB_DIR_PATH path is set
#dependency_scanning: $CI_PROJECT_DIR/.blackduck/integrations/polaris/gitlab_report/sca.json # BRIDGE_POLARIS_REPORTS_GITLAB_CREATE enabled and BRIDGE_POLARIS_REPORTS_GITLAB_DIR_PATH path is set
paths:
- .bridge # Upload bridge diagnostics to artifact
- .blackduck/integrations/polaris/sarif/report.sarif.json # Used when BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled
- $CI_PROJECT_DIR/report.sarif.json # Used when BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled and BRIDGE_POLARIS_REPORTS_SARIF_FILE_PATH is set
### Uncomment below configuration to add custom logic based on return status
#after_script : |
# echo "Polaris Scan exit status - $status"
| Input Parameter | Description | Mandatory / Optional |
|---|---|---|
BRIDGE_POLARIS_ACCESSTOKEN |
Polaris access token. You can use either a user access token (created in the Polaris UI) or a service account token here. | Mandatory |
BRIDGE_POLARIS_APPLICATION_NAME |
Application name in Polaris The Default Value is CI_PROJECT_NAME |
Optional |
BRIDGE_POLARIS_ASSESSMENT_TYPES |
Polaris assessment types Accepted values:
For DAST configuration requirements, see Using Bridge CLI With Polaris. |
Mandatory |
BRIDGE_POLARIS_BRANCH_NAME |
Branch name on the Polaris Server. The branch is created if it doesn't already exist. | Optional |
BRIDGE_POLARIS_BRANCH_PARENT_NAME |
Parent branch name on the Polaris Server. Parent branch name is used by the PR comments feature. | Optional |
BRIDGE_POLARIS_PROJECT_NAME |
Project name in PolarisThe Default Value is$CI_PROJECT_NAME |
Optional |
BRIDGE_POLARIS_SERVERURL |
Polaris server URL | Mandatory |
BRIDGE_GITLAB_USER_TOKEN |
GitLab User Access Token Example: |
Mandatory when BRIDGE_POLARIS_PRCOMMENT_ENABLED is set as true. |
BRIDGE_POLARIS_REPORTS_SARIF_CREATE |
Set this to Default: Note: SARIF reports can be generated for any configured branch; however, report generation is not supported in a merge request context.
|
Optional |
BRIDGE_POLARIS_REPORTS_SARIF_FILE_PATH |
File path (including file name) where SARIF report is created. Note: GitLab is only able to package artifacts found in the
$CI_PROJECT_DIR directory. If BRIDGE_POLARIS_REPORTS_SARIF_FILE_PATH is set outside $CI_PROJECT_DIR, SARIF report will not be uploaded.Default: |
Optional |
BRIDGE_POLARIS_REPORTS_SARIF_ISSUE_TYPES |
Lists which assessment issues types to include in SARIF file report. Example: |
Optional |
BRIDGE_POLARIS_REPORTS_SARIF_SEVERITIES |
Comma-separated list of SAST/SCA issue severities to include in SARIF file report. Valid severities are Default: All severities are included. |
Optional |
BRIDGE_POLARIS_REPORTS_SARIF_GROUPSCAISSUES |
When set to true, SCA issues are grouped by component. Set this to false to list SCA issues by vulnerability. Default: |
Optional |
BRIDGE_POLARIS_REPORTS_GITLAB_CREATE |
Set this to Note: Gitlab reports can be generated for any configured branch; however, report generation is not supported in a merge request context.
Default: |
Optional |
BRIDGE_POLARIS_REPORTS_GITLAB_DIR_PATH |
Directory path (excluding file name) where Gitlab report is created. Note: GitLab is only able to package artifacts found in the
$CI_PROJECT_DIR directory. If BRIDGE_POLARIS_REPORTS_GITLAB_DIR_PATH is set outside $CI_PROJECT_DIR, Gitlab report will not be uploaded.Default:
|
Optional |
BRIDGE_POLARIS_REPORTS_GITLAB_ISSUE_TYPES |
Lists which assessment issues types to create in Giltab file reports. Example: |
Optional |
BRIDGE_POLARIS_REPORTS_GITLAB_SEVERITIES |
Comma-separated list of SAST/SCA issue severities to include in Gitlab file report. Valid severities are Default: |
Optional |
BRIDGE_POLARIS_REPORTS_GITLAB_GROUPSCAISSUES |
When set to true, SCA issues are grouped by component. Set this to false to list SCA issues by vulnerability. Default: |
Optional |
BRIDGE_POLARIS_PRCOMMENT_ENABLED |
Option to enable automatic creation pull request comments for new issues found in the merge request. Note: The merge request from the feature branch to the main branch must exist for this feature to work.
Default: |
Optional |
BRIDGE_POLARIS_PRCOMMENT_SEVERITIES |
The value should be a comma-separated list of severities. Comments are created for issues where the issue severity matches one of the values specified using this option. Valid severities are: Default: |
Optional |
BRIDGE_POLARIS_FIXPR_ENABLED |
Enable Fix Pull Request creation for SCA vulnerabilities. Creates Pull Requests with dependency upgrades to fix security issues. Only runs on push and workflow_dispatch events. Default: |
Optional |
BRIDGE_POLARIS_FIXPR_MAXCOUNT |
Maximum number of Fix Pull Requests to create per scan/workflow run. This limits the number of Pull Requests generated to avoid overwhelming the repository with too many automated Pull Requests at once. Default: |
Optional |
BRIDGE_POLARIS_FIXPR_USEUPGRADEGUIDANCE |
Allows the user to specify short-term or long-term upgrade guidance, or both. If both values are provided, the first takes priority, and the second value is used only if the first returns no results. If upgrade guidance is not available, the Fix Pull Request is not created. Accepted Values:
Default: |
Optional |
BRIDGE_POLARIS_FIXPR_FILTER_SEVERITIES |
Comma-separated list of severity levels for which Fix PRs should be created. Filters SCA vulnerabilities by severity to control which security issues generate automated Fix Pull requests. Accepted values: One or more of the following (comma-separated, case-insensitive):
Default: |
Optional |
BRIDGE_POLARIS_ASSESSMENT_MODE |
The test mode type of the Polaris scan. Supported values: SOURCE_UPLOAD, CIDefault: Note: |
Optional |
BRIDGE_POLARIS_TEST_SAST_LOCATION |
Configure the location of source code capture and SAST analysis. Supported values are hybrid, local and remote.
Default: In In In |
Optional |
BRIDGE_POLARIS_TEST_SCA_LOCATION |
Configure location of source code capture and SCA analysis. Supported values are hybrid and remote.
Default: In In |
Optional |
BRIDGE_PROJECT_DIRECTORY |
The project source directory. Defaults to the repository root directory. Set this to specify a custom folder that is other than repository root. | Optional |
BRIDGE_PROJECT_SOURCE_ARCHIVE |
The zipped source file path. It overrides the project directory. | Optional |
BRIDGE_PROJECT_SOURCE_EXCLUDES |
A list of git ignore pattern strings that indicate the files need to be excluded from the zip file. | Optional |
BRIDGE_POLARIS_TEST_SAST_TYPE |
Polaris test type to trigger sigma rapid scan or full scan. Supported values: Default: |
Optional |
BRIDGE_POLARIS_TEST_SCA_TYPE |
Polaris SCA test type to trigger signature scan, package manager scan or binary scan. Default: SCA-PACKAGE Supported values:
|
Optional |
BRIDGE_POLARIS_ARTIFACTTOUPLOAD |
Path to a binary or archive file to analyze. | Optional. Required when using SCA-BINARY as the SCA Test Type. |
BRIDGE_POLARIS_WAITFORSCAN |
Specifies if the workflow should wait for the analysis to complete. Default : If set to false, post scan workflows like PR comment, Fix PR, SARIF etc. will not be applicable. |
Optional |