{"library":"ocsf-pydantic","title":"Pydantic Models for OCSF","description":"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install ocsf-pydantic"],"cli":null},"imports":["from ocsf_pydantic.events.file_activity import FileActivity","from ocsf_pydantic.objects.user import User"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from datetime import datetime, timezone\nfrom ocsf_pydantic.events.file_activity import FileActivity\nfrom ocsf_pydantic.objects.file import File\nfrom ocsf_pydantic.objects.user import User\n\n# Create an OCSF FileActivity event\nfile_activity_event = FileActivity(\n    time=datetime.now(timezone.utc),\n    correlation_uid=\"example-correlation-id-456\",\n    activity_id=1,  # Represents FileActivityId.CREATE\n    file=File(\n        name=\"report.pdf\",\n        path=\"/home/user/documents/report.pdf\",\n        size=10240,\n        hash_md5=\"d41d8cd98f00b204e9800998ecf8427e\"\n    ),\n    user=User(name=\"analyst_user\", uid=\"U007\"),\n    message=\"New report generated by analyst_user\"\n)\n\n# Print the event as JSON\nprint(file_activity_event.model_dump_json(indent=2))\n\n# Access a specific field\nprint(f\"\\nEvent Type Name: {file_activity_event.activity_name}\")\nprint(f\"File Name: {file_activity_event.file.name}\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}