ocsf-pydantic provides Pydantic v2 models for the Open Cybersecurity Schema Framework (OCSF). It enables type-safe Python representations of OCSF schemas, facilitating event parsing, validation, and generation in cybersecurity applications. The current version is 0.0.6, and its release cadence is irregular, typically aligned with updates to the OCSF specification or bug fixes.
pip install ocsf-pydanticVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a `FileActivity` OCSF event using the `ocsf-pydantic` models. It populates essential fields like time, correlation ID, file details, and user information, then prints the resulting event in JSON format. It also shows how to access nested fields.
Always review release notes for new versions and test your code against new releases, especially for breaking changes in model fields or required arguments.
Ensure `pydantic` is installed at version 2.x. If you have Pydantic V1 installed, upgrade it (`pip install --upgrade 'pydantic>=2,<3'`) or use a virtual environment.
Trust the default values set by the models for these common event fields. Focus on providing data for the specific fields relevant to your event type. If you need to manipulate common fields, do so carefully after model instantiation, or ensure your data strictly adheres to OCSF enum values.