This quickstart explains how to set up the Black Duck Security Scan Template to run a pipeline that integrates with Black Duck® SCA to run a full scan and Merge Request scan. Merge Request review comments are only created for new issues created 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. Conversely, the Merge Request scan will be triggered by push events to Merge Requests that target those branches. Any new security issues introduced by a Merge Request will be added as review comments on the Merge 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:
- Admin access to a GitLab repository.
- 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 GitLab Personal Access Token with at least
Developerprivileges andapiaccess is required to allow the pipeline to inject review comments into GitLab Merge Requests. - For security reasons, it is advisable not to store credentials directly in the workflow. The recommended approach is to use masked and hidden variables. Important: It is adviseable to use project variables. Group variable inheritance can cause scans to fail under certain conditions. Be sure to set the mask variable flag for
BLACKDUCKSCA_API_TOKENandGITLAB_USER_TOKENto avoid exposure in the CI logs. - The following parameters are required to enable inject review comments into Pull Requests and have been included in the quickstart example: Important: Merge Request comments will not be injected if these parameters and the required prerequisites are not configured.
Parameter Description Example DETECT_PROJECT_NAMEBlack Duck® SCA project name. $CI_PROJECT_NAMEDETECT_PROJECT_VERSION_NAMESet to Merge Request target branch for differential comparison. $CI_MERGE_REQUEST_TARGET_BRANCH_NAMEBRIDGE_BLACKDUCKSCA_AUTOMATION_PRCOMMENTWhen true, enables PR comments."true"BRIDGE_GITLAB_USER_TOKENGitLab Personal Access Token with at least Developerprivileges andapiaccess for injecting review comments.$GITLAB_USER_TOKENNote: The Black Duck Security Scan Template 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 pipeline job.- The following variables are required ():
Variable Type Description Example BLACKDUCKSCA_URLMasked Black Duck Server URL https://sca.blackduck.com BLACKDUCKSCA_API_TOKENMasked and hidden Black Duck API Token REPLACE_WITH_YOUR_TOKENGITLAB_USER_TOKENMasked and hidden GitLab Personal Access Token with at least Developerprivileges andapiaccesss for injecting review comments.REPLACE_WITH_YOUR_TOKEN
- The following variables are required ():
Instructions
Follow the steps below to configure the Black Duck Security Scan Template to run a full scan and Merge Request scan.
Next steps
Bridge initiates a Black Duck Detect scan that targets a repository. Detect properties can be passed using the
BRIDGE_BLACKDUCK_ARGS variable to further configure the scan. The code below is an example of further configuration; however, it is not necessary to include in this scan. BRIDGE_BLACKDUCK_ARGS: --detect.project.name=your_project_name, --detect.project.version.name=v1.7A complete list of Bridge variables for Black Duck® SCA is available at Bridge SCA Variables.Troubleshooting and support
If a pipeline error is encountered similar to the example below, then it is likely that organization firewall rules maybe restricting access to the template.
Attention: Unable to create pipeline Project `blackduck-inc/black-duck-security-scan` not found or access denied! Make sure any includes in the pipeline configuration are correctly defined.
The recommended solution is to check that the template is referenced correctly and then perform one of the following actions:
- Arrange access with IT administration of the organization.
- Use a GitLab self managed runner.