Scheduled Security Scan #263
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: Scheduled Security Scan | |
| on: | |
| schedule: | |
| - cron: '0 4 * * *' # every day at 4:00 UTC | |
| workflow_dispatch: # can be run manually from the GitHub UI | |
| permissions: | |
| contents: read | |
| security-events: write | |
| actions: read | |
| jobs: | |
| security-scan: | |
| name: 🔐 Security Scan CodeQL | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@main | |
| - name: Run CodeQL | |
| uses: github/codeql-action/init@v4 | |
| with: | |
| languages: java-kotlin | |
| queries: security-and-quality | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@main | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| - name: Build | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew build -x test | |
| - name: CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4 | |
| security-scan-snyk: | |
| name: 🔐 Security Scan Snyk | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@main | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@main | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@main | |
| - name: Run Snyk to check for vulnerabilities | |
| uses: snyk/actions/gradle-9-jdk17@master | |
| env: | |
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
| JAVA_HOME: /opt/java/openjdk # Enforce directory expected by the Snyk container | |
| with: | |
| args: --sarif-file-output=snyk.sarif | |
| - name: Upload Snyk scan results to GitHub Security tab | |
| # Fix condition to work for both push and PR (excluding forks) | |
| if: | | |
| github.event_name == 'push' || | |
| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: 'snyk.sarif' | |
| security-scan-trivy: | |
| name: 🔐 Security Scan Trivy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@main | |
| - name: Run Trivy | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| exit-code: '1' | |
| - name: Run Trivy (console report) | |
| if: failure() | |
| run: | | |
| echo "==== Trivy console report ====" | |
| trivy fs . | |
| - name: Upload Trivy scan results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| security-scan-osv: | |
| name: 🔐 Security Scan OSV | |
| uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.5 | |
| with: | |
| fail-on-vuln: true | |
| scan-args: |- | |
| --config=osv-scanner.toml | |
| --recursive | |
| ./ |