Use this action to analyze the source code for security vulnerabilities and quality defects using the Perforce Klocwork Static Application Security Testing (SAST) scanner. The action output can be used as a quality gate in subsequent GitHub Actions steps or jobs.
This action is available on the GitHub marketplace.
For background on how the scanner works and the difference between explicit and implicit scans, refer to Understanding Perforce Klocwork scanning.
Prerequisites
Set up CloudBees Unify and GHA to work together, providing key features of CloudBees Unify to GHA workflows. For more information, refer to Set up GitHub Actions integration.
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The Klocwork server URL. |
|
String |
Yes |
Klocwork username. |
|
String |
No |
Klocwork password. |
|
String |
No |
Klocwork application token. |
|
String |
Yes |
Klocwork build tool [make / cmake / python/ maven / dotnet]. |
|
String |
No |
Klocwork build directory [default is root folder /]. |
|
String |
Yes |
Specify the ref to be checked out and scanned. |
|
String |
No |
Klocwork build name. |
|
String |
No |
Klocwork scan build options [e.g., make <target-name> -j4]. |
|
String |
No |
Klocwork build specification file path [e.g., /tmp/kwinject.out]. |
|
Boolean |
No |
Enable Klocwork Agent Scan [default is full scan]. |
|
String |
No |
Klocwork license server hostname [default is server hostname]. |
|
String |
No |
Klocwork license server port [default is 27000]. |
|
String |
No |
Klocwork project name. |
|
String |
No |
Klocwork scan waiting time in seconds [e.g., 3600]. |
|
String |
No |
Klocwork scan tables directory [e.g., /tmp/tables]. |
|
Boolean |
No |
Enable Klocwork Local Scan [performs analysis locally on the agent only and does not push results to the Klocwork Server]. |
|
String |
No |
Klocwork |
|
String |
No |
Klocwork |
|
String |
No |
The file path of the code to be scanned. |
For C/C++/.NET projects, since kwinject is used for building the specification file, the build-options parameter is mandatory. You must pass the appropriate build command with options. For example, if make is the build tool, the build-options should be specified like make targetName -j14 or similar build commands specific to your project configuration.
|
Outputs
| Output name | Data type | Description |
|---|---|---|
|
String |
The number of Critical severity issues discovered during the scan. |
|
String |
The number of High severity issues discovered during the scan. |
|
String |
The number of Medium severity issues discovered during the scan. |
|
String |
The number of Low severity issues discovered during the scan. |
|
String |
The total number of issues discovered during the scan. |
This action uses GitHub OIDC authentication to securely communicate with CloudBees Unify.
Be sure to set permissions to id-token: write in your workflow.
|
Usage examples
The following is a basic example of using this action:
In the following example, the Klocwork
command reference provides detailed guidance on specifying build-options according to the build-tool used.
For example, if the build-tool is make, the build-options must include the build command and relevant flags,
such as make targetName -j14, to ensure that kwinject can correctly generate the build specification file.
permissions: id-token: write contents: read steps: - name: Scan with Perforce Klocwork SAST scanner uses: cloudbees-io-gha/perforce-klocwork-sast-publish@v1 with: url: ${{ vars.KLOCWORK_URL }} token: ${{ secrets.KLOCWORK_APP_TOKEN }} license-host: ${{ vars.KLOCWORK_LICENSE }} username: ${{ vars.KLOCWORK_USERNAME }} project-name: test-c-project build-directory: / build-tool: make build-options: make clean <target-name> --ignore-errors enable-agent-scan: false enable-local-scan: false
Using the action output
Use the output values from this action in downstream steps and jobs. The following example uses the action output in a downstream step of the same job:
The following example uses the action output in a downstream job:
Full workflow and run example
The following GHA workflow example scans a repository with Perforce Klocwork SAST scanner.
Example GHA workflow YAML file
After the GHA run has completed, the security findings are collected and displayed in the Security center and the Security overview for the component containing the workflow.
When the respective artifact is deployed to an application environment, Klocwork findings are also displayed in the Security center and the Security overview for the application.