- Treats code as a queryable database rather than a set of files.
- Performs semantic and cross-file analysis to follow actual data flow.
- Uses language libraries (including taint-tracking predicates) to model sources, sanitizers, and sinks.
In the example above,
isUserControlled(...) is a conceptual placeholder. In real CodeQL queries you should use CodeQL’s taint-tracking predicates (from the official libraries) or define precise source predicates to model user-controlled input. See CodeQL taint-tracking for implementation patterns.req.query.q) to the sink (db.query(...)) and can flag this as an SQL injection if the value is tainted and not sanitized.
Interpreted vs compiled languages
To analyze code, CodeQL needs a representation of the program. How it obtains that differs by language:
- For interpreted languages (JavaScript, Python, Ruby), CodeQL can read and analyze source files directly.

- For compiled languages (Java, C/C++, Go, etc.), CodeQL must observe the build because compiled artifacts and generated files affect the final program structure. CodeQL hooks into your compiler and build system to capture the build artifacts. If the build fails, CodeQL cannot complete its analysis.
If the CodeQL workflow cannot reproduce your project’s build (missing code generation, different build flags, or absent dependencies), analysis will fail. Ensure your CI build mirrors the local build steps exactly for compiled languages.

- Reproduce your CI build locally and include all build steps: compilation, code generation, dependency fetching.
- For compiled languages, include the same build commands in the CodeQL workflow so it can analyze the produced artifacts.
- Make CodeQL (and its underlying build) a required status check for protected branches to block merges when analysis cannot complete or reports new issues.
- Use CodeQL’s standard libraries for taint-tracking and model specific sources/sinks for your application framework.
Summary (what to remember)
- CodeQL provides semantic, cross-file, data-flow analysis — not simple token matching.
- It excels at finding vulnerability patterns that depend on program logic (e.g., unsanitized input reaching eval, SQL builders, or command execution).
- For interpreted languages, analysis can run on source files. For compiled languages, ensure builds succeed and are reproduced in the workflow.
- Failures in the build step will prevent CodeQL from analyzing your project; make your CI build reliable and consistent.
- CodeQL documentation — CodeQL docs
- CodeQL language guide — taint-tracking
- GitHub Code Scanning — automatically scanning your code for vulnerabilities