As a Bitbucket Pipe user, you can use Bridge CLI to automate Polaris scanning in your CI pipeline. You can use Bridge CLI with Polaris in the following ways:
- Automate SCA scans
- Automate SAST scans
- Add Pull Request comments to Bitbucket
- Raise Fix Pull Requests for SCA vulnerabilities
- Export SARIF files
Before running a pipe with the Black Duck Security Scan Pipe, please read the Black Duck documentation on Bitbucket prerequisites.
Client scan tools can be configured using the Bridge CLI environment variables within the Black Duck Security Scan Pipe. 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.
For an overview about using PR Comments, please see the following documentation page: Pull request (PR) comments
For an overview about Fix Pull Requests, please see the following documentation page: Fix pull requests (Fix PRs).
After completing the prerequisites, you may add the following code blocks to your bitbucket-pipelines.yml, and then run your pipe. A list of mandatory and optional parameters is provided below the code examples.
-
Simplified example:
security-scan: &blackduck-security-scan step: name: Black Duck Security Scan script: - pipe: blackduck-inc/blackduck-security-scan:1.6.0 variables: BRIDGE_POLARIS_SERVERURL: $POLARIS_SERVERURL BRIDGE_POLARIS_ACCESSTOKEN: $POLARIS_ACCESSTOKEN BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SCA,SAST' ## Mandatory when BRIDGE_POLARIS_PRCOMMENT_ENABLED, BRIDGE_POLARIS_FIXPR_ENABLED or BRIDGE_POLARIS_REPORTS_SARIF_CREATE is set true. # BRIDGE_BITBUCKET_API_TOKEN: $BITBUCKET_REPO_ACCESS_TOKEN ## Pull Request Comments # BRIDGE_POLARIS_PRCOMMENT_ENABLED: 'true' ## Fix Pull Request Creation # BRIDGE_POLARIS_FIXPR_ENABLED: 'true' ## SARIF report generation # BRIDGE_POLARIS_REPORTS_SARIF_CREATE: 'true' ## Uncomment below configuration for signature scan # BRIDGE_POLARIS_TEST_SCA_TYPE: 'SCA-SIGNATURE' ## Uncomment below configuration for sigma rapid scan # BRIDGE_POLARIS_TEST_SAST_TYPE: 'SAST_RAPID' ## Mark build status if policy violating issues are found # MARK_BUILD_STATUS: 'success' ### Use below configuration for uploading artifacts if INCLUDE_DIAGNOSTICS or BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled artifacts: - '.blackduck/integrations/polaris/sarif/report.sarif.json' # Used when BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled - '.bridge/**' # Used when INCLUDE_DIAGNOSTICS is enabled pipelines: pull-requests: '**': # Matches all pull requests - <<: *blackduck-security-scan branches: '{main,master,develop,stage,release}': - <<: *blackduck-security-scan -
Detailed example:
pipelines: pull-requests: '**': - step: # runs-on: # Use this to specify self-hosted runners # - linux # Name of your Bitbucket runner script: - pipe: blackduck-inc/blackduck-security-scan:1.6.0 variables: BRIDGE_POLARIS_SERVERURL: $BRIDGE_POLARIS_SERVERURL BRIDGE_POLARIS_ACCESSTOKEN: $BRIDGE_POLARIS_ACCESSTOKEN BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SCA,SAST' BRIDGE_POLARIS_APPLICATION_NAME: $BRIDGE_POLARIS_APPLICATION_NAME BRIDGE_POLARIS_PROJECT_NAME: $BRIDGE_POLARIS_PROJECT_NAME BRIDGE_POLARIS_BRANCH_NAME: $BRIDGE_POLARIS_BRANCH_NAME ### Enable Polaris PR scan BRIDGE_POLARIS_PRCOMMENT_ENABLED: 'true' BRIDGE_BITBUCKET_API_TOKEN: $BRIDGE_BITBUCKET_API_TOKEN ### BRIDGE_BITBUCKET_API_USER_NAME is required if App Password is set as BRIDGE_BITBUCKET_API_TOKEN # BRIDGE_BITBUCKET_API_USER_NAME: $BRIDGE_BITBUCKET_API_USER_NAME BRIDGE_POLARIS_PRCOMMENT_SEVERITIES: 'CRITICAL,HIGH' # BRIDGE_POLARIS_WAITFORSCAN: 'false' # Used to support the async mode ### Signature scan # BRIDGE_POLARIS_TEST_SCA_TYPE: 'SCA-SIGNATURE' ### Sigma rapid scan # BRIDGE_POLARIS_TEST_SAST_TYPE: 'SAST_RAPID' ### 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' ## Use custom image to configure paths and tools # CUSTOM_IMAGE: 'user/custom-blackduck-security-scan:maven' ## Use below parameters to authenticate private custom docker image # DOCKER_USERNAME: $DOCKER_USERNAME # DOCKER_PASSWORD: $DOCKER_PASSWORD # Supports Password and Personal Access Token ## Use this if the private docker image is hosted in internal docker registry # DOCKER_REGISTRY: $DOCKER_REGISTRY ## Uncomment to specify the directory to scan. Default value is repository root # BRIDGE_PROJECT_DIRECTORY: '/usr/local/my-project' # NETWORK_AIRGAP: true # BRIDGECLI_INSTALL_DIRECTORY:'/usr/local/bridge-cli-bundle' ## Coverity (SAST) Tools Settings # BRIDGE_COVERITY_CLEAN_COMMAND: 'mvn clean' # BRIDGE_COVERITY_BUILD_COMMAND: 'mvn clean install' # BRIDGE_COVERITY_CONFIG_PATH: '/usr/local/config/coverity.yml' # BRIDGE_COVERITY_ARGS: '-c /usr/local/config/coverity.yml -o capture.build.clean-command="mvn clean" -- mvn clean install' # BRIDGE_COVERITY_VERSION: '2025.9.0' ## Detect Tool Settings # BRIDGE_DETECT_SEARCH_DEPTH: 2 # BRIDGE_DETECT_ARGS: '--detect.diagnostic=true' # BRIDGE_DETECT_CONFIG_PATH: '/usr/local/config/application.properties' ### Use below configuration for uploading artifacts if INCLUDE_DIAGNOSTICS is enabled artifacts: - '.bridge/**' branches: '{main,master,develop,stage,release}': - step: # runs-on: # Use this to specify self-hosted runners # - linux # Name of your Bitbucket runner script: - pipe: blackduck-inc/blackduck-security-scan:1.6.0 variables: BRIDGE_POLARIS_SERVERURL: $BRIDGE_POLARIS_SERVERURL BRIDGE_POLARIS_ACCESSTOKEN: $BRIDGE_POLARIS_ACCESSTOKEN BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SCA,SAST' BRIDGE_POLARIS_APPLICATION_NAME: $BRIDGE_POLARIS_APPLICATION_NAME BRIDGE_POLARIS_PROJECT_NAME: $BRIDGE_POLARIS_PROJECT_NAME BRIDGE_POLARIS_BRANCH_NAME: $BRIDGE_POLARIS_BRANCH_NAME ### Fix PR - generates automated fixable PRs BRIDGE_POLARIS_FIXPR_ENABLED: 'true' BRIDGE_POLARIS_FIXPR_MAXCOUNT: '5' BRIDGE_POLARIS_FIXPR_USEUPGRADEGUIDANCE: 'SHORT_TERM,LONG_TERM' BRIDGE_POLARIS_FIXPR_FILTER_SEVERITIES: 'CRITICAL,HIGH' ### Upload Polaris SARIF report as job artifact BRIDGE_POLARIS_REPORTS_SARIF_CREATE: 'true' BRIDGE_POLARIS_REPORTS_SARIF_FILE_PATH: '/usr/local/report/report.sarif.json' BRIDGE_POLARIS_REPORTS_SARIF_ISSUE_TYPES: 'SCA,SAST' BRIDGE_POLARIS_REPORTS_SARIF_SEVERITIES: 'CRITICAL,HIGH' BRIDGE_POLARIS_REPORTS_SARIF_GROUPSCAISSUES: 'true' # BRIDGE_POLARIS_WAITFORSCAN: 'false' # Used to support the async mode ### Signature scan # BRIDGE_POLARIS_TEST_SCA_TYPE: 'SCA-SIGNATURE' ### Sigma full scan # BRIDGE_POLARIS_TEST_SAST_TYPE: 'SAST_FULL' ### 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' ### BRIDGE_BITBUCKET_API_TOKEN is required to upload SARIF report and diagnostics in the Bitbucket downloads section, otherwise configure SARIF and diagnostics as artifacts in the bitbucket-pipelines.yml # BRIDGE_BITBUCKET_API_TOKEN: $BRIDGE_BITBUCKET_API_TOKEN ### BRIDGE_BITBUCKET_API_USER_NAME is required if App Password is set as BRIDGE_BITBUCKET_API_TOKEN # BRIDGE_BITBUCKET_API_USER_NAME: $BRIDGE_BITBUCKET_API_USER_NAME ### Mark build status if policy violating issues are found # MARK_BUILD_STATUS: 'success' ## Use custom image to configure paths and tools # CUSTOM_IMAGE: 'user/custom-blackduck-security-scan:maven' ## Use below parameters to authenticate private custom docker image # DOCKER_USERNAME: $DOCKER_USERNAME # DOCKER_PASSWORD: $DOCKER_PASSWORD # Supports Password and Personal Access Token ## Use this if the private docker image is hosted in internal docker registry # DOCKER_REGISTRY: $DOCKER_REGISTRY ## Uncomment to specify the directory to scan. Default value is repository root # BRIDGE_PROJECT_DIRECTORY: '/usr/local/my-project' # NETWORK_AIRGAP: true # BRIDGECLI_INSTALL_DIRECTORY:'/usr/local/bridge-cli-bundle' ## Polaris SCA Binary Scan # BRIDGE_POLARIS_TEST_SCA_TYPE: 'SCA-BINARY' # BRIDGE_POLARIS_ARTIFACTTOUPLOAD: '/path/to/artifact.zip' ## Coverity (SAST) Tools Settings # BRIDGE_COVERITY_CLEAN_COMMAND: 'mvn clean' # BRIDGE_COVERITY_BUILD_COMMAND: 'mvn clean install' # BRIDGE_COVERITY_CONFIG_PATH: '/usr/local/config/coverity.yml' # BRIDGE_COVERITY_ARGS: '-c /usr/local/config/coverity.yml -o capture.build.clean-command="mvn clean" -- mvn clean install' # BRIDGE_COVERITY_VERSION: '2025.9.0' ## Detect Tool Settings # BRIDGE_DETECT_SEARCH_DEPTH: 2 # BRIDGE_DETECT_ARGS: '--detect.diagnostic=true' # BRIDGE_DETECT_CONFIG_PATH: '/usr/local/config/application.properties' ### Use below configuration for uploading artifacts if INCLUDE_DIAGNOSTICS or BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled artifacts: - '/usr/local/report/report.sarif.json' # Used when BRIDGE_POLARIS_REPORTS_SARIF_CREATE is enabled - '.bridge/**' # Used when INCLUDE_DIAGNOSTICS is enabled
List of mandatory and optional parameters for Polaris
| 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 Polaris. The Default Value is $BITBUCKET_REPO_SLUG |
Optional |
BRIDGE_POLARIS_SERVERURL |
Polaris server URL | Mandatory |
BRIDGE_BITBUCKET_API_TOKEN |
Bitbucket User Access Token. Example: BRIDGE_BITBUCKET_API_TOKEN: $BRIDGE_BITBUCKET_API_TOKEN |
Mandatory when BRIDGE_POLARIS_PRCOMMENT_ENABLED is set as true. |
BRIDGE_BITBUCKET_API_USER_NAME |
Specify your Bitbucket User Name to use features like PR Comments, SARIF upload and diagnostics upload. This works in conjunction with your Bitbucket API token. | Mandatory when BRIDGE_POLARIS_PRCOMMENT_ENABLED is set as true. |
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_POLARIS_REPORTS_SARIF_CREATE |
Set this to true to generate SARIF report. Default: falseNote: 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. Only Default: |
Optional |
BRIDGE_POLARIS_REPORTS_SARIF_ISSUE_TYPES |
Lists which assessment issues types to include in SARIF file report. Example: 'SCA,SAST' |
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_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 :false. |
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 :5. |
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: :SHORT_TERM,LONG_TERM. |
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: CRITICAL,HIGH |
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 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_SOURCE_EXCLUDES |
A list of git ignore pattern strings that indicate the files need to be excluded from the zip file. | Optional |
BRIDGE_PROJECT_SOURCE_ARCHIVE |
The zipped source file path. It overrides the project directory. | 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:
Note:
SCA-BINARY can only be used stand-alone. It cannot be combined with SCA-PACKAGE or SCA-SIGNATURE. |
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_TEST_SAST_TYPE |
Polaris test type to trigger sigma rapid scan or full scan. Supported values: Default: |
Optional |
BRIDGE_POLARIS_WAITFORSCAN |
Specifies whether or not the workflow should wait for the analysis to complete. Default: If set to |
Optional |