|
| 1 | +name: "CodeQL Advanced Analysis" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "master" ] # Trigger analysis on push to main branches |
| 6 | + pull_request: |
| 7 | + branches: [ "main", "master" ] # Also run on PRs targeting these branches |
| 8 | + schedule: |
| 9 | + - cron: "0 2 * * 1" # Optional: run a scheduled scan every Monday at 2 AM UTC |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + security-events: write |
| 14 | + actions: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + analyze: |
| 18 | + name: "CodeQL Analyze" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + security-events: write |
| 22 | + contents: read |
| 23 | + actions: read |
| 24 | + |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + language: [ 'javascript', 'python', 'java' ] # Add or remove languages based on your repo |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + # (Optional) Setup environment, dependencies, or build tools here |
| 35 | + - name: Setup Node.js |
| 36 | + if: matrix.language == 'javascript' |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: '20' |
| 40 | + |
| 41 | + - name: Setup Python |
| 42 | + if: matrix.language == 'python' |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: '3.11' |
| 46 | + |
| 47 | + - name: Setup Java |
| 48 | + if: matrix.language == 'java' |
| 49 | + uses: actions/setup-java@v4 |
| 50 | + with: |
| 51 | + java-version: '17' |
| 52 | + distribution: 'temurin' |
| 53 | + |
| 54 | + # (Optional) Install project dependencies |
| 55 | + - name: Install dependencies |
| 56 | + if: matrix.language == 'javascript' |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Initialize CodeQL |
| 60 | + uses: github/codeql-action/init@v3 |
| 61 | + with: |
| 62 | + languages: ${{ matrix.language }} |
| 63 | + queries: +security-and-quality # Runs both security and quality query suites |
| 64 | + |
| 65 | + - name: Autobuild |
| 66 | + uses: github/codeql-action/autobuild@v3 |
| 67 | + |
| 68 | + # (Optional) Manual build step (if autobuild fails) |
| 69 | + # - name: Build manually |
| 70 | + # run: | |
| 71 | + # mvn clean install -DskipTests=true |
| 72 | + |
| 73 | + - name: Perform CodeQL Analysis |
| 74 | + uses: github/codeql-action/analyze@v3 |
| 75 | + with: |
| 76 | + category: "/language:${{ matrix.language }}" |
0 commit comments