@@ -168,6 +168,8 @@ jobs:
168168 name : Build Gitpod
169169 needs : [ configuration, create-runner ]
170170 runs-on : ${{ needs.create-runner.outputs.label }}
171+ outputs :
172+ affected_packages : ${{ steps.check_vulnerabilities.outputs.affected_packages }}
171173 concurrency :
172174 group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-build-gitpod
173175 cancel-in-progress : ${{ needs.configuration.outputs.is_main_branch == 'false' }}
@@ -323,11 +325,6 @@ jobs:
323325 GITHUB_USER : roboquat
324326325327 VERSION : ${{ needs.configuration.outputs.version }}
326- - name : Add failOn to workspace config (when scheduled)
327- if : needs.configuration.outputs.is_scheduled_run == 'true'
328- run : |
329- # Add failOn: ["critical"] to the sbom block in WORKSPACE.yaml
330- sed -i '/sbom:/,/^[a-z]/ s/enabled: true/enabled: true\n failOn: ["critical"]/' WORKSPACE.yaml
331328 - name : Scan for Vulnerabilities
332329 id : scan
333330 shell : bash
@@ -388,6 +385,25 @@ jobs:
388385 cat "$scans_dir/vulnerability-summary.md" >> $GITHUB_STEP_SUMMARY
389386
390387 exit $RESULT
388+ - name : Check for Critical Vulnerabilities
389+ if : needs.configuration.outputs.is_scheduled_run == 'true'
390+ id : check_vulnerabilities
391+ shell : bash
392+ run : |
393+ # Parse vulnerability-stats.json from the scans directory
394+ CRITICAL_PACKAGES=$(jq -r '.[] | select(.critical > 0) | "\(.name): \(.critical) critical vulnerabilities"' "${{ steps.scan.outputs.leeway_vulnerability_reports_dir }}/vulnerability-stats.json")
395+
396+ # If there are critical packages, list them and fail the build
397+ if [ -n "$CRITICAL_PACKAGES" ]; then
398+ echo "::error::Critical vulnerabilities found in the following packages:"
399+ echo "$CRITICAL_PACKAGES" | tee -a $GITHUB_STEP_SUMMARY
400+ echo "affected_packages<<EOF" >> $GITHUB_OUTPUT
401+ echo "$CRITICAL_PACKAGES" >> $GITHUB_OUTPUT
402+ echo "EOF" >> $GITHUB_OUTPUT
403+ exit 1
404+ else
405+ echo "No critical vulnerabilities found."
406+ fi
391407 - name : Upload SBOMs
392408 uses : actions/upload-artifact@v4
393409 with :
@@ -592,11 +608,11 @@ jobs:
592608 - name : Slack Notification
593609 uses : rtCamp/action-slack-notify@v2
594610 env :
595- SLACK_WEBHOOK : ${{ secrets.ENTERPRISE_JOBS_SLACK_WEBHOOK }}
611+ SLACK_WEBHOOK : ${{ secrets.WORKSPACE_SLACK_WEBHOOK }}
596612 SLACK_ICON_EMOJI : " :x:"
597613 SLACK_USERNAME : " Scheduled Build"
598614 SLACK_COLOR : " danger"
599- SLACK_MESSAGE : " ⚠️ Security Alert: Daily vulnerability scan triggered action! Either critical vulnerabilities were detected or the scan process failed. Please check the vulnerability reports to assess security impact and take appropriate action. "
615+ SLACK_MESSAGE : " ⚠️ Security Alert: Daily vulnerability scan detected critical vulnerabilities in the following packages: \n ${{ needs.build-gitpod.outputs.affected_packages }} "
600616 SLACK_FOOTER : " <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Logs>"
601617
602618 delete-runner :
0 commit comments