Skip to content

Repository files navigation

CodeQL for Python

Unofficial Python 3.x bindings for the CodeQL CLI application.

Install the package via:

pip install git+https://github.com/AlexAltea/codeql-python.git

Usage

importcodeql# Open databases from files or foldersdb=codeql.Database('path/to/db.zip')
# Queries return a CSV-like array of arraysresults=db.query('select "Hello"')
assert(results[0][1] =='Hello')
# Queries with external libraries are supported as wellcodeql.set_search_path('path/to/codeql')
results=db.query(''' import cpp from BlockStmt block  select block''')
# Create temporary databases from inlined sourcesdb=codeql.Database.from_cpp(''' int main() { return 1337 + 1337 + 1337; }''')
results=db.query(''' import cpp from Literal literal where literal.getType() instanceof IntType and literal.getValue().toInt() = 1337 select literal''')
assert(len(results[1:]) ==3)

About

Python bindings for CodeQL CLI

Resources

Stars

54 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages