Skip to content

CodeQL

CodeQL #4321

name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
paths-ignore:
- '**/*.md'
- '**/*.txt'
schedule:
- cron: '0 22 * * 6'
env:
MAVEN_VERSION: '3.9.9'
jobs:
analyze:
name: 'Analyze'
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript', 'python' ]
steps:
- uses: actions/checkout@v4
with:
lfs: false
- name: 'Cache Maven repository'
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: 'Initialize CodeQL'
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# 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
queries: security-and-quality
- name: 'Set up JDK'
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: 'Set up Maven'
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: 'Build'
run: |
mvn clean install -Dmaven.test.skip=true -Ddocker.skip=true -Dtest.onlyITs= -B -V -e -fae -q -DskipQA=true
- name: 'Perform CodeQL Analysis'
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
upload: false
output: 'sarif-results'
- name: 'Filter sarif files'
uses: advanced-security/filter-sarif@v1
with:
# filter out all these files
# https://josh-ops.com/posts/github-codeql-ignore-files/
patterns: |
-**/extjs/*.js
-**/*Test*.java
-**/generated-sources/**/*.java
input: "sarif-results/${{ matrix.language }}.sarif"
output: "sarif-results/${{ matrix.language }}.sarif"
- name: 'Upload sarif files'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "sarif-results/${{ matrix.language }}.sarif"
- name: 'Upload loc as a Build Artifact'
uses: actions/upload-artifact@v4
with:
name: "sarif-results.${{ matrix.language }}"
path: 'sarif-results'
retention-days: 1
- name: 'Cleanup build artifacts'
run: |
mvn clean build-helper:remove-project-artifact
find ~/.m2/repository -name "*SNAPSHOT*" -type d | xargs rm -rf {}