Skip to main content

Rhada

Rhada is a compliance, Software Bill of Materials (SBOM), binary linkage, and security vulnerability auditor for Python source workspaces and compiled Linux distributions (Nuitka and PyInstaller).

Overview

  1. Dual-Mode Operation

    • Source Mode (default when --dist is omitted): Inspects Python source workspaces. Supports modern PEP 621 / uv projects (pyproject.toml, uv.lock) as well as legacy setuptools and pip workspaces (setup.py, setup.cfg, requirements.txt). setup.py is safely inspected using static Abstract Syntax Tree (AST) parsing without executing untrusted code. Discovers installed package metadata across virtual environments (.venv, venv, env) to separate direct runtime dependencies from development/build tools, extract SPDX licence metadata, and check for security advisories.
    • Compiled Distribution Mode (--dist <path>): Audits Nuitka and PyInstaller artefacts, including standalone directories (app.dist/, dist/app/) and monolithic single-file binaries (app.bin). Identifies bundled Python modules (excluding build and test tools such as pytest, ruff, mypy, nuitka, and pyinstaller), inspects bundled native shared libraries (.so), and verifies ELF dynamic linkage.
  2. Legal and Licence Compliance

    • Parses and normalises METADATA licence headers, PEP 639 License-Expression fields, Trove classifiers, and verbatim licence texts into canonical SPDX identifiers and compound expressions (MIT OR Apache-2.0, GPL-2.0-only AND BSD-3-Clause) using license-expression.
    • Categorises licence risk (permissive, public-domain, weak-copyleft, strong-copyleft, proprietary, unknown) and evaluates redistribution rules:
      • Flags strong copyleft (GPL-*, AGPL-*, SSPL-1.0) obligations (LIC-COP-STRONG, LIC-COP-NETWORK).
      • Detects LGPL relinking issues (LIC-LGPL-MONOLITHIC) when weak-copyleft libraries are statically compiled or embedded into monolithic binaries without dynamic .so relinking support.
    • Generates a THIRD_PARTY_NOTICES attribution file containing component inventory, copyright notices, NOTICE / AUTHORS files, and verbatim licence texts.
  3. ELF Binary and Native Library Inspection

    • Parses 32-bit and 64-bit ELF executables and .so libraries via pyelftools with a struct fallback for stripped or header-truncated binaries.
    • Extracts DT_NEEDED, DT_SONAME, DT_RPATH, DT_RUNPATH, PT_INTERP, exported symbols (PyInit_*, modulecode_*), and embedded library version strings (OpenSSL, zlib, SQLite, libffi, gmp, readline, etc.).
    • Verifies whether each DT_NEEDED shared library is resolved within the distribution, satisfied by the baseline Linux/glibc ABI, or missing as an unbundled external dependency, and flags insecure RPATH/RUNPATH tokens.
  4. Security Vulnerability Auditing

    • Integrates pip-audit (OsvService and ResolvedDependency) alongside the OSV.dev batch API (/v1/querybatch) and advisory endpoints (/v1/vulns/{id}) for discovered Python packages and versioned native libraries.
    • Calculates CVSS v3.0/v3.1 base scores using cvss and summarises findings by severity (CRITICAL, HIGH, MEDIUM, LOW) with fixed version recommendations.
  5. Standards-Compliant SBOMs and CLI Exit Codes

    • Generates CycloneDX 1.5 JSON (via cyclonedx-python-lib and packageurl-python) and SPDX 2.3 JSON SBOMs.
    • Provides a typed CLI built with typer and deterministic exit codes for CI/CD enforcement.

Installation

Manage and install with uv:

# Install dependencies and synchronise virtual environment
uv sync

# Run via uv
uv run rhada --help

Pre-Commit Hook Integration

Add Rhada to your .pre-commit-config.yaml to audit source workspaces automatically before each commit:

repos:
  - repo: https://github.com/dcollison/rhada
    rev: v0.1.0
    hooks:
      - id: rhada

CLI Usage

1. Audit a Python / uv Source Workspace

uv run rhada --project . \
  --sbom sbom.cdx.json \
  --notices THIRD_PARTY_NOTICES

2. Audit a Compiled Nuitka or PyInstaller Distribution

# Standalone directory (Nuitka .dist or PyInstaller folder)
uv run rhada --project . --dist ./build/app.dist \
  --sbom dist-sbom.json \
  --sbom-format cyclonedx \
  --notices dist/THIRD_PARTY_NOTICES \
  --fail-on-linkage

# Monolithic single-file binary (PyInstaller onefile or Nuitka onefile)
uv run rhada --project . --dist ./dist/app-linux-x86_64 \
  --sbom dist-sbom.spdx.json \
  --sbom-format spdx \
  --notices dist/THIRD_PARTY_NOTICES

3. Policy Controls, Internal Packages, and pyproject.toml Configuration

Rhada supports turnkey policy configuration via CLI options or centrally via [tool.rhada] in your pyproject.toml:

Internal Package Whitelisting (--internal-package / --allow-package)

For projects utilizing in-house or corporate packages (e.g. from private registries or monorepos):

  • Matching packages are treated as first-party organization code.
  • Exempt from third-party license compliance checks (LIC-UNKNOWN, LIC-PROPRIETARY, LIC-POLICY-NOT-ALLOWED).
  • Bypassed from public OSV.dev vulnerability queries (preventing private package name leakage).
  • Omitted from THIRD_PARTY_NOTICES (which are reserved for third-party OSS).
  • Classified as first-party application code in distribution file accounting.
# Whitelist by pattern or comma-separated names
uv run rhada --project . --internal-package "mycorp-*,internal-auth"

Ignoring Dependencies (--ignore-package)

To completely omit specific packages from audit findings:

uv run rhada --project . --ignore-package "legacy-test-tool,mock-*"

Approved Licences (--allow-licence vs --allow-extra-licence)

  • --allow-licence / --allow-license (Strict Whitelist): Enforces a strict, closed-world allowlist. Only the explicitly listed licences are approved. Any package whose licence is not in this list (including standard permissive licences like MIT or Apache-2.0) will be flagged as unapproved (LIC-POLICY-NOT-ALLOWED).
    # Enforce that only these exact licences are legally approved across the entire project
    uv run rhada --project . \
      --allow-licence "MIT,Apache-2.0,BSD-3-Clause,0BSD,LicenseRef-AcmeCorp,Proprietary"
    
  • --allow-extra-licence / --allow-extra-license (Supplemental Allowlist): Similar to --extra-index-url in pip/uv, this flag supplements the default permissive baseline rather than replacing it. It permits specific additional or custom/proprietary licences (e.g. Proprietary, LicenseRef-Corporate, or commercial SDKs) without requiring you to enumerate every common open-source licence (MIT, Apache-2.0, etc.).
    # Permit a specific proprietary or internal licence while keeping standard open-source licences allowed
    uv run rhada --project . --allow-extra-licence "Proprietary,LicenseRef-Custom"
    

Declarative Configuration in pyproject.toml

All policy rules and operational defaults can be declared in [tool.rhada]:

[tool.rhada]
# Whitelist internal corporate packages (supports exact names and wildcards)
internal-packages = [
    "mycorp-*",
    "internal-security-sdk",
]

# Completely ignore specific dependencies
ignore-packages = [
    "legacy-stub",
]

# Strict approved licenses for your organisation (closed-world allowlist)
# allowed-licenses = [
#     "MIT",
#     "Apache-2.0",
#     "BSD-3-Clause",
#     "0BSD",
# ]

# Supplemental approved licenses (preserves standard permissive defaults)
extra-allowed-licenses = [
    "Proprietary",
    "LicenseRef-Corporate",
]

# Optional audit enforcement defaults
fail-on-severity = "high"
fail-on-license = "high"
allow-unknown-license = false
verbose = false
offline = false

# Ignore specific vulnerabilities (supports advisory ID, reason, and optional expiry date)
[tool.rhada.ignore-vulnerabilities]
"CVE-2024-99999" = "Non-exploitable in CLI context"
"GHSA-34jh-p97f-mpxf" = { reason = "Awaiting upstream patch", expires = "2026-12-31" }

# Override missing verbatim license texts for packages lacking LICENSE files in their wheels
[tool.rhada.license-files]
"some-legacy-package" = "licenses/legacy-license.txt"

[tool.rhada.license-texts]
"proprietary-sdk" = "Copyright (c) 2026 Acme Corp. All rights reserved."

Ignoring Specific Vulnerabilities (--ignore-vulnerability)

If an upstream dependency has an advisory that is not exploitable in your application or has no patch available yet, ignore specific IDs without disabling checks for the rest of the package:

uv run rhada --project . --ignore-vulnerability "CVE-2024-99999,GHSA-34jh-p97f-mpxf"

Licence Text Overrides (--license-file and [tool.rhada.license-files])

When an open-source wheel omits a verbatim LICENSE file (triggering LIC-MISSING-TEXT), provide a local file or inline text to satisfy attribution requirements:

uv run rhada --project . --license-file "legacy-lib=licenses/legacy-lib.txt"

CLI flags supplement and take precedence over pyproject.toml settings.

For packages governed by the GNU Lesser General Public License (LGPL-2.0, LGPL-2.1, LGPL-3.0), Section 4(d) / Section 6 requires that recipients have access to complete corresponding source code and retain the ability to modify and relink the library:

  • Rhada resolves upstream repository and release source URLs from package Project-URL metadata, PyPI files, or native library registries.
  • Discovered source links are included directly in LIC-LGPL-DYNAMIC and LIC-LGPL-MONOLITHIC compliance findings and embedded into CycloneDX (vcs) and SPDX (downloadLocation) SBOMs.
  • THIRD_PARTY_NOTICES includes a dedicated LGPL Compliance & Source Code Offer section providing exact source code download locations and written offer statements.

5. Distribution File Accounting & Inventory (--verbose / --full)

When auditing a compiled distribution directory (--dist), Rhada performs full file inventory accounting to verify that every distributed file is attributed and accounted for:

  • Application Binaries (application-binary): Main entrypoint executables and first-party compiled modules. First-party packages and submodules (configured in pyproject.toml or discovered in the source tree) are properly recognized as project source rather than flagged as unknown third-party packages.
  • Python Runtime (python-runtime): CPython runtime shared libraries (python313.dll, libpython3.so) and standard library C-extensions (select.pyd, _socket.pyd, etc., licensed under PSF-2.0).
  • Compiler / Platform ABI (compiler-abi): Standard compiler runtimes and platform ABIs (vcruntime140.dll, msvcp140.dll, ucrtbase.dll, libc.so, etc.).
  • Native Shared Libraries (native-library): Discovered or vendored third-party shared libraries (libcrypto, libssl, libopenblas, etc.).
  • Python Packages (python-package): Bundled third-party wheels, bytecode, and extension libraries.
  • Metadata (data-metadata): Compilation reports, license files, notices, SBOMs, and manifest files.
  • Unaccounted Files (unaccounted): Any unrecognized loose file that may require audit or review.

By default, the audit summary reports the overall coverage percentage:

Distribution File Coverage: 100.0% (32/32 files classified: 1 application binary, 25 python runtime, 4 compiler abi, 2 data metadata)

Pass --verbose (or -v, --full) to render the complete line-by-line inventory table detailing the relative file path, category, attributed component, file size, SHA-256 hash, and classification details:

uv run rhada --project . --dist ./dist/my-app.dist --compilation-report ./dist/report.xml --verbose

The complete inventory is also serialized under file_inventory in JSON reports (--format json or --report-json).

6. Subcommands

# Generate SBOM to stdout or file
uv run rhada sbom --project . --format spdx --output sbom.spdx.json

# Generate THIRD_PARTY_NOTICES (plain text or GitHub-flavoured Markdown)
uv run rhada notices --project . --dist ./build/app.dist --output THIRD_PARTY_NOTICES
uv run rhada notices --project . --format markdown --output THIRD_PARTY_NOTICES.md

# Compare two SBOMs or audit reports to inspect dependency, licence, and vulnerability changes
uv run rhada diff base-report.json new-report.json
uv run rhada diff base-sbom.json new-sbom.json --fail-on-new-vuln --fail-on-downgrade

# Inspect ELF binaries and DT_NEEDED linkage directly
uv run rhada inspect-elf ./build/app.dist

CLI Reference

Running rhada [OPTIONS] directly defaults to the audit command.

Global Options

Option Short Description
--version Show program version and exit.
--help -h Show help message and exit.

audit Command Options

Workspace & Distribution Input Options

Option Short Type Default Description
--project -p PATH . Path to the Python or uv project workspace root.
--dist -d PATH None Path to a compiled Nuitka or PyInstaller distribution (directory or monolithic binary).
--compilation-report PATH auto Optional path to a Nuitka compilation-report.xml or report.xml. If omitted, Rhada automatically searches --dist, its parent, and the current working directory.
--include-dev flag false Include development and build dependencies in source audit mode.
--offline flag false Skip online OSV.dev vulnerability queries.

Output & Reporting Options

Option Short Type Default Description
--format table | json table Console output format rendered to standard output.
--report-json -o, --output PATH None Write the complete machine-readable JSON audit report to disk.
--sbom PATH None Write a machine-readable SBOM JSON file to the specified path.
--sbom-format cyclonedx | spdx cyclonedx SBOM standard specification format.
--notices PATH None Write a THIRD_PARTY_NOTICES attribution file to the specified path.
--notices-format text | markdown text Attribution file format (auto-detected if output path ends with .md).
--verbose -v, --full flag false Show detailed distribution file accounting and component mapping breakdown.

Policy & Compliance Options

Option Aliases Type Default Description
--fail-on-severity critical | high | medium | low high Minimum vulnerability severity threshold that triggers a non-zero exit code (1 or 3).
--fail-on-license --fail-on-licence critical | high | medium | low high Minimum licence compliance finding severity that triggers a non-zero exit code (2 or 3).
--fail-on-linkage flag false Fail with exit code 4 if unresolved binary dynamic linkage dependencies (DT_NEEDED) or insecure RPATHs exist.
--allow-unknown-license --allow-unknown-licence flag false Downgrade unknown or unasserted licence findings to LOW severity instead of HIGH.
--allow-license --allow-licence
--allow-licenses
--allow-licences
TEXT (repeatable or comma-separated) None Strict exclusive approved licence allowlist. Any licence not listed is flagged with LIC-POLICY-NOT-ALLOWED.
--allow-extra-license --allow-extra-licence
--allow-extra-licenses
--allow-extra-licences
TEXT (repeatable or comma-separated) None Supplemental approved licences. Permits additional specific licences without enforcing an exclusive allowlist on standard permissive licences.
--deny-license --deny-licence
--deny-licenses
--deny-licences
TEXT (repeatable or comma-separated) None Forbidden SPDX licence IDs. Packages using these licences will generate HIGH severity compliance findings.
--internal-package --internal-packages
--allow-package
--allow-packages
TEXT (repeatable or comma-separated) None Internal package names or wildcards (e.g. 'mycorp-*') to treat as first-party application code.
--ignore-package --ignore-packages TEXT (repeatable or comma-separated) None Package names or wildcards to completely omit from compliance audit and vulnerability scanning.
--ignore-vulnerability --ignore-vulnerabilities TEXT (repeatable or comma-separated) None Advisory or CVE IDs to ignore from failure evaluation (renders as ignored in reports).
--license-file TEXT (repeatable) None Override licence text file for a component in component=path format.

Subcommands Reference

Subcommand Option Short Type Default Description
audit (default) (see above) Full compliance, vulnerability, linkage, and SBOM audit.
sbom --project -p PATH . Project workspace root.
--dist -d PATH None Compiled distribution directory or binary.
--format -f cyclonedx | spdx cyclonedx SBOM specification format.
--output -o PATH stdout Output file path (writes to stdout if omitted).
--offline flag false Skip OSV vulnerability enrichment.
notices --project -p PATH . Project workspace root.
--dist -d PATH None Compiled distribution directory or binary.
--output -o PATH stdout Output file path (writes to stdout if omitted).
--format -f text | markdown text Notices format (auto-detected if output path ends with .md).
diff BASE PATH (arg) (required) Baseline SBOM or report JSON file.
TARGET PATH (arg) (required) Target SBOM or report JSON file to compare against baseline.
--format -f table | json table Console output format.
--fail-on-downgrade flag false Fail with exit code 1 if any dependency version was downgraded.
--fail-on-new-vuln flag false Fail with exit code 1 if any new vulnerability was introduced.
--fail-on-changes flag false Fail with exit code 1 if any dependency, version, or licence changed.
inspect-elf / inspect-binary TARGET PATH (arg) (required) Target ELF/PE binary (.so, .dll, .pyd, .exe) or distribution directory to inspect for dependencies and dynamic linkage.

Exit Codes

Exit Code Enum Name Meaning
0 OK Audit passed all security, licence, and binary linkage policies.
1 VULNERABILITY_FAILURE One or more vulnerabilities met or exceeded --fail-on-severity (default: high).
2 LICENSE_FAILURE One or more licence compliance findings met or exceeded --fail-on-licence / --fail-on-license (default: high).
3 COMBINED_POLICY_FAILURE Both vulnerability and licence compliance thresholds were breached.
4 LINKAGE_FAILURE --fail-on-linkage was set and unbundled external DT_NEEDED libraries or insecure RPATHs were found.
5 USAGE_OR_IO_ERROR Invalid CLI arguments or unreadable target paths.

GitHub Actions CI Example

jobs:
  compliance-and-security-gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v4
      - name: Run Rhada Audit and Generate Release Artefacts
        run: |
          uv run rhada audit \
            --project . \
            --dist ./dist/my-service.dist \
            --sbom ./dist/sbom.cdx.json \
            --notices ./dist/THIRD_PARTY_NOTICES \
            --report-json ./dist/rhada-report.json \
            --fail-on-severity high \
            --fail-on-licence high \
            --fail-on-linkage

Running Tests

uv run pytest -v

Metadata

Release files for rhada 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rhada 0.1.1
File Size Uploaded Provenance Actions
rhada-0.1.1.tar.gz 203.7 kB With provenance Details for rhada-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rhada 0.1.1
File Interpreter ABI Platform Actions
rhada-0.1.1-py3-none-any.whl Python 3 none any Details for rhada-0.1.1-py3-none-any.whl

Total release size: 313.8 kB

Release files / rhada-0.1.1.tar.gz

Download URL rhada-0.1.1.tar.gz
Size 203.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ca8769f147d5ed6ec2b22658f5673925ce0bf5cc70eb5073ac1052981fad05c3
BLAKE2b-256 checksum
How to use checksums
df4c521ec52f9c049c2f1d68496189296332e984c6679fc611e9f7c4cf3d9599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / rhada-0.1.1-py3-none-any.whl

Download URL rhada-0.1.1-py3-none-any.whl
Size 110.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
020bdc59c7fa0ee73e42fcc65afec36f77b02177654d957d09c7394245b405b3
BLAKE2b-256 checksum
How to use checksums
97bfd991f558d85de946832fc92642236ae66c8ca780a45c2e90b0e1a7a5a7dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for rhada 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rhada-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page