|
| 1 | + |
| 2 | +# You may wish to alter this file to override the set of languages analyzed, |
| 3 | +# or to provide custom queries or build logic. |
| 4 | +# |
| 5 | +# ******** NOTE ******** |
| 6 | +# We have attempted to detect the languages in your repository. Please check |
| 7 | +# the `language` matrix defined below to confirm you have the correct set of |
| 8 | +# supported CodeQL languages. |
| 9 | + |
| 10 | +#1) HEADER & TRIGGER |
| 11 | +name: "Codeql on PR / Conditional Scan NEW" |
| 12 | + |
| 13 | +on: |
| 14 | + pull_request: |
| 15 | + branches: [ "main" ] #Se voglio triggerare su tutti i rami = branches: [ "*" ] |
| 16 | + |
| 17 | +#2) CONFIGURAZIONE JOBS |
| 18 | +jobs: |
| 19 | + analyze: |
| 20 | + name: Analyze Java - Conditional |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | +#3) PERMESSI - DEFINISCE COSA PUO' FARE IL WORKFLOW NEL REPOSITORY |
| 24 | + permissions: |
| 25 | + security-events: write # Per scrivere risultati di sicurezza |
| 26 | + packages: read # Per scaricare query pack CodeQL |
| 27 | + actions: read # Per leggere altri workflow |
| 28 | + contents: read # Per leggere il codice del repo |
| 29 | + |
| 30 | +#4) CHECKOUT |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 # Necessario per rilevare i file modificati |
| 36 | + |
| 37 | +#5) RILEVAMENTO FILE MODIFICATI |
| 38 | + - name: Get changed files |
| 39 | + id: changed-files |
| 40 | + uses: tj-actions/changed-files@v44 # https://github.com/tj-actions/changed-files |
| 41 | + with: |
| 42 | + files: | |
| 43 | + **/*.java |
| 44 | + **/*.xml |
| 45 | + **/*.properties |
| 46 | +
|
| 47 | +#6) SETUP JAVA - CONDIZIONALE |
| 48 | + - name: Setup Java |
| 49 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 50 | + uses: actions/setup-java@v4 |
| 51 | + with: |
| 52 | + distribution: 'temurin' |
| 53 | + java-version: '21' |
| 54 | + |
| 55 | +#7) INITIALIZE CODEQL - CONDIZIONALE |
| 56 | + - name: Initialize CodeQL |
| 57 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 58 | + uses: github/codeql-action/init@v3 |
| 59 | + with: |
| 60 | + languages: java-kotlin |
| 61 | + build-mode: none |
| 62 | + queries: ./.codeql/custom-queries |
| 63 | + # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#extending-codeql-coverage-with-codeql-model-packs |
| 64 | + |
| 65 | + # If you wish to specify custom queries, you can do so here or in a config file. |
| 66 | + # By default, queries listed here will override any specified in a config file. |
| 67 | + # Prefix the list here with "+" to use these queries and those in the config file. |
| 68 | + |
| 69 | + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs |
| 70 | + # queries: security-extended,security-and-quality |
| 71 | + |
| 72 | +#8) BUILD MANUALE - CONDIZIONALE |
| 73 | + # - name: Build WebGoat - Full Project |
| 74 | + # if: steps.changed-files.outputs.any_changed == 'true' |
| 75 | + # run: | |
| 76 | + # echo "Building complete WebGoat project..." |
| 77 | + # mvn clean compile -DskipTests -q |
| 78 | + # echo "Build completed successfully" |
| 79 | + |
| 80 | +#9) ANALISI CODEQL - CONDIZIONALE |
| 81 | + - name: Perform CodeQL Analysis |
| 82 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 83 | + uses: github/codeql-action/analyze@v3 |
| 84 | + |
| 85 | +#10) SUMMARY |
| 86 | + - name: Analysis Summary |
| 87 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 88 | + run: | |
| 89 | + echo "WebGoat CodeQL analysis completed" |
| 90 | + echo "Files analyzed: ${{ steps.changed-files.outputs.all_changed_files }}" |
| 91 | + echo "Language: java-kotlin" |
| 92 | + |
| 93 | + - name: No Changes Summary |
| 94 | + if: steps.changed-files.outputs.any_changed == 'false' |
| 95 | + run: | |
| 96 | + echo "No Java/XML/Properties files changed" |
| 97 | + echo "⏭CodeQL analysis skipped for performance" |
| 98 | + |
0 commit comments