Static analysis
What is CodeQL? An introduction to GitHub's semantic code analysis engine
CodeQL is GitHub's semantic code analysis engine for discovering vulnerabilities across a codebase. It lets users query code as if it were data, so a security question becomes a query that can be run, refined and shared. Analysis runs against a CodeQL database, and queries can be run from a Visual Studio Code extension.
- Tool
- CodeQL
- Made by
- GitHub
- Official site
- codeql.github.com
- Category
- Static analysis
Who makes CodeQL
CodeQL is made by GitHub. The official CodeQL website is linked below this article and is the place to confirm current documentation, downloads and licensing terms.
Official website: codeql.github.com
What CodeQL is for
CodeQL is used to discover vulnerabilities across a codebase. Instead of matching text patterns, it works as a semantic analysis engine, and it treats code as data that can be queried.
That model changes how a vulnerability is hunted. A user can write a query that finds all variants of a vulnerability, not just a single instance, and then share that query with others so the same search can be repeated elsewhere.
Who CodeQL is for
The vendor names three audiences: security researchers, open source project maintainers and academic researchers. Each of these groups benefits from being able to express a vulnerability pattern as a query and reuse it.
Licensing matters when deciding whether CodeQL fits a project. Use is restricted to OSI-approved open source codebases, academic research, or specific automated-analysis cases. Other CI/CD use requires contacting sales. CodeQL databases can be created for any project under an OSI-approved open source license.
Notable capabilities
CodeQL combines a query-based approach to code analysis with tooling for building databases and running queries. The capabilities below come from the vendor's published material.
- Semantic code analysis: the engine is built to discover vulnerabilities across a codebase rather than only flag surface-level patterns.
- Code as data: users query code as if it were data, which is the core idea behind the tool.
- Variant finding and sharing: a single query can find all variants of a vulnerability, and that query can be shared with other people.
- Database-driven analysis: analysis works against a CodeQL database, which can be downloaded for open source projects or created with the CodeQL CLI.
- CLI database creation: for a Java project, the CLI builds a database when you specify the language and a build command.
- Visual Studio Code extension: queries can be run through the extension, and a starter workspace is available. You right-click and choose Run Query.
- Taint tracking: CodeQL supports taint tracking, which is highlighted in a Java Capture the Flag challenge.
How CodeQL fits static analysis
Static analysis examines code without running it, and CodeQL fits that category through a query-driven approach. Rather than shipping only a fixed set of checks, it gives users a way to ask their own questions of a codebase and to share the answers as queries.
Within Linthelm's wider niche of linters, static analysis and code quality, CodeQL sits on the security-focused end. It is aimed at finding vulnerabilities, and the use of taint tracking and shareable variant queries reflects that purpose. Readers comparing tools in this niche should check the licensing scope first, since it depends on whether the codebase is open source, academic or another automated-analysis case.
Frequently asked questions
What is CodeQL used for?
CodeQL is used to discover vulnerabilities across a codebase. Users query code as if it were data, and can write a query that finds all variants of a vulnerability.
Who develops CodeQL?
CodeQL is developed by GitHub. Its official website is https://codeql.github.com.
How do I create a CodeQL database?
A CodeQL database can be downloaded for open source projects or created with the CodeQL CLI. For a Java project, the CLI builds a database when you specify the language and a build command.
Can I run CodeQL queries in Visual Studio Code?
Yes. Queries can be run through a Visual Studio Code extension. With the starter workspace, you right-click and choose Run Query.
Can CodeQL be used in any CI/CD pipeline?
Not without checking the terms. Use is restricted to OSI-approved open source codebases, academic research, or specific automated-analysis cases. Other CI/CD use requires contacting sales.
Linthelm is independent and is not affiliated with GitHub. Product names belong to their owners. Features change; confirm details on the official website.