CodeQL library for Python
codeql/python-all 3.0.1-dev (changelog, source)
Search

Module VerifyApiGraphs

A test query that verifies assertions about the API graph embedded in source-code comments.

An assertion is a comment of the form def=<path> or use=<path>, and asserts that there is a def/use feature reachable from the root along the given path, and its associated data-flow node must start on the same line as the comment.

We also support negative assertions of the form MISSING: def <path> or MISSING: use <path>, which assert that there isn’t a node with the given path on the same line.

The query only produces output for failed assertions, meaning that it should have no output under normal circumstances.

The syntax is made to look exactly like inline expectation tests, so that the tests can remain consistent with other Python tests.

Import path

import utils.test.VerifyApiGraphs

Imports

ApiGraphs

Provides an implementation of API graphs, which are an abstract representation of the API surface used and/or defined by a code base.

DataFlow

Provides a library for local (intra-procedural) and global (inter-procedural) data flow analysis: deciding whether data can flow from a source to a sink.

python

Predicates

Classes

Assertion

An assertion matching a data-flow node against an API-graph feature.