|
| 1 | +name: Security Scan |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: ["**"] |
| 6 | + push: |
| 7 | + branches: [main, develop] |
| 8 | + schedule: |
| 9 | + - cron: "0 8 * * 1" # weekly Monday 08:00 UTC |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + security-events: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + codeql: |
| 17 | + name: CodeQL (Java SAST) |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 21 | + |
| 22 | + - name: Set up JDK 21 |
| 23 | + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 24 | + with: |
| 25 | + distribution: temurin |
| 26 | + java-version: "21" |
| 27 | + |
| 28 | + - name: Initialize CodeQL |
| 29 | + uses: github/codeql-action/init@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5 |
| 30 | + with: |
| 31 | + languages: java |
| 32 | + queries: +security-extended |
| 33 | + |
| 34 | + - name: Build with Maven |
| 35 | + run: ./mvnw -B compile -DskipTests -pl ice,ice-rest-catalog |
| 36 | + |
| 37 | + - name: Perform CodeQL Analysis |
| 38 | + uses: github/codeql-action/analyze@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5 |
| 39 | + with: |
| 40 | + category: "/language:java" |
| 41 | + |
| 42 | + trivy: |
| 43 | + name: Trivy Filesystem Scan |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 47 | + |
| 48 | + - name: Run Trivy (table output for logs) |
| 49 | + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 |
| 50 | + with: |
| 51 | + scan-type: fs |
| 52 | + scan-ref: . |
| 53 | + scanners: vuln |
| 54 | + severity: CRITICAL,HIGH |
| 55 | + exit-code: "1" |
| 56 | + format: table |
| 57 | + trivy-config: trivy.yaml |
| 58 | + |
| 59 | + - name: Run Trivy (SARIF for GitHub Security tab) |
| 60 | + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 |
| 61 | + if: always() |
| 62 | + with: |
| 63 | + scan-type: fs |
| 64 | + scan-ref: . |
| 65 | + scanners: vuln |
| 66 | + severity: CRITICAL,HIGH |
| 67 | + exit-code: "0" |
| 68 | + format: sarif |
| 69 | + output: trivy-results.sarif |
| 70 | + trivy-config: trivy.yaml |
| 71 | + |
| 72 | + - name: Upload Trivy SARIF to GitHub Security |
| 73 | + uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5 |
| 74 | + if: always() |
| 75 | + with: |
| 76 | + sarif_file: trivy-results.sarif |
| 77 | + |
| 78 | + grype: |
| 79 | + name: Grype Dependency Scan |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 83 | + |
| 84 | + - name: Run Grype (table output for logs) |
| 85 | + uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0 |
| 86 | + with: |
| 87 | + path: . |
| 88 | + fail-build: "true" |
| 89 | + severity-cutoff: high |
| 90 | + output-format: table |
| 91 | + |
| 92 | + - name: Run Grype (SARIF for GitHub Security tab) |
| 93 | + uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0 |
| 94 | + if: always() |
| 95 | + id: grype-sarif |
| 96 | + with: |
| 97 | + path: . |
| 98 | + fail-build: "false" |
| 99 | + severity-cutoff: high |
| 100 | + output-format: sarif |
| 101 | + |
| 102 | + - name: Upload Grype SARIF to GitHub Security |
| 103 | + uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5 |
| 104 | + if: always() |
| 105 | + with: |
| 106 | + sarif_file: ${{ steps.grype-sarif.outputs.sarif }} |
| 107 | + category: grype |
0 commit comments