Utilities to extract and record Code42 security events
Project description
c42eventextractor - Utilities to extract and record Code42 security events
The c42eventextractor
package provides modules that assist in the retrieval and logging of Code42 security events.
This is done by exposing handlers that allow developers to supply custom behaviors to occur when events are retrieved.
By default, the extractors will simply print their results to stdout, but these handlers can be extended to allow developers
to record the event info to whatever location or format they desire.
Requirements
- Python 2.7.x or 3.5.0+
- Code42 Server 6.8.x+
Installation
Once you've done that, install c42eventextractor
using:
$ python setup.py install
Usage - AED
To get all security events within the last default look-back days (60 days):
from c42eventextractor.extractors import FileEventExtractor
from c42eventextractor import FileEventHandlers
from py42.sdk import SDK
code42 = SDK.create_using_local_account(
"https://example.authority.com",
"admin@example.com",
"password",
)
handlers = FileEventHandlers()
# Add implementations for customizing handling response and getting/setting insertion timestamp cursors:
def handle_response(response):
pass
def record_cursor_position(cursor):
pass
def get_cursor_position():
pass
handlers.handle_response = handle_response
handlers.record_cursor_position = record_cursor_position
handlers.get_cursor_position = get_cursor_position
extractor = FileEventExtractor(code42, handlers)
extractor.extract()
# To get all security events in a particular time range, provide an EventTimestamp filter.
# Note that if you use `record_cursor_position`, your event timestamp filter may not apply.
from py42.sdk.file_event_query.event_query import EventTimestamp
time_filter = EventTimestamp.in_range(1564694804, 1564699999)
extractor.extract(1564694804)
extractor.extract(None, time_filter)
# Pass in an iterable to specify the exposure types you seek.
# Choices are "SharedViaLink", "SharedToDomain", "ApplicationRead", "CloudStorage", "RemovableMedia", and "IsPublic".
extractor.extract(exposure_types=["CloudStorage", "RemovableMedia"])
c42eventextractor
provides some common logging and formatting implementations that you may find useful for reporting on this data.
For example, to submit each event to a syslog server in CEF format, try using the below as your handle_response
implementation:
import json
import logging
from c42eventextractor.logging.handlers import NoPrioritySysLogHandler
from c42eventextractor.logging.formatters import FileEventDictToCEFFormatter
my_logger = logging.getLogger("MY_LOGGER")
handler = NoPrioritySysLogHandler("examplehostname.com")
handler.setFormatter((FileEventDictToCEFFormatter()))
my_logger.addHandler(handler)
my_logger.setLevel(logging.INFO)
def handle_response(response):
events = json.loads(response.text)["fileEvents"]
for event in events:
my_logger.info(event)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for c42eventextractor-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6b1e0524dbfd7634caf845e99cf9232bca341236ee800e84313d03449088058 |
|
MD5 | fe44e577f28995fcae757a1656700fec |
|
BLAKE2b-256 | 6adaa8ef2e9baae6d260652aa0a3aad1297721385025c673cd0fdbf96a8e5f53 |