Skip to main content

tmxcaliber

tmxcaliber is a command-line toolkit for refining, querying, and transforming TrustOnCloud ThreatModels. It helps engineers work with large model files more efficiently by filtering JSON, exporting threats and controls, mapping control objectives to frameworks, generating DFD artifacts, and comparing model versions without writing custom scripts for each task.

Highlights

  • Filter ThreatModel JSON files by IDs, severity, IAM permissions, and events.
  • List threats, controls, services, and feature classes from a single model or an entire directory.
  • Map control objectives to SCF-supported frameworks or your own custom framework.
  • Write mapping data back into a ThreatModel JSON.
  • Generate threat-focused and feature-class-focused DFD XML and PNG outputs.
  • Create structured change logs in JSON or Markdown.
  • Scan control descriptions with regex patterns or the built-in guardduty_findings alias.

Quickstart

tmxcaliber supports Python 3.10+.

pip install tmxcaliber
tmxcaliber -h

Or run it without installing anything, using uv:

uvx tmxcaliber -h

First commands to try:

tmxcaliber list threats path/to/threatmodel.json
tmxcaliber filter path/to/threatmodel.json --severity high --output filtered.json
tmxcaliber map path/to/threatmodel.json --scf 2025.3.1 --framework-name "NIST CSF v2.0"

Installation

Install from PyPI

The recommended way to get the CLI:

pip install tmxcaliber

Or run it without installing anything, with uv:

uvx tmxcaliber -h

Pin a specific version the usual way:

pip install "tmxcaliber==<version>"

Every merge to main publishes a new version to PyPI automatically, so the latest released code is always there. The Git tags remain the release history and carry the same sdist and wheel as attachments.

Install from source

For contributors, or to work against unreleased changes. This uses uv to build the environment from the committed uv.lock:

git clone https://github.com/trustoncloud/tmxcaliber.git
cd tmxcaliber
uv sync
uv run tmxcaliber -h

If you prefer a manual virtual environment with pip:

python -m venv .venv
# PowerShell
.venv\Scripts\Activate.ps1
# bash / zsh
source .venv/bin/activate

pip install .
tmxcaliber -h

Docker

The repository includes a Dockerfile for containerized use:

docker build -t tmxcaliber .
docker run --rm -it tmxcaliber -h

Requirement note for generate

The generate command depends on drawio. If the binary is not automatically detected, provide it explicitly with --bin.

Working against the TrustOnCloud API

If your organization subscribes to TrustOnCloud, tmxcaliber can read your entitled ThreatModels directly instead of working from files you downloaded.

Set a key

Create a key in the app under Settings, Service API keys, then:

tmxcaliber init

It asks for the key without echoing it, stores it in ~/.trustoncloud/credentials readable only by you, and then calls the API to confirm it works and tell you which tenant it belongs to. Run it again any time to see what is currently set.

If TrustOnCloud has given you a different endpoint, store it with tmxcaliber init --api-url <url>. It is kept until you pass the option again.

In CI, where there is no terminal to prompt, pipe the key in:

echo "$TOC_API_KEY" | tmxcaliber init

A one-off override needs no file at all:

export TOC_API_KEY=toc-tak1-...

TOC_API_URL overrides the endpoint if TrustOnCloud has given you a different one to use. It defaults to https://api.trustoncloud.com.

The environment wins over the file, which is also why there are no profiles: one stored key, and an environment variable for the "a different one, right now" case.

The key and the endpoint are each looked up on their own. If init stored an endpoint other than the default, a key you export in TOC_API_KEY is sent to that stored endpoint unless you also set TOC_API_URL. Commands print a note on stderr when that happens, naming the endpoint and the file it came from.

The key is a TrustOnCloud credential rather than a tmxcaliber one, which is why it is named and stored this way: the same key works with curl or any other client. There is deliberately no --api-key flag, so the secret never lands in your shell history or a CI log.

Two prerequisites that are easy to miss. Your organization must have IP filtering configured, and the address you run from has to be on the allow list: an empty list denies everything, and an IPv6 caller is refused whatever the list says. Until the API is enabled for your organization, every route answers 404, including tmxcaliber me, so "not found" can mean "not enabled" rather than "does not exist".

Use a ThreatModel without downloading it

Anywhere a command takes a file, it also takes a ThreatModel id, optionally pinned to a release:

tmxcaliber list threats aws-s3
tmxcaliber filter aws-s3 --severity high --output filtered.json
tmxcaliber generate aws-s3
tmxcaliber create-change-log aws-s3@1700000000 aws-s3@1611187200

A value that exists on disk is always treated as a path, so nothing you run today changes meaning. Fetched documents are cached under ~/.tmxcaliber/cache; set TMXCALIBER_CACHE_DIR to move it.

That last example is worth noticing: comparing two released versions of the same model needs no local copies of either.

Call the API directly

The commands mirror the API's own routes, so the published reference and the CLI use the same names:

tmxcaliber threatmodels list --provider aws
tmxcaliber threatmodels get aws-s3
tmxcaliber threatmodels threats aws-s3 --feature-class S3.FC1
tmxcaliber threatmodels dfd aws-s3
tmxcaliber subscriptions list
tmxcaliber compliance frameworks list
tmxcaliber compliance mappings list --framework nist-800-53-r5
tmxcaliber ccr packs list

Collections are read in full; paging is handled for you. When the API reports that an answer is incomplete (for example, compliance mappings for ThreatModels whose SCF release is not supported yet), the command still writes what it got, names what is missing on stderr, and exits 3; pass --allow-incomplete to accept a partial answer. For anything these commands do not cover, the API takes the same key directly:

curl -H "Authorization: Bearer $TOC_API_KEY" https://api.trustoncloud.com/v1/apis

A document pulled with your key is licensed to your organization and carries its attribution. It is not a file to redistribute.

Use the API from Python

The same commands are available as a library. Each command becomes a call by turning its spaces into dots: the positional stays positional, and each option becomes a keyword argument.

from tmxcaliber import Client

api = Client()
api.me()
api.threatmodels.list(provider="aws")
api.threatmodels.threats("aws-s3", feature_class="S3.FC1")
api.compliance.mappings.list(framework="nist-800-53-r5")

Client() finds the key and endpoint exactly as the CLI does. To use a key kept somewhere else, pass it: Client(api_key=..., api_url=...). A collection comes back as a list of every row. An incomplete answer raises IncompleteAnswer, which carries the rows that did arrive, unless you pass allow_incomplete=True. Every failure is a RemoteError subclass, such as AuthenticationError or NotFound, importable from tmxcaliber. api.get(path) and api.paginate(path) remain available for a raw path.

Command Overview

Command Purpose Typical output
filter Produce a refined ThreatModel JSON based on filters. JSON
list threats Export threat rows from one model or a directory. CSV
list controls Export control rows from one model or a directory. CSV
list services List service names and their source files. CSV or JSON
list feature-classes Inspect feature classes in a single ThreatModel. CSV or JSON
map Generate a framework mapping from ThreatModel control objectives. CSV or JSON
add-mapping Insert mapping data into the ThreatModel JSON. JSON
scan Find controls whose descriptions match a pattern. JSON
generate Generate XML and PNG DFD artifacts. Files on disk
create-change-log Compare two ThreatModels and summarize differences. JSON or Markdown

Core Workflows

Filter a ThreatModel

Use filter when you want a refined ThreatModel JSON as the output.

tmxcaliber filter path/to/threatmodel.json \
  --severity high \
  --output filtered.json

Create a filtered file and a companion file containing everything removed:

tmxcaliber filter path/to/threatmodel.json \
  --permissions s3:GetObject \
  --output filtered.json \
  --output-removed

Use --exclude to invert an ID-based filter:

tmxcaliber filter path/to/threatmodel.json \
  --ids S3.T12,S3.CO1 \
  --exclude \
  --output filtered.json

List threats and controls

List threats from a single model:

tmxcaliber list threats path/to/threatmodel.json

List only high and very-high severity threats from a directory:

tmxcaliber list threats path/to/threatmodels \
  --severity high \
  --output threats.csv

List controls from a directory:

tmxcaliber list controls path/to/threatmodels --output controls.csv

List only AWS data perimeter controls:

tmxcaliber list controls path/to/threatmodels \
  --type AWS_DATA_PERIMETER \
  --output perimeter_controls.csv

List services across a directory of models:

tmxcaliber list services path/to/threatmodels --format json

List feature classes from a single ThreatModel:

tmxcaliber list feature-classes path/to/threatmodel.json

Map to a supported or custom framework

Generate a mapping to an SCF-supported framework:

tmxcaliber map path/to/threatmodel.json \
  --scf 2025.3.1 \
  --framework-name "ISO 27001 v2013" \
  --format csv

Use the exact framework name from the selected SCF version header when targeting a built-in framework.

Generate a mapping to your own framework using the starter CSVs in template/:

tmxcaliber map path/to/threatmodel.json \
  --scf 2025.3.1 \
  --framework-name "My Framework" \
  --framework-map template/myframework.csv \
  --framework-metadata template/mymetadata.csv \
  --format json

Add mapping data back into a ThreatModel

If you want the mapping persisted directly into the ThreatModel output:

tmxcaliber add-mapping path/to/threatmodel.json \
  --scf 2025.3.1 \
  --framework-name "My Framework" \
  --framework-map template/myframework.csv \
  --framework-metadata template/mymetadata.csv \
  --output enriched-threatmodel.json

Generate DFD artifacts

generate accepts either:

  • a ThreatModel JSON containing base64-encoded XML in dfd.body
  • a raw XML file from the main ThreatModel DFD

Generate XML and PNG outputs from JSON:

tmxcaliber generate path/to/threatmodel.json \
  --threat-dir out/threat-xml \
  --fc-dir out/feature-class-xml \
  --out-dir out/png

Generate from XML with an explicit drawio binary:

tmxcaliber generate path/to/provider_service_DFD.xml \
  --bin "C:\Program Files\draw.io\draw.io.exe" \
  --out-dir out/png

Scan control descriptions

Search control descriptions with a regex:

tmxcaliber scan path/to/threatmodel.json --pattern UnauthorizedAccess

Use the built-in GuardDuty findings alias:

tmxcaliber scan path/to/threatmodel.json --pattern guardduty_findings

Create change logs

Compare two ThreatModel versions and output JSON:

tmxcaliber create-change-log path/to/new_tm.json path/to/old_tm.json

Generate a Markdown report:

tmxcaliber create-change-log path/to/new_tm.json path/to/old_tm.json \
  --format md \
  --output changes.md

You can also scope the comparison to specific IDs and invert the selection with --exclude.

Common Examples

# List all threats across a directory
tmxcaliber list threats path/to/threatmodels

# Keep only specific controls and objectives in a filtered JSON
tmxcaliber filter path/to/threatmodel.json --ids S3.C12,S3.CO5 --output filtered.json

# Exclude known noisy threats from a threat export
tmxcaliber list threats path/to/threatmodel.json --ids S3.T2,S3.T9 --exclude

# Export services for inventory or reporting
tmxcaliber list services path/to/threatmodels --output services.csv

# Produce a custom-framework mapping
tmxcaliber map path/to/threatmodel.json --scf 2025.3.1 --framework-name "My Framework" --framework-map template/myframework.csv

# Create a Markdown change log between releases
tmxcaliber create-change-log new.json old.json --format md --output changes.md

Help Reference

Use the built-in help to inspect the full CLI surface:

tmxcaliber -h
tmxcaliber filter -h
tmxcaliber map -h
tmxcaliber add-mapping -h
tmxcaliber scan -h
tmxcaliber generate -h
tmxcaliber list threats -h
tmxcaliber list controls -h
tmxcaliber list services -h
tmxcaliber list feature-classes -h
tmxcaliber create-change-log -h

Development

Set up a local development environment with dev dependencies (Ruff, mypy, pytest, coverage, pre-commit, and type stubs):

uv sync --extra dev
uv run pre-commit install

Run the test suite:

uv run pytest -q test

Lint, format, and type-check:

uv run ruff format --check .
uv run ruff check .
uv run mypy

Contributing

Contributions are welcome. If you want to improve the CLI, add tests, or extend the documentation, open an issue or submit a pull request with a clear description of the change and its intended user impact.

Metadata

Release files for tmxcaliber 0.6.0

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

Source distribution (sdist)

Source distribution for tmxcaliber 0.6.0
File Size Uploaded Provenance
tmxcaliber-0.6.0.tar.gz 177.3 kB With provenance Details

Built distribution (wheel)

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

Total release size: 304.1 kB

Release files / tmxcaliber-0.6.0.tar.gz

Download URL tmxcaliber-0.6.0.tar.gz
Size 177.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d82628b4f360e32ed47ba4eb13cf56426743902681c288492b0d0c07ac096ae4
BLAKE2b-256 checksum
How to use checksums
ad9fd681f4970b1da953c0453878ae13e0408b57f5577fa3f2c60cdfaab98fea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

Release files / tmxcaliber-0.6.0-py3-none-any.whl

Download URL tmxcaliber-0.6.0-py3-none-any.whl
Size 126.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c22c2a74f8c46fbd3443209d2dd8974f3b32212b6c17cea379dccf34be300b54
BLAKE2b-256 checksum
How to use checksums
45fdc5150b7563da09f7b9df31d541bc078b5b561943c905619d0cc6044be580
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

Security for tmxcaliber 0.6.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tmxcaliber-0.6.0.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 9, 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.

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