Skip to content

ROX-23362: conditionally build Scanner V4 with -race #2762

ROX-23362: conditionally build Scanner V4 with -race

ROX-23362: conditionally build Scanner V4 with -race #2762

name: Scanner dev vulnerability update
on:
schedule:
- cron: "30 */4 * * *"
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
build-updater:
runs-on: ubuntu-latest
if: >
github.event_name == 'schedule' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'pr-update-scanner-vulns'))
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.3.69
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
- uses: ./.github/actions/cache-go-dependencies
- name: Build updater
run: |
make tag
make -C scanner bin/updater
- uses: actions/upload-artifact@v4
with:
name: updater
path: scanner/bin/updater
if-no-files-found: error
run-updater:
needs:
- build-updater
runs-on: ubuntu-latest
env:
STACKROX_NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
STACKROX_NVD_API_CALL_INTERVAL: 6s
steps:
- uses: actions/download-artifact@v4
with:
name: updater
path: /usr/local/bin
- name: Set updater
run: |
chmod +x /usr/local/bin/updater
mkdir vulns
- name: Run updater (single bundle)
run: |
updater export vulns
- name: Run updater (multi bundle)
run: |
updater export --split bundles
zip vulns/vulnerabilities.zip bundles/*.json.zst
- uses: actions/upload-artifact@v4
with:
name: vulns
path: vulns
if-no-files-found: error
upload-vulnerabilities:
runs-on: ubuntu-latest
needs:
- run-updater
steps:
- uses: actions/download-artifact@v4
with:
name: vulns
path: vulns
- name: Authenticate with Google Cloud
if: github.event_name == 'schedule'
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_SA_STACKROX_HUB_VULN_DUMP_UPLOADER }}
- name: Authenticate with Google Cloud
if: github.event_name == 'pull_request'
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_SA_CIRCLECI_SCANNER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Update dev vulnerabilities
if: github.event_name == 'schedule'
run: |
cd vulns
# Upload development tags for upstream (dev) and downstream (1.0.0).
gsutil -m cp -r . gs://definitions.stackrox.io/v4/vulnerability-bundles/dev/
gsutil -m cp -r . gs://definitions.stackrox.io/v4/vulnerability-bundles/1.0.0/
- name: Update PR vulnerabilities
if: github.event_name == 'pull_request'
run: |
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# Replace / with -, so the branch name isn't truncated when pushed to GCS.
dir=${branch////-}
case $dir in
dev|1.0.0)
echo "Branch $dir is disallowed"
exit 1
esac
cd vulns
gsutil cp -r . "gs://scanner-v4-test/vulnerability-bundles/$dir"
send-notification:
needs:
- upload-vulnerabilities
runs-on: ubuntu-latest
if: failure()
steps:
- name: Send Slack notification on workflow failure
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"<${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|Workflow ${{ github.workflow }}> failed in repository ${{ github.repository }}: Failed to update vulnerabilities"}' ${{ secrets.SLACK_ONCALL_SCANNER_WEBHOOK }}