Skip to main content

oscal-bindings (Python)

oscal-bindings-specs CI PyPI Python versions License

Typed Python data bindings for OSCAL (Open Security Controls Assessment Language) v1.2.3, generated from the NIST JSON Schema with Pydantic v2.

  • Every OSCAL document type. Catalog, Profile, Component Definition, System Security Plan, Assessment Plan, Assessment Results, Plan of Action and Milestones, and Mapping Collection, each with a typed parser.
  • Strict input. A parse rejects unknown fields, Python field names in place of OSCAL names, and values that break an OSCAL pattern, and reports each failure with its location.
  • Valid OSCAL output. Every serialization path writes OSCAL key names and never writes null.
  • Measured performance. PERFORMANCE.md has the parse, memory, and serialization costs.
  • One runtime dependency. Only pydantic. JSON and YAML input as str, bytes, or a file path, with YAML as an optional extra.
  • Consistent interoperability. The bindings implement the language-neutral OSCAL bindings spec and the tests pass its full conformance corpus.

API reference: https://cairn-proofs.github.io/oscal-bindings-python/

Installation

pip install oscal-bindings

For YAML support, install oscal-bindings[yaml]. Requires Python 3.11+ and Pydantic 2.14.2+. Installation and versions covers uv, local checkouts, and Git installs.

Quick start

Parse a document. Each document type has a typed parser that returns its wrapper (CatalogDocument here); parse_oscal takes any type.

>>> from oscal_bindings import parse_catalog, serialize_oscal, OscalParseError
>>> text = '''{"catalog": {
...   "uuid": "74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724",
...   "metadata": {"title": "Demo catalog", "last-modified": "2026-01-02T03:04:05Z",
...                "version": "1.0", "oscal-version": "1.2.3"},
...   "controls": [{"id": "ac-1", "title": "Policy and Procedures"}]}}'''
>>> doc = parse_catalog(text)

Read it as typed Python objects.

>>> doc.catalog.metadata.title
'Demo catalog'
>>> doc.catalog.controls[0].id
'ac-1'

Serialize it back. Output always uses OSCAL key names and omits unset fields.

>>> doc.catalog.controls[0].model_dump_json()
'{"id":"ac-1","title":"Policy and Procedures"}'
>>> json_text = serialize_oscal(doc)   # the whole document, indented

Reject input that is not valid OSCAL. Here a Python field name stands in for an OSCAL name:

>>> try:
...     parse_catalog(text.replace('"oscal-version"', '"oscal_version"'))
... except OscalParseError as e:
...     for entry in e.errors:
...         print(entry["type"], entry["loc"])
...
missing ('CatalogDocument', 'catalog', 'metadata', 'oscal-version')
extra_forbidden ('CatalogDocument', 'catalog', 'metadata', 'oscal_version')

Highlights

One facade for every document type. OscalDoc gives metadata, uuid, and oscal_version without dispatching on the type (details):

from oscal_bindings import OscalDoc

doc = OscalDoc.from_file("ssp.json")
doc.metadata.title

Back-matter builders validate as they build (details):

from oscal_bindings import make_hash, make_resource, make_rlink

digest = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
resource = make_resource(
    title="Evidence: signed audit report",
    rlinks=[make_rlink("https://example.com/audit-q1.pdf", media_type="application/pdf",
                       hashes=[make_hash(digest)])],
)

YAML works the same way as JSON, with the yaml extra (details):

from oscal_bindings import parse_oscal_yaml_file, serialize_oscal_yaml

doc = parse_oscal_yaml_file("catalog.yaml")
yaml_text = serialize_oscal_yaml(doc)

Datetimes keep every fraction digit. OSCAL allows more than the six that datetime holds; OscalDateTime keeps and writes them all (details).

OSCAL versions

The bindings live in oscal_bindings.v1, named for the OSCAL major version, and the top-level package re-exports it, so from oscal_bindings import parse_oscal and from oscal_bindings.v1 import parse_oscal give the same object. A 1.x schema refresh regenerates v1 in place and never changes your imports. See Installation and versions.

Other Python OSCAL libraries

  • compliance-trestle is a compliance workflow tool: workspaces, document splitting, Markdown authoring, and CI governance, built on its own OSCAL object model. Use it to run an authoring workflow.
  • oscal loads, validates, converts, and queries OSCAL in XML, JSON, and YAML for every published OSCAL version, and resolves profiles and imports. Use it when you need XML, several OSCAL versions at once, or profile resolution.
  • oscal-pydantic-v2 provides Pydantic models for OSCAL. Its latest release covers the Catalog and Profile models, without parse or serialize helpers.

oscal-bindings is the typed data-binding layer for one OSCAL release: Pydantic models for all eight document types that type checkers and IDEs understand, strict parsing that reports each failure with its location, valid OSCAL on every serialization path, and no dependency beyond Pydantic.

Documentation

Project information

License

Apache License 2.0; see LICENSE. The models are generated from the OSCAL JSON Schema of NIST, which is in the public domain; see NOTICE.

Metadata

Release files for oscal-bindings 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 oscal-bindings 0.6.0
File Size Uploaded Provenance Actions
oscal_bindings-0.6.0.tar.gz 486.4 kB With provenance Details for oscal_bindings-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 571.8 kB

Release files / oscal_bindings-0.6.0.tar.gz

Download URL oscal_bindings-0.6.0.tar.gz
Size 486.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bf8cde689a260bbdeca429195ba01c486d5cbf19e6b55eb39c920f723b20e135
BLAKE2b-256 checksum
How to use checksums
f4ac97d96c0363f8918d9d8a8ac8cd88b0d1542307dd95b55db4572ba1b03aab
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 Nov 19, 2026.

Transparency log

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

Download URL oscal_bindings-0.6.0-py3-none-any.whl
Size 85.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4df53e38abdb6d20060f7cf3af3a6fd6d1dad71e59de5aefa819e90a124cdb1d
BLAKE2b-256 checksum
How to use checksums
3c90af1f809f2d7d2db33d080725390b2d94ddb7182a6e9df10bf21a9a653656
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 Nov 19, 2026.

Transparency log

Security for oscal-bindings 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

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

Select from 2 files

Attestation for oscal_bindings-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 Nov 19, 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