Explains how to set up the Black Duck Security Scan Action to run a workflow that integrates with Black Duck® SCA to run a full scan and Pull Request scan. Pull request review comments are created only for new issues detected in the feature branch but not in the target branch.
The full scan will be triggered by push and merge events on specified branches. GitHub issues will be created from scan findings. 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:
- Admin access to a GitHub 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 GitHub token is required to allow the Black Duck Security Scan Action to inject Pull Request comments and create GitHub issues from scan findings.
- For security reasons, it is advisable not to store credentials directly in the workflow. The recommended approach is to use secrets.
- The following environment variables must be defined in the
env:section of your GitHub Actions workflow to enable Pull Request scanning and automated review comment injection.Important: If these variables and the prerequisites are not properly configured, the workflow will not inject comments into Pull Requests.Environment Variable Description Example DETECT_PROJECT_NAMEBlack Duck® SCA project name. ${{ github.event.repository.name }}DETECT_PROJECT_VERSION_NAMESet to target branch of Pull Request to allow differential comparison. ${{ github.event_name != 'pull_request' && github.ref_name || github.event.pull_request.base.ref }} - The following parameters have been included in the quickstart example and are required to inject review comments and create GitHub issues:Important: If these parameters and the prerequisites are not configured, the workflow will not inject comments into Pull Requests and GitHub Issues will not be created.
Parameter Description Example blackducksca_prcomment_enabledWhen true, enables PR comments.trueblackducksca_externalIssues_createWhen true, this enables creation of GitHub issues from scan findings.truegithub_tokenA GitHub Personal Access Token with workflow read and write permissions. Required to inject review comments. ${{ secrets.GITHUB_TOKEN }}if using the built inGITHUB_TOKENor${{ secrets.MY_PAT_TOKEN }}to reference a custom token.Note: Black Duck Security Scan Action integrates with Black Duck® SCA via Bridge CLI. Additional scan configuration options not available through the action's parameter set can be specified by defining relevant Bridge CLI environment variables within the workflow job. - Add the following secrets and variables ():
Variable Type Description Example BLACKDUCK_URLVariable Black Duck® SCA Server URL https://sca.blackduck.comBLACKDUCK_TOKENSecret Black Duck® SCA Access Token REPLACE_WITH_YOUR_TOKEN
Instructions
Follow the steps below to configure the Black Duck Security Scan Action to run a full scan and Pull Request scan.
Next steps
Bridge initiates a Black Duck Detect scan that targets a repository. Detect properties can be passed using the
detect_args parameter to further configure the scan. The code below is an example of further configuration; however, it is not necessary to include in this scan.detect_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.