{"id":8471,"library":"pycadf","title":"PyCADF Library","description":"The pycadf library provides an auditing data model based on the Cloud Auditing Data Federation (CADF) specification. It is primarily used within the OpenStack ecosystem to establish strict expectations for auditors regarding audit notifications and event structures. The library is actively maintained by the OpenStack project and is currently at version 4.0.1.","status":"active","version":"4.0.1","language":"python","source_language":"en","source_url":"https://github.com/openstack/pycadf","tags":["auditing","cloud","openstack","cadf","security","compliance"],"install":[{"cmd":"pip install pycadf","lang":"bash","label":"Install PyPI package"}],"dependencies":[{"reason":"Configuration management for OpenStack projects.","package":"oslo.config","optional":false},{"reason":"Serialization utilities for OpenStack projects.","package":"oslo.serialization","optional":false},{"reason":"PBR (Python Build Reasonableness) is an OpenStack project that provides a common build system.","package":"pbr","optional":false}],"imports":[{"wrong":"from pycadf import Event","symbol":"Event","correct":"from pycadf import Event"}],"quickstart":{"code":"import json\nfrom pycadf.events import Event\nfrom pycadf.resource import Resource\nfrom pycadf.cadftype import CADF_VERSION_1_0_0\n\n# Define initiator resource\ninitiator = Resource(\n    typeURI=CADF_VERSION_1_0_0 + 'security/account/user',\n    id='example-user-id',\n    name='example_auditor',\n    domainId='example-domain'\n)\n\n# Define target resource\ntarget = Resource(\n    typeURI=CADF_VERSION_1_0_0 + 'compute/instance',\n    id='example-instance-id',\n    name='my_vm',\n    host=Resource(\n        typeURI=CADF_VERSION_1_0_0 + 'compute/host',\n        id='example-host-id',\n        name='compute-host-1'\n    )\n)\n\n# Create a CADF event\nevent = Event(\n    eventType='activity',\n    outcome='success',\n    action='create',\n    initiator=initiator,\n    target=target,\n    eventTime='2026-04-16T15:00:00.000Z', # ISO 8601 format\n    id='example-event-id'\n)\n\n# Serialize the event to a dictionary and print as JSON\nprint(json.dumps(event.as_dict(), indent=2))","lang":"python","description":"This quickstart demonstrates how to create a basic CADF audit event by defining an initiator (user), a target (VM instance), and then constructing an Event object. The event is then serialized to a JSON string for auditing purposes."},"warnings":[{"fix":"Upgrade your Python environment to version 3.9 or higher. The officially supported minimum is Python 3.9.","message":"PyCADF version 4.0.0 and later no longer support Python 3.8. Users on Python 3.8 will encounter installation or runtime errors.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure that if you have specific versioning requirements for 'oslo' libraries in your project, they are compatible with the versions required by pycadf.","message":"As an OpenStack project, pycadf relies on common OpenStack libraries (oslo.config, oslo.serialization). While these are installed as dependencies, be aware of their presence if integrating pycadf into non-OpenStack environments.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'4.0.1':54 'activ':43 'audit':8,15,35,55 'auditor':33 'base':11 'cadf':18,58 'cloud':14,56 'complianc':60 'current':51 'data':9,16 'ecosystem':27 'establish':29 'event':38 'expect':31 'feder':17 'librari':2,5,41 'maintain':44 'model':10 'notif':36 'openstack':26,47,57 'primarili':22 'project':48 'provid':6 'pycadf':1,4 'regard':34 'secur':59 'specif':19 'strict':30 'structur':39 'use':23 'version':53 'within':24","created_at":"2026-04-16T17:02:21.390802+00:00","updated_at":"2026-04-16T17:02:21.390802+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'Event' from 'pycadf' (/tmp/tmpz1ne4km4/venv/lib/python3.12/site-packages/pycadf/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://docs.openstack.org/pycadf/latest/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pycadf/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","observability","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}