Skip to main content

prototyyppi

Candidate for the next Python reference implementation of CSAF 2.1. Validates CSAF advisory documents against the full three-tier test suite (mandatory, recommended, informative) specified in the CSAF 2.1 standard.

Requires Python 3.11 or later.

Install

pip install prototyyppi

The package name on PyPI is prototyyppi (Finnish: "prototype"). The final stable release will be published as csaf.

Optional extras activate additional subcommands or a faster schema backend:

Extra Installs Enables
tui textual view and edit subcommands — interactive terminal advisory browser and JSON editor
fast-schema jsonschema-rs Compiled JSON Schema backend — typically 10–15× faster schema validation
yaml ruamel.yaml --format yaml output and edit --yaml YAML view mode
pip install 'prototyyppi[tui]'                       # view + edit (advisory browser and JSON editor)
pip install 'prototyyppi[fast-schema]'                # fast schema backend
pip install 'prototyyppi[yaml]'                       # YAML output and edit --yaml view mode
pip install 'prototyyppi[fast-schema,tui,yaml]'       # all extras

Manual

The man page provides the full CLI reference. After installation, place it on your MANPATH:

mkdir -p ~/.local/share/man/man1
cp docs/man/prototyyppi.1 ~/.local/share/man/man1/
man prototyyppi

Quickstart

CLI

Validate a CSAF 2.1 advisory and get a human-readable report:

prototyyppi validate advisory.json
File: advisory.json
Overall: FAIL

  [PASS] schema — JSON Schema (CSAF 2.1)
  [FAIL] 6.1.1 — Missing Definition of Product ID
          /product_tree/product_groups/0/product_ids/0: product id `CSAFPID-9080700` is not defined in product_tree
  [PASS] 6.1.2 — Multiple Definition of Product ID
  …

Exit code is 0 for a valid document, 1 for invalid, 2 for usage errors.

Validation levels — run additional test tiers:

# Basic: schema + mandatory (6.1.x) — default
prototyyppi validate advisory.json

# Extended: + recommended (6.2.x)
prototyyppi validate --level extended advisory.json

# Full: + informative (6.3.x)
prototyyppi validate --level full advisory.json

Output formats:

# TC-compatible JSON (matches the OASIS test-result schema)
prototyyppi validate --format json advisory.json

# SARIF 2.2 (GitHub code scanning, VS Code SARIF viewer)
prototyyppi validate --format sarif advisory.json > results.sarif

# GitHub-flavored markdown — paste directly into a GitHub issue or PR comment
prototyyppi validate --format markdown advisory.json

Batch validation:

# All files in a directory
prototyyppi validate advisories/*.json

# Recursive glob (quote to let Python expand it — avoids shell ARG_MAX limits)
prototyyppi validate 'advisories/**/*.json'

# Batch markdown for a GitHub issue
prototyyppi validate --format markdown 'advisories/*.json'

Rule filtering — suppress or allow-list specific rules:

# Skip by ID or from a YAML file (shown as [SKIP])
prototyyppi validate --skip-rules 6.1.9 advisory.json
prototyyppi validate --skip-rules skip.yaml advisory.json

# Run only specific rules (allowlist; composes with --skip-rules)
prototyyppi validate --only-rules 6.1.1,6.1.2 advisory.json
prototyyppi validate --only-rules rules.yaml advisory.json

Suppress output:

prototyyppi validate --quiet advisory.json    # hide passing rules
prototyyppi validate --silent advisory.json   # exit code only

Performance instrumentation:

# Per-rule timing and peak RSS delta — report to stderr
prototyyppi validate --perf advisory.json

# Save a JSON baseline for later comparison
prototyyppi validate --level full --perf --perf-format json \
    --perf-output baseline.json advisory.json

Exit code is unchanged by --perf. On Windows the RSS delta column shows n/a (the resource module is POSIX-only); wall-clock timing works on all platforms.

Advisory browser (TUI):

# Open an advisory in the interactive terminal browser
prototyyppi view advisory.json

# Multiple files — navigate with arrow keys in the sidebar
prototyyppi view advisories/*.json

# Pipe from the producer API
python build_advisory.py | prototyyppi view

Requires pip install 'prototyyppi[tui]'. Five tabs: Summary (metadata and conformance status), Validation (rule-by-rule table), Dimensions (Appendix C soft-limit report, computed lazily in the background), Document (full structured rendering of the CSAF document), and Log (append-only per-file validation record that persists across rule re-runs). The loading screen streams rule results in real time as validation runs in the background; the advisory view is available immediately once all files finish loading. The theme indicator in the header subtitle (e.g. advisory.json [textual-dark]) updates automatically when the theme is changed via the command palette (Ctrl+P).

JSON editor (TUI):

# Edit a CSAF advisory file
prototyyppi edit advisory.json

# Choose a file from an in-app directory browser
prototyyppi edit

# Pipe from a script (stdin is re-routed so Ctrl+S works)
python draft_advisory.py | prototyyppi edit

Requires pip install 'prototyyppi[tui]'. The editor formats the JSON canonically (2-space indent, POSIX newline) on load. A Fields pane on the right tracks the cursor and shows the CSAF schema field's title, description, type, and all active constraints (enum values, format, pattern, minLength/maxLength, numeric ranges). Key bindings: Ctrl+S save, Ctrl+Q quit (unsaved-changes guard), Ctrl+F toggle / F7 narrow / F8 widen the fields pane, Ctrl+Z undo, Ctrl+R redo, Ctrl+Y copy current field constraints to clipboard, Ctrl+P command palette.

Rule catalog:

prototyyppi info rules                         # full list
prototyyppi info rules --only-groups mandatory # filter by tier
prototyyppi info rules --format json           # machine-readable
Spec   ID         Group           Status           Title
--------------------------------------------------------------------------------
2.1    6.1.1      mandatory       implemented      Missing Definition of Product ID
2.1    6.1.2      mandatory       implemented      Multiple Definition of Product ID
…
61 rule(s) in catalog (CSAF 2.1).

Environment info:

prototyyppi info env                    # CSAF support, catalogs, interpreter, platform
prototyyppi info env --level extended   # + runtime config, paths, host OS identity
prototyyppi info env --level full       # + interpreter detail, flags, CPU, resource usage
prototyyppi info env --format json      # machine-readable

For a condensed single-page reference see the Quickstart guide. For tutorials covering validation and document production see the Tutorial index.

Python API — consumer (validate)

from prototyyppi import validate, validate_file

# From a file path
report = validate_file("advisory.json")

# From an already-parsed dict
import msgspec
doc = msgspec.json.decode(open("advisory.json", "rb").read())
report = validate(doc, path="advisory.json")

print("valid:", report.overall_valid)
for result in report.results:
    if not result.passed:
        print(f"[FAIL] {result.id}{result.title}")
        for err in result.errors:
            print(f"       {err.instance_path}: {err.message}")

The ValidationReport is a frozen msgspec.Struct. Pass it to the formatters to render as text, JSON, SARIF, or markdown:

from prototyyppi import to_text, to_tc_json, to_sarif, to_markdown

print(to_text(report))
print(to_tc_json(report))
print(to_sarif(report, version='0.0.0'))
print(to_markdown(report))

Python API — producer (build)

Construct a typed document and call build() to get validated JSON:

from prototyyppi import (
    Document, Distribution, FullProductName, Note, Publisher, ProductStatus,
    ProductTree, Revision, Tlp, Tracking, Vulnerability,
    Metric, MetricContent, cvss31_from_vector, cwe_entry,
)

doc = Document(
    category='csaf_security_advisory',
    title='Acme Corp — Advisory 2026-001',
    publisher=Publisher(category='vendor', name='Acme Corp',
                        namespace='https://acme.example.com'),
    tracking=Tracking(
        id='ACME-2026-SA-001', status='final', version='1',
        initial_release_date='2026-01-15T10:00:00Z',
        current_release_date='2026-01-15T10:00:00Z',
        revision_history=[Revision(date='2026-01-15T10:00:00Z', number='1',
                                   summary='Initial release.')],
    ),
    distribution=Distribution(tlp=Tlp(label='CLEAR')),
    product_tree=ProductTree(full_product_names=[
        FullProductName(name='Widget 1.0', product_id='CSAFPID-W100'),
    ]),
    vulnerabilities=[
        Vulnerability(
            cve='CVE-2026-10001',
            cwes=[cwe_entry('CWE-122')],
            notes=[Note(category='description', text='Heap overflow in widget parser.')],
            product_status=ProductStatus(known_affected=['CSAFPID-W100']),
            metrics=[Metric(
                content=MetricContent(
                    cvss_v3=cvss31_from_vector(
                        'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'
                    ),
                ),
                products=['CSAFPID-W100'],
            )],
        ),
    ],
)

json_str, report = doc.build()   # raises BuildError on structural violations
assert report.overall_valid
import pathlib
pathlib.Path('advisory.json').write_text(json_str, encoding='utf-8')

build() validates the document and returns (json_str, ValidationReport). The JSON output has sorted keys, two-space indentation, and an auto-injected generator block. See the producer tutorial for step-by-step coverage of all five profiles, CVSS helpers, and build modes.

URL reachability cache

Rules 6.3.06 and 6.3.07 check that URLs in advisory documents resolve to live endpoints. Because HTTP requests are slow and advisory corpora can be large, the validator provides a four-mode URL cache:

Mode Behaviour When to use
run In-memory dedup within the current invocation Default; interactive use
disk Persist results to disk with a configurable TTL CI pipelines
disk-ro Read disk cache; skip on cache miss (no network) Air-gapped or offline builds
none No caching; each URL is checked fresh every run Debugging
# Default: in-memory dedup (no flags needed)
prototyyppi validate --level full advisory.json

# Disk cache with default TTL (24h) and default directory (~/.cache/prototyyppi)
prototyyppi validate --level full --url-cache disk advisory.json

# Custom TTL and cache directory
prototyyppi validate --level full \
    --url-cache disk \
    --url-cache-ttl 7d \
    --url-cache-dir /var/cache/prototyyppi \
    advisory.json

# Read-only: use cache, skip URL rules on miss (no network calls)
prototyyppi validate --level full --url-cache disk-ro advisory.json

# Disable URL rules entirely (shown as [SKIP]; implies --skip-rules 6.3.06,6.3.07)
prototyyppi validate --level full --no-network advisory.json

TTL accepts: 30m, 6h, 7d (minutes, hours, days). The disk cache is stored as a JSON file; entries expire individually based on their write time.

Recommended CI pattern:

prototyyppi validate \
    --level full \
    --url-cache disk \
    --url-cache-dir .cache/prototyyppi \
    --url-cache-ttl 24h \
    'advisories/**/*.json'

Document dimension report (doc-stats)

The doc-stats subcommand measures advisory documents against the informative soft limits defined in Appendix C of the CSAF 2.1 specification — file size (§C.1), array lengths (§C.2), and string lengths (§C.3). It does not perform conformance validation.

Each dimension is rated ok (at or below the caution threshold), caution (above threshold but within the limit), or exceeds (above the limit). The overall posture is the worst-case rating across all dimensions.

# Single file — human-readable text
prototyyppi doc-stats advisory.json

# Structured output
prototyyppi doc-stats --format json advisory.json
prototyyppi doc-stats --format yaml advisory.json

# SARIF 2.2 — for GitHub code scanning or VS Code SARIF viewer
prototyyppi doc-stats --format sarif 'advisories/**/*.json' > doc-stats.sarif

# Batch — text report with grand total footer
prototyyppi doc-stats 'advisories/**/*.json'

Adjusting the caution threshold:

# Rate a dimension caution when it exceeds 75% of the limit (default: 50%)
prototyyppi doc-stats --caution-fraction 0.75 advisory.json

Selecting the taxonomy version:

# v21 (default) or its alias v21csd02
prototyyppi doc-stats --spec-version v21csd02 advisory.json

Exit codes: 0 (all ok or caution), 1 (any exceeds, or a file could not be read), 2 (usage error).

The four official OASIS Appendix examples (example/appendix/) all pass at ok posture. See example/README.md for the full per-file dimension reports.

Single-pass combined conformance + dimension report:

--with-doc-stats on validate runs both pipelines on the same decoded document — no second parse. The dimension block is appended to each file's conformance output.

# Single file: conformance + dimensions in one invocation
prototyyppi validate --with-doc-stats advisory.json

# Also fail on any exceeds posture (default: dimension posture does not affect exit code)
prototyyppi validate --with-doc-stats --doc-stats-exit advisory.json

# Machine-readable output with embedded doc_stats key
prototyyppi validate --format json --with-doc-stats advisory.json

# SARIF with two runs per file (validation run + doc-stats run)
prototyyppi validate --format sarif --with-doc-stats advisory.json

Skip rules

Rules can be suppressed individually or via a YAML skip file. Suppressed rules appear as [SKIP] in the output and do not affect the exit code.

CSV on the command line:

prototyyppi validate --skip-rules 6.1.9,6.2.39.02 advisory.json

# May be specified multiple times (processed left to right)
prototyyppi validate --skip-rules 6.1.9 --skip-rules 6.2.39.02 advisory.json

Re-enable a rule skipped by a previous argument or file (prefix with +):

prototyyppi validate --skip-rules base.yaml --skip-rules +6.1.9 advisory.json

YAML skip file — supports structured entries with reason and expiry:

# skip.yaml
- "schema"
- id: "6.1.9"
  reason: "CVSS v3 scorer deviation  under review"
  expires: "2026-12-31"
prototyyppi validate --skip-rules skip.yaml advisory.json

Expired entries still take effect; the validator prints a warning to stderr.

Official examples

The example/ directory contains official OASIS CSAF 2.1 advisory examples from the CSAF TC repository: six general advisories, four Appendix normative examples (Collapsing Product Paths, examples 11–14), and thirteen VEX use-case documents.

See example/README.md for per-example validation reports and notes on findings.

To refresh the examples from upstream:

python bin/sync_examples.py           # download/update all files
python bin/sync_examples.py --show    # list bundled files and sizes
python bin/sync_examples.py --dry-run # compare with upstream without writing

Bundled catalogs

All external reference data is bundled and kept up to date within the package. No network access is required for validation.

Catalog Bundled version Sync script
CWE v4.9–v4.13 (969 weaknesses) python bin/sync_cwe.py
SPDX 3.28.0 + ScanCode licensedb python bin/sync_spdx.py
SSVC format_version 3 python bin/sync_ssvc.py
CSAF translations v2.1 (de) python bin/sync_translations.py

Life Cycle Management

Four categories of data bundled in the package require periodic maintenance.

Category Location Update trigger
TC fixture data csaf/v21/data/ New TC test suite release
Spec schema files csaf/v21/schema/ Schema normative change
Reference catalogs csaf/v21/{cwe,spdx,ssvc,translations}/ Upstream version release
Official examples example/ New CSAF TC release (main, appendix, or VEX)

TC fixture data

The test suite reads fixture files from prototyyppi/csaf/v21/data/{mandatory,recommended,informative}/. These are a snapshot of the OASIS CSAF TC test suite and require a sibling checkout of the TC repository to refresh.

make sync-fixtures csaf_tc_root=../csaf-2.1   # default: csaf_tc_root=../csaf-2.1

After syncing, run the test suite to confirm all fixture-driven tests still pass:

python -m pytest test/ -q

New fixtures for rules that were previously not_implemented will cause new tests to be collected; updated fixtures may change pass/fail counts. Investigate any unexpected failures before committing.

Once the test suite is green, stage and commit the changed files:

fossil add prototyyppi/csaf/v21/data/
fossil commit -m "sync: TC fixture data YYYY-MM-DD"

CWE catalog

The CWE catalog at prototyyppi/csaf/v21/cwe/catalog.json is built from MITRE's XML distribution. Download the desired CWE versions and run:

python bin/sync_cwe.py --latest-version 4.13 \
    cwec_v4.9.xml cwec_v4.10.xml cwec_v4.13.xml cwec_v4.14.xml cwec_v4.20.xml

The script reads only local XML files; no network access is required. --latest-version sets the version marker used by rule 6.2.24 (defaults to the highest version found in the supplied files when omitted).

SPDX license catalog

The SPDX catalog at prototyyppi/csaf/v21/spdx/catalog.json combines the SPDX license list with the ScanCode license database.

Network (default):

python bin/sync_spdx.py

Air-gapped — supply locally downloaded source files:

python bin/sync_spdx.py \
    --spdx-licenses licenses.json \
    --spdx-exceptions exceptions.json \
    --scancode scancode-index.json

Download sources from the SPDX license list JSON API and the ScanCode licensedb index.

SSVC decision point catalog

The SSVC catalog at prototyyppi/csaf/v21/ssvc/catalog.json is built from the CERTCC/SSVC repository.

python bin/sync_ssvc.py --sync ssvc --sync cvss   # sync both namespaces
python bin/sync_ssvc.py --show                    # print current catalog
python bin/sync_ssvc.py --namespace ssvc --key A --latest-version 3.0.0  # manual override

Syncing requires network access to the GitHub Contents API. For air-gapped environments, review the upstream repository offline and apply changes with --namespace / --key / --latest-version.

CSAF translations catalog

The translations catalog at prototyyppi/csaf/v21/translations/translations.json is maintained by the OASIS CSAF TC.

python bin/sync_translations.py             # fetch and write
python bin/sync_translations.py --show      # print current catalog
python bin/sync_translations.py --dry-run   # compare with upstream without writing

OASIS examples

The official OASIS CSAF 2.1 examples are bundled in example/ (main advisories), example/appendix/ (Appendix normative examples), and example/csaf_vex/ (VEX use cases). All three groups are refreshed via bin/sync_examples.py.

python bin/sync_examples.py             # download/refresh all groups
python bin/sync_examples.py --show      # print bundled filenames and sizes
python bin/sync_examples.py --dry-run   # compare with upstream without writing
python bin/sync_examples.py --no-appendix  # skip appendix/ group
python bin/sync_examples.py --no-vex       # skip csaf_vex/ group

After syncing, stage and commit the changed files:

fossil add example/
fossil commit -m "sync: OASIS CSAF examples YYYY-MM-DD"

Adding a new bundled catalog

To add a new reference catalog following the established pattern:

  1. Create bin/sync_<name>.py with network and (where possible) air-gap modes.
  2. Create prototyyppi/csaf/v21/<name>/ and add the generated JSON file.
  3. Add package-data globs to pyproject.toml.
  4. Add an lru_cache loader in prototyyppi/csaf/v21/rules/_shared.py.
  5. Add a section provider in prototyyppi/_env.py for info env output.
  6. Add the catalog to the "Bundled catalogs" table in this README.

Fuzzing

Coverage-guided fuzz testing uses AFL via python-afl. Seven harnesses cover the parser and filter functions with the highest attack surface.

Target Harness Functions covered
cvss-vector fuzz/fuzz_cvss_vector.py _parse_cvss_vector, _cvss2/3/4_base_score
vers fuzz/fuzz_vers.py _parse_vls, _get_vers_pairs
purl fuzz/fuzz_purl.py _validate_purl, _purl_base, _purl_version
spdx-expr fuzz/fuzz_spdx_expr.py _parse_spdx_expression
only-groups fuzz/fuzz_only_groups.py _filter_by_groups
skip-rules fuzz/fuzz_skip_rules.py _build_skip_rules (CSV branch)
ttl fuzz/fuzz_ttl.py _parse_ttl

Prerequisites: afl-fuzz and python-afl must be installed and on PATH. On macOS with pyenv, ensure the virtualenv is active so PYTHON_BIN resolves to the real interpreter (not the pyenv shim).

# Run all targets sequentially (default: 60 s each)
make fuzz

# Run a single target
make fuzz-ttl

# Adjust the time budget
make fuzz-cvss-vector fuzz_time=300

# After a run, promote AFL-discovered queue entries into the seed corpus
make fuzz-update-seeds
# Review fuzz/seeds/ and commit any valuable new seeds

Crash and hang findings land in fuzz/findings/<target>/. The seed corpus lives in fuzz/seeds/<target>/. Each target's seed directory contains at least one valid, non-crashing input so AFL can establish a baseline before mutation begins.

Design and requirements

Document Identifier File
Software Requirements Specification PRO-SRS-001 docs/requirements/srs/
Software Design Description PRO-SDD-001 docs/design/sdd/

Both documents follow the MIL-STD-498 DID structure and are rendered into the documentation site alongside the quickstart, tutorial, and example gallery.

Bug Tracker

Feature requests and bug reports go to the todos of prototyyppi.

Primary Source repository

The main source of prototyyppi is on a mountain in Central Switzerland under configuration control (fossil).

Contributions

To share small changes under the repository's license, kindly send a patchset per email using git send-email.

Support

Submit issues at https://todo.sr.ht/~sthagen/prototyyppi or write plain text email to ~sthagen/prototyyppi@lists.sr.ht.

Security Policy

See SECURITY.md for the security policy.

Changes

See docs/releases/ for release summaries and docs/releases/changes/ for the detailed change log.

Coverage

The test suite maintains high branch coverage (≥99%). The HTML report (if generated) is in site/coverage/.

SBOM

Runtime dependency information is published in docs/sbom/ in SPDX 3.0 (JSON-LD) and CycloneDX 1.6 (JSON) formats. See docs/sbom/README.md for the component inventory and validation guide.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prototyyppi-2026.8.3.tar.gz (402.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prototyyppi-2026.8.3-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file prototyyppi-2026.8.3.tar.gz.

File metadata

  • Download URL: prototyyppi-2026.8.3.tar.gz
  • Upload date:
  • Size: 402.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for prototyyppi-2026.8.3.tar.gz
Algorithm Hash digest
SHA256 a5689a0c30192668a8e7721a4226fb59520a67ad2ca2f076a91a25f43eb36ee5
MD5 9b0dcdd5a87be14811ecf32e2a7c0aad
BLAKE2b-256 541b11b89fdb2cdf43794d7d2f483d368b79f719e117fc8b6e7c2a45cf8201c4

See more details on using hashes here.

File details

Details for the file prototyyppi-2026.8.3-py3-none-any.whl.

File metadata

  • Download URL: prototyyppi-2026.8.3-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for prototyyppi-2026.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1c8186a0920feb2d49e1d3a060c51b2671c0e7298db861319e5457ce5d5a6c4e
MD5 19976d1f2e9c77a8bc5a1743c6e6b94b
BLAKE2b-256 1cd2c74ae70bfaecf1485f5370074fd41956f71698a07684c22d84b96578289b

See more details on using hashes here.

Release history Release notifications | RSS feed

2026.9.6

2 files

2026.8.31

2 files

2026.8.30

2 files

2026.8.26

2 files

2026.8.23

2 files

2026.8.22

2 files

2026.8.21

2 files

2026.8.20

2 files

2026.8.19

2 files

2026.8.16

2 files

2026.8.10

2 files

2026.8.9

2 files

2026.8.8

2 files

2026.8.6

2 files

2026.8.4

2 files

This release

2026.8.3 This release

2 files

2026.8.2

2 files

2026.8.1

2 files

2026.7.31

2 files

2026.7.30

2 files

2026.7.29

2 files

2026.7.28

2 files

2026.7.27

2 files

2026.7.26

2 files

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