Run STO scans using GitHub Action and Drone Plugin steps
Pipeline examples that use GitHub Actions and Drone plugins.
GitHub Actions is a GitHub feature that enables you to automate various event-driven activities, such as security scanning, in GitHub. This topic describes how to run GitHub Action scans and ingest the results into your Harness pipelines.
Important notes for using GitHub Action and Drone Plugin steps in STO
You can run GitHub Action security scans in both STO-only pipelines and integrated CI/STO pipelines.
You can run scans using GitHub Action steps and Plugin steps.
The type of step to use depends on your build infrastructure. For Harness Cloud infrastructures, use Action steps. For Kubernetes infrastructures, you can use Action or Plugin steps.
Harness recommends that you output your scan results to a data file in SARIF format. You can then use a Custom Ingestion step to ingest the results into your pipeline.
For a description of the end-to-end workflow, go to Ingest SARIF scan results.
As described below, you need to translate settings from the GitHub Action YAML to the Harness pipeline YAML. It is good practice to configure these settings in the YAML editor.
Example workflows for using GitHub Action and Drone Plugin steps in STO
Open the CI or STO pipeline where you want to run the action, then go to the Build or Security stage where you want to run the action.
Click Add Step and then add a GitHub Action plugin step.
Use Settings to specify the Github Action you want to use and to pass variables and attributes required by the Action.
For information about the settings to set, go to the external scanner documentation.
For a complete description of how to set up a GitHub Action step, go to Use the GitHub Action step.
KeyDescriptionValue formatValue exampleusesSpecify the Action's repo, along with a branch or tag.
[repo]@[tag]ajinabraham/njsscan-action@masterwithProvide a map of key-value pairs representing settings required by the action itself. At a minimum, make sure you configure the action to publish results in SARIF format.
key: valueargs: . --sarif --output result.sarif || trueenvSpecify a map of environment variables to pass to the Action. For example, you might need to pass an access token to scan a private repository.
key: valueGITHUB_TOKEN: <+secrets.getValue("github_pat")>Add a Custom Ingest step and set it up to ingest the data file.
Example setup
This example uses the njsscan action to scan a container. As noted in the Github Code Scanning SARIF upload snippet, you can configure the args value to output the scan results to a SARIF file:
Given this, you would set up the Action step in your Harness pipeline like this. You can then set up a CustomIngest step to ingest the trivy-results.sarif file that gets generated.
Open the CI or STO pipeline where you want to run the action, then go to the Build or Security stage where you want to run the action.
Click Add Step and then add a Plugin step.
For Container Registry, select a container registry connector that has Docker Hub access.
In the Image field, enter the name of the GitHub Actions Drone Plugin image:
plugins/github-actions.Use Settings to specify the Github Action you want to use and to pass variables and attributes required by the Action.
For information about how to set up the specific action, go to the external scanner documentation.
For a complete description of how to set up a GitHub Action Plugin step, go to Use the GitHub Actions Drone plugin.
KeyDescriptionValue formatValue exampleusesSpecify the Action's repo, along with a branch or tag.
[repo]@[tag]ajinabraham/njsscan-action@masterwithProvide a map of key-value pairs representing settings required by the GitHub Action itself. This example configures the Action to output a data file in SARIF format.
key: valueargs: . --sarif --output result.sarif || trueenvSpecify a map of environment variables to pass to the Action. For example, you might need to pass an access token to scan a private repository.
key: valueGITHUB_TOKEN: <+secrets.getValue("github_pat")>Add a Custom Ingest step and set it up to ingest the data file.
Example setup
This example uses the njsscan action to scan a container. As noted in the Github Code Scanning SARIF upload snippet, you can configure the args value to output the scan results to a SARIF file:
Given this, you would set up the Action step in your Harness pipeline like this. You can then set up a CustomIngest step to ingest the trivy-results.sarif file that gets generated.
Last updated
Was this helpful?
