security-scan #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: security-scan | |
on: | |
schedule: | |
- cron: "45 8 * * 1" | |
workflow_dispatch: | |
env: | |
APPLICATION: submit | |
DOCKER_REPO: ${{ secrets.DEPLOY_DOCKER_REPOSITORY }} | |
ZAP_VERSION: 2.15.0 | |
jobs: | |
static-audit: | |
runs-on: ubuntu-latest | |
environment: development | |
outputs: | |
alerts_undefined: ${{ steps.report.outputs.alerts_undefined }} | |
alerts_low: ${{ steps.report.outputs.alerts_low }} | |
alerts_medium: ${{ steps.report.outputs.alerts_medium }} | |
alerts_high: ${{ steps.report.outputs.alerts_high }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dependencies | |
run: | | |
npm ci | |
- name: Run static security scan | |
run: | | |
npm audit -f markdown -o npm-audit-report.md || true | |
npm audit -f json -o npm-audit-report.json || true | |
cat npm-audit-report.md >> $GITHUB_STEP_SUMMARY | |
- name: Upload npm audit report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: npm-audit-report | |
path: npm-audit-report.json | |
- name: Parse npm audit report | |
id: report | |
run: | | |
# Parse the npm audit report and output the number of alerts based on severity | |
echo "alerts_low=$(jq '[..vulnerabilities[] | select(.severity == "low")] | length' npm-audit-report.json)" >> $GITHUB_OUTPUT | |
echo "alerts_medium=$(jq '[..vulnerabilities[] | select(.severity == "moderate")] | length' npm-audit-report.json)" >> $GITHUB_OUTPUT | |
echo "alerts_high=$(jq '[..vulnerabilities[] | select(.severity == "high")] | length' npm-audit-report.json)" >> $GITHUB_OUTPUT | |