Fix ~238 code scanning security alerts: log injection, regex injection, XSS, container privilege escalation #671
Workflow file for this run
This file contains hidden or 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: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| # Run security scan daily at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| security-events: write | |
| actions: read | |
| jobs: | |
| dependency-scan: | |
| name: Dependency Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci --audit=true --audit-level=moderate | |
| - name: Run npm audit | |
| run: | | |
| echo "## NPM Security Audit" >> $GITHUB_STEP_SUMMARY | |
| npm audit --production --audit-level=moderate | |
| npm audit --json > npm-audit.json | |
| - name: Check claims-scrubbing-service | |
| run: | | |
| if [ -d "services/claims-scrubbing-service" ]; then | |
| cd services/claims-scrubbing-service | |
| npm ci | |
| npm audit --production --audit-level=moderate | |
| else | |
| echo "⚠️ claims-scrubbing-service not found, skipping" | |
| fi | |
| - name: Upload audit results | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: npm-audit-results | |
| path: npm-audit.json | |
| retention-days: 30 | |
| dotnet-scan: | |
| name: .NET Security Scan | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| service: | |
| - services/sponsor-service | |
| - services/member-service | |
| - services/coverage-service | |
| - services/provider-service | |
| - services/claims-service | |
| - services/authorization-service | |
| - services/reference-data-service | |
| - services/benefit-plan-service | |
| - services/eligibility-service | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| run: | | |
| if [ -f "${{ matrix.service }}/*.csproj" ]; then | |
| cd ${{ matrix.service }} | |
| dotnet restore | |
| fi | |
| - name: Check for vulnerable packages | |
| run: | | |
| if [ -f "${{ matrix.service }}/*.csproj" ]; then | |
| cd ${{ matrix.service }} | |
| dotnet list package --vulnerable --include-transitive 2>&1 | tee vuln-check.txt | |
| if grep -q "has the following vulnerable packages" vuln-check.txt; then | |
| echo "❌ Vulnerable packages found in ${{ matrix.service }}" | |
| cat vuln-check.txt | |
| exit 0 | |
| else | |
| echo "✅ No vulnerable packages in ${{ matrix.service }}" | |
| fi | |
| fi | |
| docker-scan: | |
| name: Docker Image Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scanner in fs mode | |
| uses: aquasecurity/[email protected] | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| severity: 'CRITICAL,HIGH' | |
| exit-code: '0' | |
| ignore-unfixed: true | |
| - name: Upload Trivy results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v4 | |
| if: always() | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| - name: Generate Trivy report | |
| if: always() | |
| uses: aquasecurity/[email protected] | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| ignore-unfixed: true | |
| secret-scan: | |
| name: Secret Scanning | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Run Gitleaks | |
| uses: gitleaks/gitleaks-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} | |
| security-summary: | |
| name: Security Summary | |
| runs-on: ubuntu-latest | |
| needs: [dependency-scan, dotnet-scan, docker-scan, secret-scan] | |
| if: always() | |
| steps: | |
| - name: Generate Security Summary | |
| run: | | |
| echo "# 🛡️ Security Scan Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Scan Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Scan Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Scan Type | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Dependency Scan | ${{ needs.dependency-scan.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| .NET Scan | ${{ needs.dotnet-scan.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Docker Scan | ${{ needs.docker-scan.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Secret Scan | ${{ needs.secret-scan.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Action Required:** Review failed scans and remediate vulnerabilities" >> $GITHUB_STEP_SUMMARY |