This project uses CodeQL to analyze code in multiple languages:
- Java/Kotlin (Android app)
- Python (DCS scripts)
The GitHub workflow (.github/workflows/codeql.yml) automatically creates separate databases for each language using a matrix strategy:
matrix:
include:
- language: actions
build-mode: none
- language: java-kotlin
build-mode: manual
- language: python
build-mode: noneThis runs 3 parallel jobs on GitHub Actions, each creating its own database and uploading results separately.
- Each language gets its own job (runner)
- CodeQL creates a database for that specific language
- Analysis runs independently
- Results are uploaded to GitHub Security tab
Run the provided batch script:
run_codeql_analysis.batThis will:
- Clean previous databases
- Create Java/Kotlin database (compiles Android app)
- Create Python database (scans scripts folder)
- Download CodeQL query packs (first run only)
- Analyze both databases
- Generate SARIF reports
Java/Kotlin (Android):
# Use Debug build (Release build may have compilation errors)
codeql database create codeql-db-java --language=java-kotlin --command="gradlew.bat assembleDebug --no-daemon"
# Download query pack (first time only)
codeql pack download codeql/java-queries
# Analyze with explicit query pack
codeql database analyze codeql-db-java codeql/java-queries --format=sarif-latest --output=java-analysis.sarifPython (Scripts):
codeql database create codeql-db-python --language=python --source-root=scripts
# Download query pack (first time only)
codeql pack download codeql/python-queries
# Analyze with explicit query pack
codeql database analyze codeql-db-python codeql/python-queries --format=sarif-latest --output=python-analysis.sarif- Install the CodeQL extension
- Run
run_codeql_analysis.batto create databases - In VS Code, select CodeQL: Choose Database
- Select either:
codeql-db-javafor Android analysiscodeql-db-pythonfor Python scripts
You can only analyze one language at a time in the IDE, but you can switch between databases.
CodeQL requires separate databases for each language because:
- Different languages have different AST (Abstract Syntax Tree) structures
- Each language needs specific extractors and libraries
- Analysis queries are language-specific
The GitHub online scan handles this automatically with matrix jobs. For local/IDE analysis, you must create separate databases.
After running analysis:
java-analysis.sarif- Java/Kotlin security findingspython-analysis.sarif- Python security findingscodeql-db-java/- Java/Kotlin database (can be reused)codeql-db-python/- Python database (can be reused)
All output files are git-ignored (see .gitignore lines 57-66).
Install CodeQL CLI: https://github.com/github/codeql-cli-binaries/releases
The query packs are downloaded automatically by the script. If manual download is needed:
codeql pack download codeql/java-queries
codeql pack download codeql/python-queriesMake sure you can build the project with:
gradlew.bat assembleDebugIf Release build fails, CodeQL analysis uses Debug build by default (which is sufficient for security analysis).
Ensure Python files exist in scripts/ directory.