HashiCorp Cloud Platform
scan ci
The scan ci
command is used to enable scanning content in a continuous integration workflow.
Usage
Usage: vault-radar scan ci [subcommand]
Command Options
pr
: Scans a git repository branch/pr for a CI/CD workflowtip
: Scans the tip of a git repository branch for a CI/CD workflow
Example Vault Radar CI configurations
Your HCP_PROJECT_ID
, HCP_CLIENT_ID
, and HCP_CLIENT_SECRET
from your project are needed to use the vault-radar scan ci
commands. These values will need to be available to the workflow runner as environment variables.
The following sample GitHub workflow yaml is an example of using the vault-radar scan ci
commands in a configuration that will scan for risks when commits or PRs are created within a repository.
Note: When using the tip
scan, it's important to add the with
section to the checkout step, and a variable fetch-depth
set to 0
so the cloned repository has the entire history. Without this, the results can be inaccurate.
jobs:
vault-radar:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Vault Radar
env:
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}
run: |
set -x
export LATEST_VERSION=$(curl https://api.releases.hashicorp.com/v1/releases/vault-radar/latest | jq -r .version)
curl https://releases.hashicorp.com/vault-radar/${LATEST_VERSION}/vault-radar_${LATEST_VERSION}_linux_amd64.zip -o vr.zip # download latest binary# This can be replaced with other package managers or to other release versions. See: https://releases.hashicorp.com/vault-radar
unzip vr.zip -d vr
mv vr/vault-radar .
chmod +x vault-radar
if [[ "${{ github.event_name }}" == "pull_request" ]];
then
head_ref="${{ github.event.pull_request.head.sha }}"
base_ref="${{ github.event.pull_request.base.sha }}"
ref_name="${{ github.head_ref }}"
./vault-radar scan ci pr \
--head-ref ${head_ref} \
--base-ref ${base_ref} \
--ref-name ${ref_name} \
-s high \
-o vault-radar.jsonl \
-l vault-radar.log \
--skip-ignored \
--pretty=gha_pr
else
./vault-radar scan ci tip -s high -o vault-radar.jsonl -l vault-radar.log --pretty=gha
fi