Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

assert-cpp-definition-is-used

Latest version: v20261130055651

Overview

Last scanned
30 Nov 2026
Published
30 Nov 2026
PyPI package Publisher: jdrowne_10ulabs
0 Stars
0 Forks
2 Versions
Python Repo language

Scan summary

assert-cpp-definition-is-used was last scanned on 30 Nov 2026 at version 20261130055651. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 2 versions, all published on 30 Nov 2026.
  • Findings: No rules fired in version 20261130055651.

Versions

2 versions published
Versions and the rules that fired in each
VersionPublishedStatus
20261130055651 LATEST 30 Nov 2026 No rules fired
20261130053311 30 Nov 2026 No rules fired

No rules fired in 20261130055651

Findings

Findings for v20261130055651. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 20261130055651; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

assert-cpp-definition-is-used

Assert that every C++ definition in a tree is reached from a root of the program.

Why

A function whose last caller is deleted does not disappear. Its tests still pass and the coverage gate over its file stays green, because a test that calls a function runs its lines. Nothing in a normal toolchain reports it.

A loose check asks whether the definition's name is written anywhere else. In C++ that question proves nothing. Overloads and members such as size or get are everywhere, and two dead functions that call each other both pass. C++ names can be tied to definitions, because the compiler knows which definition each name refers to, so this tool asks the stricter question: can the definition be reached from where the program starts?

Installation

pip install assert-cpp-definition-is-used

The package depends on the libclang wheel, which carries a libclang shared library and clang's Python bindings.

Usage

cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

# Definitions in src/ that main and the exported C interface never reach
assert-cpp-definition-is-used --build-dir build \
  --roots-declared-in include/vpi_user.h \
  --roots-declared-in include/svdpi.h \
  src

# Shared test code that no test reaches
assert-cpp-definition-is-used --build-dir build \
  --sources test --sources lib/cpp \
  lib/cpp

Each translation unit named in compile_commands.json whose source file lies under a --sources tree is parsed with its own command line. Those units make up the program. The positional trees are the ones whose definitions are checked; a definition outside them, such as one in the standard library, is followed but never reported.

Options
Option Effect
--build-dir DIR The directory holding compile_commands.json. Required.
--sources TREE Parse only units under this tree. Repeatable. Defaults to the trees.
--root NAME A fully qualified function the program is entered through. Repeatable. Defaults to main.
--roots-declared-in HEADER Every function this header declares is a root. Repeatable.
--libclang PATH The libclang shared library to parse with.
--jobs N How many units are parsed at once. Defaults to the processors.
--exclude PATTERNS Comma-separated globs. A matching source is not parsed, and a definition in a matching file is not reported.
--quiet Print nothing; report through the exit code.
--count Print only how many definitions are dead.
--verbose Print each unit parsed, each fallback on a dependent name, and a summary.
--fail-fast Report only the first dead definition.
--warn-only Always exit 0.
Exit codes
Code Meaning
0 Nothing is dead
1 Something is dead
2 The build directory or its compile_commands.json is missing or unreadable, a unit failed to parse, libclang could not be loaded, or a --root or --roots-declared-in named nothing
Output

Each dead definition prints on its own line, sorted by path and then by line:

src/main.cpp:3:6: function pong is reached from no root
src/shapes.h:12:21: member function Square::size is reached from no root

Parsing with the build's clang

The bundled libclang carries none of clang's own headers, such as stddef.h and stdarg.h, so a unit that includes the standard library may fail to parse with it. Point --libclang at the libclang of an installed LLVM, which finds its headers beside itself:

assert-cpp-definition-is-used --build-dir build \
  --libclang /usr/lib/llvm-18/lib/libclang.so.1 src

Using the same version as the compiler in compile_commands.json also keeps the parse from tripping over flags or language features the bundled version does not know. A unit that does not parse is an error, not a skipped file, because whatever it alone uses would be reported as dead.

What a definition is

Every one of these is checked:

  • free functions and function templates
  • member functions, static ones included, and constructors, destructors and conversion functions
  • classes, structs, unions, class templates and their partial specializations
  • enumerations and their enumerators
  • type aliases and alias templates, whether written with using or typedef
  • variables and constants at namespace scope
  • static and non-static data members

Local variables and parameters are left out, since the compiler's own unused warnings already cover them. An anonymous class, union or enumeration has no name to report, so it is never reported itself, though its named members are.

A definition is one entity however many units include it. The tool keys each entity by its USR, the unified symbol resolution string clang gives every declaration, so an inline function in a header that 50 files include is one definition, and two overloads of one name are two. An entity with internal linkage, such as a static function or one in an anonymous namespace, is also keyed by the file that declares it.

What counts as a use

A definition is used when it is reachable. Every root is reachable, and so is every entity that a reachable definition references. A reference is anything the compiler resolves to the entity: a call, taking its address to register a callback, naming a type, a base class or a template argument, reading or writing a member, an enumerator in a case label, an operator such as a + b or x[i], and the begin, end and iterator operators a range for calls.

A definition referenced only by itself, or only by definitions that are themselves unreachable, is dead. A unit outside --sources is never parsed, so a call from a test never counts.

A use of a template's instantiation is a use of the template: calling Box<int>::get reaches Box::get. Using a member reaches the class that holds it.

Calls the compiler makes

Some calls appear in no source text. These rules cover them:

  • When a class is reachable, so are its destructor, its constructors and every one of its virtual member functions. Code outside the parsed program, such as a library, may call a virtual through a base class, and a constructor is often called from inside a standard template such as std::make_unique.
  • When a reachable function is a coroutine, so are its promise type and the members of it the compiler calls: get_return_object, initial_suspend, final_suspend, return_void, return_value, unhandled_exception, await_transform and yield_value, and the await_ready, await_suspend and await_resume members of what they return. A promise type chosen by a specialization of std::coroutine_traits is found by name instead.
  • A variable at namespace scope, or a static data member, whose initializer calls a function that is not constexpr or consteval is a root, because that initializer runs before main. A googletest TEST is one: it defines a static data member whose initializer registers the test. A variable whose initializer is constant is used only when something references it.

Dependent names

Inside a template, a name that depends on a template parameter cannot be resolved until the template is instantiated, and clang's tree of the template's own text leaves it unresolved. The tool counts such a name as a use of every entity with that name: machine.start() in a template reaches every start, and a dependent a < b reaches every operator<. A range for over a dependent range does the same for begin, end and the iterator operators.

Only this fallback makes the result a lower bound rather than an exact answer, and --verbose names each place it happens inside the checked trees:

Falling back to every entity named start: src/launch.h:3:46

GitHub Actions

- name: Assert every definition is reached from a root
  uses: 10U-Labs/assert-cpp-definition-is-used@latest
  with:
    build-dir: build
    libclang: /usr/lib/llvm-18/lib/libclang.so.1
    roots-declared-in: include/vpi_user.h include/svdpi.h
    trees: src
    verbose: true

Over shared test code, where the test programs are the program:

- name: Assert every test helper is reached from a test
  uses: 10U-Labs/assert-cpp-definition-is-used@latest
  with:
    build-dir: build
    libclang: /usr/lib/llvm-18/lib/libclang.so.1
    sources: test lib/cpp
    trees: lib/cpp

License

Apache-2.0

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases assert-cpp-definition-is-used

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Vulnerability Insights

OpenSSH Password Authentication Bypass on Alpine Linux (*sshole) – CVE-2026-123158

Frame 2085668439 (1)
Group 1261154229