In today's software development landscape, integrating security scans into your continuous integration and delivery (CI/CD) pipelines is a best practice. An automated process quickly identifies vulnerabilities and ensures that your software is secure. One essential tool for achieving this level of security is Black Duck. This tool performs comprehensive scans of your codebase and its open-source dependencies, helping to identify potential security vulnerabilities, license compliance issues, and code quality problems.
In this blog, I'll walk you through the process of integrating Black Duck scans into your SAP Continuous Integration and Delivery jobs. By creating a custom command for Black Duck scans, you can actively detect and address risks before they compromise your software, ensuring a more secure and reliable product. Let's dive into the steps required to achieve this integration and enhance your CI/CD pipeline with robust security measures.
We'll use a bash script to run a Black Duck scan. This script installs the necessary Java Runtime Environment (JRE), downloads the Black Duck Detect tool, and then executes the scan.
Here’s the script we'll use:
#!/bin/bash set -eu # Runs Black Duck scan in current directory after downloading Java # and Synopsys Detect script. JRE_VERSION="21.0.5" JRE_TAR="sapmachine-jre-${JRE_VERSION}_linux-x64_bin.tar.gz" JRE_URL="https://github.com/SAP/SapMachine/releases/download/sapmachine-$JRE_VERSION/$JRE_TAR" DETECT_URL="https://detect.synopsys.com/detect10.sh" install_jre() { echo "Downloading and installing sapmachine from $JRE_URL" wget --quiet $JRE_URL -O - | tar -xzf - export JAVA_HOME=$(pwd)/sapmachine-jre-${JRE_VERSION} $JAVA_HOME/bin/java -version echo "Java installation complete." } download_detect_tool() { echo "Downloading Black Duck Detect tool from $DETECT_URL" wget --quiet $DETECT_URL -O detect.sh chmod +x detect.sh echo "Black Duck Detect tool download complete." } run_blackduck_scan() { echo "Running Black Duck scan..." ./detect.sh --blackduck.url="$BD_SERVER" --blackduck.api.token="$BD_API_TOKEN" --detect.project.name="$BD_PROJECT_NAME" --detect.project.version.name="$BD_PROJECT_VERSION" echo "Black Duck scan completed." } # Main script execution install_jre download_detect_tool run_blackduck_scan
Add your script to the repository containing your project source code.
In SAP Continuous Integration and Delivery, either create a new job or navigate to the job to which you want to add additional commands and choose Edit.
In the Compliance stage section of your job, choose + next to Additional Commands. This allows you to introduce a custom script.
Choose either Run First in Stage or Run Last in Stage to execute the scan in relation to other tasks.
In the Command text field. enter the following command to execute your script:
bash path/to/your/blackduck_script.sh
Replace path/to/your/blackduck_script.sh with the actual path to your script in the repository.
Confirm your changes.
The script uses a couple of variables provided in the environment, so you don't need to adjust the script for your jobs. Instead, we will set these variables using the Additional Variables feature.
In the Compliance stage section of your job, choose + next to Additional Variables. This opens the Add Variables pop-up.
Add the following variables one after the other:
These variables will be used as parameters for the detect.sh script.
In the Compliance stage section of your job, choose + next to Additional Credentials and add the following credential to access your Black Duck server:
BD_API_TOKEN: Your Black Duck API token.
Once the setup is complete, trigger your pipeline either manually or by committing new code to your repository. Monitor the pipeline to ensure the Black Duck scan executes properly and review the logs for any errors or output from the scan.
With these steps, you've successfully integrated Black Duck scans into your SAP Continuous Integration and Delivery pipeline. You've empowered your development process with a robust security mechanism that proactively identifies vulnerabilities and maintains code quality. By automating these scans, you can focus on delivering secure, reliable software faster. Stay ahead of potential threats and ensure your software meets the highest security standards with this seamless integration. Happy secure coding!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 38 | |
| 33 | |
| 30 | |
| 28 | |
| 27 | |
| 24 | |
| 24 | |
| 23 |