Registry / auth-security / py-ocsf-models

py-ocsf-models

JSON →
library0.9.0pypypi✓ verified 86d ago

Python implementation of the OCSF (Open Cybersecurity Schema Framework) models. Provides Pydantic v2-based data models representing OCSF schema objects (e.g., DetectionFinding, ComplianceFinding). Current version 0.9.0, supports Python 3.10–3.14, maintained by Prowler Cloud.

pip install py-ocsf-models
INSTALL
IMPORT
SIG · PY-OCSF-MODELS
P
py-ocsf-models
auth-securitypythonv0.9.0
Install
4.5s avg
Import
1380ms
Disk
45MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.426s · 46.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.5s · import 1.334s · 46MB
45MB installed
● package 45MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DetectionFinding
from py_ocsf_models.events.findings.detection_finding import DetectionFinding
from py_ocsf_models import DetectionFinding
Top-level import may not work; models are under nested modules
ComplianceFinding
from py_ocsf_models.events.findings.compliance_finding import ComplianceFinding
Introduced in 0.5.0

Create a simple DetectionFinding instance and serialize to JSON.

from py_ocsf_models.events.findings.detection_finding import DetectionFinding finding = DetectionFinding( metadata={'product': {'name': 'Test', 'vendor_name': 'Acme'}}, severity='Medium', confidence='High', time=1234567890, type_uid=1 ) print(finding.model_dump(mode='json'))
Debug
Known issues
gotchaPydantic v2 migration: Prior to 0.8.0, models used Pydantic v1. If you have serialized objects with Pydantic v1, they may not deserialize correctly with v2. Use model_validate instead of parse_raw.
fix
Upgrade to >=0.8.0 and use model_validate (v2 style) instead of parse_raw (v1).
affects: <0.8.0
gotchaPython 3.9 support was removed in 0.9.0. Required Python >=3.10 now.
fix
Use Python >=3.10.
affects: >=0.9.0
deprecatedThe product_uid field was removed from DetectionFinding in 0.4.0. Do not rely on it.
fix
Remove product_uid from any model instantiation.
affects: >=0.4.0
Errors
Common errors & fixes
ImportError: cannot import name 'DetectionFinding' from 'py_ocsf_models'
Incorrect import path; symbols are nested under 'events' submodule.
fix
Use: from py_ocsf_models.events.findings.detection_finding import DetectionFinding
pydantic_core._pydantic_core.ValidationError: 1 validation error for DetectionFinding type_uid Field required [type=missing, input_value={...}, input_type=dict]
DetectionFinding requires type_uid field (an integer). Not all OCSF fields are optional; required fields must be provided.
fix
Ensure you pass type_uid, time, metadata, severity, confidence (or adjust to match required fields). Check the model's schema.
Upgrade
Version history
0.9.0latest on PyPI · released Apr 9, 2026
Audit
Dependencies
pydanticrequiredCore dependency for model definitions
cryptographyoptionalUsed for security-related features
Agent activity
23 hits · last 30 days
node
19
OpenAI (training)
1
Resources
py-ocsf-models — pip install py-ocsf-models · libregistry