This quickstart explains how to set up the Black Duck Security Scan Pipe for Bitbucket to run a pipeline that integrates with Black Duck® SCA to run a full scan and Pull Request scan. Fix Pull Requests are automatically raised for detected dependency vulnerabilities. Pull Request review comments are only created for new issues that are detected on the feature branch but not the target branch.
The full scan will be triggered by push and merge events on specified branches. Fix Pull Requests will automatically be raised for dependency vulnerabilities detected. Conversely, the Pull Request scan will be triggered by push events to Pull Requests that target those branches. Any new security issues introduced by a Pull Request will be added as review comments on the Pull Request. After the scan completes, appropriate security reports and diagnostic logs will be exported as build artifacts.
Prerequisites
The following reading is recommended before starting this quickstart:
- Access to a Black Duck SCA server configured with:
- A Black Duck SCA role that allows creation of authentication tokens.
- A Black Duck SCA API token with Read and Write access. This can be created by navigating to from within Black Duck SCA.
- A Bitbucket Access Token is required to allow the pipeline to inject Pull Request review comments, raise fix Pull Requests for dependency vulnerablities and upload SARIF reports.
- For security reasons, it is advisable not to store credentials and access tokens directly in the pipeline. The recommended approach is to use Bitbucket variables with the
securedoption checked. - The following Black Duck Security Scan Pipe parameters are required to enable Pull Request comments, raise Fix Pull Requests and upload SARIF reports. These have been included in the quickstart example:Important: Pull Request comments, fix Pull Requests and SARIF reports will not function correctly if these parameters and the required prerequisites are not correctly configured.
Parameter Description Example BRIDGE_BLACKDUCKSCA_AUTOMATION_PRCOMMENTWhen true, this enables Pull Request comments."true"BRIDGE_BLACKDUCKSCA_FIXPR_ENABLEDWhen truea full scan will automatically raise fix Pull Requests for detected dependency vulnerabilities."true"BRIDGE_BLACKDUCKSCA_REPORTS_SARIF_CREATEWhen true this exports SARIF reports for full scans. "true"BRIDGE_BLACKDUCKSCA_URLURL for Black Duck® SCA server instance. $BLACKDUCKSCA_URLBRIDGE_BLACKDUCKSCA_TOKENBlack Duck® SCA Access Token to enable integration with Black Duck® SCA server. $BRIDGE_BLACKDUCKSCA_TOKENBRIDGE_BITBUCKET_API_TOKENA Bitbucket Access Token. Required for Pull Request comments, fix Pull Requests and uploading SARIF reports. $BITBUCKET_REPO_ACCESS_TOKEN - Add the following variables and secured variables at the repository level () or workspace level ():
Variable Type Description Example BLACKDUCKSCA_URLVariable Black Duck® SCA Server URL https://sca.blackduck.comBRIDGE_BLACKDUCKSCA_TOKENSecured Variable Black Duck® SCA Access Token REPLACE_WITH_YOUR_TOKENBITBUCKET_REPO_ACCESS_TOKENSecured Variable A Bitbucket Access Token. Required for Pull Request comments, fix Pull Requests and uploading SARIF reports. REPLACE_WITH_BITBUCKET_ACCESS_TOKENNote: The Black Duck Security Scan Pipe integrates with Black Duck® SCA via Bridge CLI. Additional scan configuration options not available through the template's parameter set can be specified by defining relevant Bridge CLI environment variables within the workflow job.
Instructions
Troubleshooting and support
INFO: --- ======== Detect Issues ========
INFO: ---
INFO: --- DETECTORS:
INFO: --- Detector Issue
INFO: --- Accuracy Not Met: MAVEN
INFO: --- Extraction for Maven Project Inspector has accuracy of LOW but HIGH is required by the current detect.accuracy.required configuration.
INFO: ---
INFO: --- ======== Detect Result ========- Create and use a custom image that extends the Black Duck® SCA pipe. The custom image should have the required build tools installed, e.g. Maven. An example for using a custom image for a pipe is:
pipe: docker://your-registry/your-custom-image:tag. - Use the
BRIDGE_DETECT_ARGSparameter to set project accuracy toNONE, i.e.BRIDGE_DETECT_ARGS: --detect.accuracy.required=NONE. - Set scan failure severities to
BLOCKER, i.e.BRIDGE_BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES: BLOCKER.