1616 branches :
1717 - main
1818 # Do not run the DAST scan when a push touches only files that cannot affect the
19- # scanned app or the scan itself: docs, other-platform CI glue, and the manual-only
20- # sibling notification workflows. App source, specs, Dockerfile/compose, build files,
21- # scan config, and this workflow still trigger a scan . (NV-4462.)
19+ # scanned app or the scan itself: docs and other-platform CI glue. App source, specs,
20+ # Dockerfile/compose, build files, scan config, and this workflow still trigger a
21+ # scan. (NV-4462.)
2222 paths-ignore :
2323 - ' **/*.md'
2424 - ' .gitignore'
2525 - ' .gitlab-ci.yml'
26- - ' convert_sarif_to_gitlab.py'
2726 - ' azure-pipelines.yml'
2827 - ' sarif_to_azure_devops.py'
2928 - ' bitbucket-pipelines.yml'
3029 - ' Jenkinsfile'
31- - ' .github/workflows/nightvision-email.yml'
32- - ' .github/workflows/nightvision-slack.yml'
33- - ' .github/workflows/nightvision-teams.yml'
30+ - ' .github/dependabot.yml'
3431 workflow_dispatch :
3532
3633env :
3734 NIGHTVISION_TOKEN : ${{ secrets.NIGHTVISION_TOKEN }}
3835 NIGHTVISION_TARGET : javaspringvulny
3936 NIGHTVISION_AUTH : javaspringvulny
37+ # Optional: a Slack Incoming Webhook URL. When set, step (7) posts a scan
38+ # summary; when unset, that step is skipped and the scan still runs and uploads.
39+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
4040
4141jobs :
4242 test :
@@ -45,12 +45,11 @@ jobs:
4545 runs-on : ubuntu-latest
4646 steps :
4747 - name : (1) Clone Code
48- uses : actions/checkout@v3
48+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4949
5050 - name : (2) Install NightVision
5151 run : |
5252 wget -c https://downloads.nightvision.net/binaries/latest/nightvision_latest_linux_amd64.tar.gz -O - | tar -xz; sudo mv nightvision /usr/local/bin/
53- python -m pip install semgrep --user
5453
5554 # Extract the spec to a local file and assert it is non-empty. The '|| true' mask
5655 # and the backup-spec fallback are dropped so a real API Discovery regression turns
8988 nightvision export sarif -s "$(head -n 1 scan-results.txt)" --swagger-file openapi-spec.yml
9089
9190 - name : (6) Upload SARIF file to GitHub Security Alerts if vulnerabilities are found
92- uses : github/codeql-action/upload-sarif@v3
91+ uses : github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
9392 if : success()
9493 with :
9594 sarif_file : results.sarif
95+
96+ # Post a one-line scan summary to a Slack Incoming Webhook. Runs on both success
97+ # and failure (always()), skipped when SLACK_WEBHOOK_URL is not set. Best-effort:
98+ # a webhook POST failure prints a warning but does not fail the run (the scan and
99+ # SARIF upload have already succeeded). jq builds the JSON payload so the message
100+ # text is escaped safely.
101+ - name : (7) Post scan summary to Slack
102+ if : ${{ always() && env.SLACK_WEBHOOK_URL != '' }}
103+ run : |
104+ run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
105+ if [ "${{ job.status }}" = "success" ] && [ -f results.sarif ]; then
106+ total=$(jq '[.runs[].results[]] | length' results.sarif)
107+ crit=$(jq '[.runs[].results[] | select(.properties["nightvision-risk"] == "CRITICAL")] | length' results.sarif)
108+ high=$(jq '[.runs[].results[] | select(.properties["nightvision-risk"] == "HIGH")] | length' results.sarif)
109+ findings_url="${{ github.server_url }}/${{ github.repository }}/security/code-scanning"
110+ text="NightVision scan of ${NIGHTVISION_TARGET} in ${{ github.repository }} succeeded: ${total} findings (${crit} critical, ${high} high). <${findings_url}|Findings> | <${run_url}|Run>"
111+ else
112+ text="NightVision scan of ${NIGHTVISION_TARGET} in ${{ github.repository }} did not complete (status ${{ job.status }}). <${run_url}|Run>"
113+ fi
114+ curl -sSf -X POST -H 'Content-type: application/json' \
115+ --data "$(jq -n --arg t "$text" '{text: $t, unfurl_links: false, unfurl_media: false}')" \
116+ "$SLACK_WEBHOOK_URL" \
117+ || echo "::warning::Slack notification failed; continuing (scan result unaffected)."
0 commit comments