A Python library for working with the Open Cybersecurity Schema Framework (OCSF) JSON schema. It provides tools for validating OCSF events, loading schemas, and managing OCSF extensions. The current version is 0.10.4, and it has an active, though irregular, release cadence with significant updates between minor versions.
pip install ocsf-libVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load the OCSF schema and validate an example OCSF event against it. It highlights the primary use case of the `ocsf-lib` for ensuring OCSF event compliance.
Update any code accessing `OCSFExtension` objects to use `extension.caption` instead of `extension.description`.
Convert any existing OCSF extension definition files from YAML to TOML format. The `OCSFExtension.from_file()` method now expects a TOML file.
Update error handling code that catches validation failures. Replace `except OCSFError:` with `except jsonschema.ValidationError:` for schema validation errors. `OCSFError` is still used for other library-specific exceptions.
If your code directly interacts with the Pydantic models generated by `ocsf-lib` (e.g., `OCSFEvent` subclasses or internal schema components), you may need to update your code to be compatible with Pydantic v2 conventions. Refer to Pydantic v2 migration guides.
Ensure network connectivity for initial schema loading. For environments without internet access, pre-populate the schema cache or package the schema files with your application.