{ "info": { "author": "David J. Bianco", "author_email": "davidjbianco@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# pycef\nA very simple CEF parser for Python 2/3\n\nI originally wrote this because I wasn't able to find very many good Python CEF parsers out there. I did find [one by Sooshie](https://github.com/sooshie/cef_parser) that got me started (thanks for sharing, sir!), but I elected to produce my own. \n\nThe `parse` function takes a string containing a single CEF record and returns a dict containing the following keys, as defined in the [CEF format documentation](https://www.protect724.hpe.com/docs/DOC-1072):\n\n* CEFVersion\n* DeviceVendor\n* DeviceVersion\n* DeviceEventClassID\n* DeviceName\n* DeviceSeverity\n\nIf there are any `key=value` pairs in the \"extensions\" section (and face it, pretty much every CEF record has these), they'll also be in the dict, with the dict key name the same as the CEF record's key name. If it could not recognize any CEF data, the `parse` function will return `None`.\n\n\n## Example Usage\nParsing a well-formatted CEF record\n\n >>> import pycef\n >>> cef = 'CEF:0|pycef|python CEF tests|1|2|Test event 1|3| field1=value1 field2=value2 field3=value3'\n >>> d = pycef.parse(cef)\n >>> d\n {'DeviceVendor': 'pycef', 'DeviceProduct': 'python CEF tests', 'DeviceVersion': '1', 'DeviceEventClassID': '2', 'DeviceName': 'Test event 1', 'DeviceSeverity': '3', 'CEFVersion': '0', 'field1': 'value1', 'field2': 'value2', 'field3': 'value3'}\n\nParsing a line of CEF from a source with header junk at the front (NOTE: this isn't specific to syslog headers as in the example. The parser just starts wherever 'CEF:0' is found):\n\n >>> import pycef\n >>> cef_syslog = 'Nov 16 21:24:18 arcsightfwd.davidbianco.io CEF:0|pycef|python CEF tests|1|2|Test event 1|3| field1=value1 field2=value2 field3=value3'\n >>> d = pycef.parse(cef_syslog)\n >>> d\n {'DeviceVendor': 'pycef', 'DeviceProduct': 'python CEF tests', 'DeviceVersion': '1', 'DeviceEventClassID': '2', 'DeviceName': 'Test event 1', 'DeviceSeverity': '3', 'CEFVersion': '0', 'field1': 'value1', 'field2': 'value2', 'field3': 'value3'}\n\n## Logging\n`Pycef` uses the standard Python `logging` module. By default, you will not see any logs, but you can easily configure them within your own application. Here's an example:\n\n import logging\n\n # We log with the name 'pycef'\n logger = logging.getLogger('pycef')\n\n # set log level to DEBUG to get the most verbose output\n logger.setLevel(logging.DEBUG)\n\n ch = logging.StreamHandler()\n ch.setLevel(logging.DEBUG)\n formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n ch.setFormatter(formatter)\n logger.addHandler(ch)\n\n # well-formatted CEF data will log the parsed values at DEBUG level\n cef = 'CEF:0|pycef|python CEF tests|1|2|Test event 1|3| field1=value1 field2=value2 field3=value3'\n d = pycef.parse(cef)\n 2018-11-23 08:49:39,827 - pycef - DEBUG - Returning values: {'DeviceVendor': 'pycef', 'DeviceProduct': 'python CEF tests', 'DeviceVersion': '1', 'DeviceEventClassID': '2', 'DeviceName': 'Test event 1', 'DeviceSeverity': '3', 'CEFVersion': '0', 'field1': 'value1', 'field2': 'value2', 'field3': 'value3'}\n\n # Parse errors in the data will log at WARNING level\n pycef.parse('kjlk')\n 2018-11-23 08:47:42,853 - pycef - WARNING - Could not parse record. Is it valid CEF format?\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/DavidJBianco/pycef", "keywords": "cef,parser,CEF", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pycef", "package_url": "https://pypi.org/project/pycef/", "platform": "", "project_url": "https://pypi.org/project/pycef/", "project_urls": { "Homepage": "https://github.com/DavidJBianco/pycef" }, "release_url": "https://pypi.org/project/pycef/1.10/", "requires_dist": [ "future" ], "requires_python": "", "summary": "A very simple CEF parser.", "version": "1.10" }, "last_serial": 4520783, "releases": { "1.10": [ { "comment_text": "", "digests": { "md5": "08022ba7c577b18f3bb6c426d44cfc04", "sha256": "d2819112a818cd45135cde5234a30d36dca2e93a83777f6160ea33a476f56d9b" }, "downloads": -1, "filename": "pycef-1.10-py3-none-any.whl", "has_sig": false, "md5_digest": "08022ba7c577b18f3bb6c426d44cfc04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5087, "upload_time": "2018-11-23T14:19:05", "url": "https://files.pythonhosted.org/packages/d7/58/ba08bdcaf05e0c922a60b22ad1cdf3054a09e53cfd43dd0fa807d2ea4d49/pycef-1.10-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9f3f575dacd7b121742fc108345db840", "sha256": "b61f0da31b3c8c020faeca38522df999f5cfea6fbca443e3860737658c587a49" }, "downloads": -1, "filename": "pycef-1.10.tar.gz", "has_sig": false, "md5_digest": "9f3f575dacd7b121742fc108345db840", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4006, "upload_time": "2018-11-23T14:19:06", "url": "https://files.pythonhosted.org/packages/4a/f4/9ac366a51d4449db3f5fe8f4bdc1c1479f71c835ae3922d9607a68036476/pycef-1.10.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "79028e25014430bc2e391fd8c1e2b19a", "sha256": "864c4a69b23aed1b7be50d4d311e38240c5424c2fdcfef18d8656f5deb62809e" }, "downloads": -1, "filename": "pycef-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "79028e25014430bc2e391fd8c1e2b19a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3485, "upload_time": "2018-09-24T19:19:26", "url": "https://files.pythonhosted.org/packages/cc/a9/93b075e1a7f031ceb13d233308b610ce9c5a2b91fc9f86297829a633ff8e/pycef-1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "05b1902b60a30e430f07291f13d59bae", "sha256": "c6536d72edf7a5f0dee52f305ee13015fcc49efa3fa9e814155cd7f98964f276" }, "downloads": -1, "filename": "pycef-1.2.tar.gz", "has_sig": false, "md5_digest": "05b1902b60a30e430f07291f13d59bae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3217, "upload_time": "2018-09-24T19:19:27", "url": "https://files.pythonhosted.org/packages/5e/36/542a47743584fe8578cfcb5dda9cfe663786c24278cd576946d616e5c96d/pycef-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "08022ba7c577b18f3bb6c426d44cfc04", "sha256": "d2819112a818cd45135cde5234a30d36dca2e93a83777f6160ea33a476f56d9b" }, "downloads": -1, "filename": "pycef-1.10-py3-none-any.whl", "has_sig": false, "md5_digest": "08022ba7c577b18f3bb6c426d44cfc04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5087, "upload_time": "2018-11-23T14:19:05", "url": "https://files.pythonhosted.org/packages/d7/58/ba08bdcaf05e0c922a60b22ad1cdf3054a09e53cfd43dd0fa807d2ea4d49/pycef-1.10-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9f3f575dacd7b121742fc108345db840", "sha256": "b61f0da31b3c8c020faeca38522df999f5cfea6fbca443e3860737658c587a49" }, "downloads": -1, "filename": "pycef-1.10.tar.gz", "has_sig": false, "md5_digest": "9f3f575dacd7b121742fc108345db840", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4006, "upload_time": "2018-11-23T14:19:06", "url": "https://files.pythonhosted.org/packages/4a/f4/9ac366a51d4449db3f5fe8f4bdc1c1479f71c835ae3922d9607a68036476/pycef-1.10.tar.gz" } ] }