Configuring scan automation with Jenkins and containers
The HCL® AppScan® Source command line interface (CLI) container, available from HCL Harbor and My HCLSoftware portal (MHS), can be used to automate static analysis scans with Jenkins, and without installing a full instance of AppScan® Source.
Prerequisites
- Jenkins environment, including one more Linux agents/hosts with Podman
installed.
This is the system that is targeted to run a static analysis scan using the CLI container.
-
A valid license for AppScan® Source for Automation and relevant license server information.
-
AppScan® Source CLI container image
Download the AppScan® Source CLI container image from HCL Harbor or My HCLSoftware portal. With a valid license, your HCL ID grants access to these locations.
-
AppScan® Source CLI script
A script is required for scanning with the container in a Jenkins pipeline.
-
Access to content on the Jenkins host / agent from the container:
The application to be scanned must be accessible from the Jenkins host running the scan.
Note: Volume mapping (mapping path on the container host to a path in the container) is used for this purpose during instantiation of a scan.
Prepare the application to be scanned
paf/ppffiles- folder scanning
paf/ppf files- Generate the
paf/ppffile using the HCL® AppScan® Source for Analysis client on a Linux system that has AppScan® Source installed.Ensure that the
pafandppffiles are located at the root of the application to be scanned. - Ensure that the application files and the
paf/ppffiles are accessible from the Jenkins host/agent.For example, if the application is accessible at root path
/usr/user1/SampleAppon the Jenkins host/agent, thepaf/ppffiles are located at/usr/user1/SampleApp/SampleApp.pafand/usr/user1/SampleApp/SampleApp.ppf. - Determine the name of the volume as seen by the container. For example, map
/usr/user1on the host tocvolin the container.Note: The volume mapping is specified when running the CLI in the container. - Create the CLI script. For example,
SampleApp.scriptin /usr/user1/SampleApp.For this example, the script tells the container to access the application content using thecvolpath. The commands listed are those used with the AppScan® Source CLI (Scanning without manual intervention).login … oa /cvol/SampleApp/SampleAll.ppf scan … logout
- Ensure that the application files are accessible from the Jenkins
host/agent.
For example, the application is accessible at path /
usr/user1/SampleAppon the Jenkins host/agent. - Determine the name of the volume as seen by the container.For example, map
/usr/user1on the host tocvolin the container.Note: The volume mapping is specified when running the CLI in the container. - Create the CLI script. For example,
SampleApp.scriptin/usr/user1/SampleApp.login … of /cvol/SampleApp/SampleAll scan … logout
Prepare the runtime environment on the Jenkins host/agent
- Download the AppScan®
Source CLI
container to the Jenkins host from My HCLSoftware portal or access directly from
HCL Harbor.
Load the CLI container image using the
podman loadcommand if downloaded from MHS. - Create a file (for example,
env.list) containing a list of environment variables that must be made available to the CLI container during a scan. Some of the required information includes:
A complete list of parameters can be found here.AS_INSTALL_MODE=standalone AS_LICENSE_URL=<license server url>
Initiate a static analysis scan using the container image
- using a container image from HCL Harbor
- using the container image from My HCLSoftware portal
Initiate a scan using container image from HCL Harbor
- LinuxIncorporate the following shell command into a Jenkins pipeline to scan the SampleApp. Note that
/usr/user1on the Jenkins host/agent is mapped tocvolin the container. Adjust the version string based on the desired version of the CLI container.sh "podman run --rm --volume /usr/user1:/cvol --env-file /cvol/SampleApp/ env.list hclcr.io/appscan/appscan-src-cli:10.10.0 script /cvol/SampleApp/SampleApp.script - Podman Jenkins pluginIncorporate the following Podman Jenkins plugin API into a Jenkins pipeline to scan the SampleApp. Note that
/usr/user1on the Jenkins host/agent is mapped tocvolin the container. Adjust the version string based on the desired version of the CLI container.podman.image('hclcr.io/appscan/appscan-src-cli:10.10.0').run('--name container-SampleApp --rm –-volume /usr/user1:/cvol --env-file /cvol/SampleApp/env.list script /cvol/SampleApp/SampleApp.script') sh "podman logs --follow container-SampleApp"
Initiate a scan using the container image from My HCLSoftware portal
tar.gz). The container image must be loaded prior to use to
scan.- Download the container image to the Jenkins host/agent. For example,
/appscansrc/appscan-src-cli-10.10.0.tar.gz.The container image must be loaded prior to use.
- Run the scan using a Linux shell command or the Podman Linux plugin:
- LinuxIncorporate the following shell command into a Jenkins pipeline to scan the SampleApp. Note that
/usr/user1on the Jenkins host/agent is mapped tocvolin the container. Adjust the version string based on the desired version of the CLI container.podman load -i /appscansrc/appscan-src-cli-10.10.0.tar.gz sh "podman run --rm --env-file /cvol/SampleApp/env.list --volume /usr/user1:/cvol appscansrc/appscan-src-cli:10.10.0 script /cvol/SampleApp/cli.script" - Podman Jenkins pluginIncorporate the following Podman Jenkins plugin API into a Jenkins pipeline to scan the SampleApp. Note that
/usr/user1on the Jenkins host/agent is mapped tocvolin the container. Adjust the version string based on the desired version of the CLI container.podman.image(‘appscan-src-cli:10.10.0').run('--name container-SampleApp --rm –-volume /usr/user1:/cvol --env-file /cvol/SampleApp/env.list script /cvol/SampleApp/SampleApp.script') sh "podman logs --follow container-SampleApp"
- Linux