Merge pull request #74 from corpobit/update-docker-workflows-go-server #48
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 | |
| paths: | |
| - 'Dockerfile' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'crossview-go-server/go.mod' | |
| - 'crossview-go-server/go.sum' | |
| - 'helm/**' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'Dockerfile' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'crossview-go-server/go.mod' | |
| - 'crossview-go-server/go.sum' | |
| - 'helm/**' | |
| schedule: | |
| - cron: '0 2 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| scan-docker-images: | |
| name: Scan Docker Images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| security-events: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scanner on Dockerfile (table output) | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Run Trivy vulnerability scanner on Dockerfile (SARIF) | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| severity: 'CRITICAL,HIGH' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Check if SARIF file exists | |
| id: check_sarif | |
| if: always() | |
| run: | | |
| if [ -f trivy-results.sarif ]; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload Trivy results to GitHub Security | |
| uses: github/codeql-action/upload-sarif@v4 | |
| if: always() && steps.check_sarif.outputs.exists == 'true' | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| - name: Scan application Docker image | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: 'corpobit/crossview:latest' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Scan PostgreSQL image | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: 'postgres:16.3-alpine' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| scan-npm-dependencies: | |
| name: Scan NPM Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run npm audit | |
| run: | | |
| echo "Running npm audit..." | |
| npm audit --audit-level=moderate || true | |
| echo "Checking for fixable vulnerabilities..." | |
| npm audit fix --dry-run || true | |
| - name: Run Trivy on package files | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: 'package-lock.json' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Generate vulnerability summary | |
| if: always() | |
| run: | | |
| echo "## Security Scan Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Security scan completed. Check the logs above for detailed vulnerability information." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "📊 Results are also available in the GitHub Security tab." >> $GITHUB_STEP_SUMMARY | |
| scan-go-dependencies: | |
| name: Scan Go Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Run Trivy on Go dependencies | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: 'crossview-go-server' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Run Trivy on go.sum | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: 'crossview-go-server/go.sum' | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH,MEDIUM' | |
| exit-code: '0' | |
| ignore-unfixed: false | |
| continue-on-error: true | |
| - name: Generate Go vulnerability summary | |
| if: always() | |
| run: | | |
| echo "## Go Dependencies Security Scan Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Go dependencies security scan completed." >> $GITHUB_STEP_SUMMARY | |