class msiempy.AlarmManager(FilteredQueryList): (source)
List-Like object. Interface to query and manage alarms.
Print all unacknowledged alarms filtered by alarm name and event message, then acknowledge the alarms. Filter with alarm match 'Test alarm' and triggering event message match 'Wordpress'.
from msiempy import AlarmManager, Alarm # Make an alarm query alarms=AlarmManager( time_range='CURRENT_YEAR', status_filter='unacknowledged', # passed to alarmGetTriggeredAlarms filters=[('alarmName', 'Test alarm')], # Regex event_filters=[('ruleName','Wordpress')], # Regex page_size=5 # Should be increased to 500 or 1000 once finish testing for better performance. ) # Load the data into the list alarms.load_data() # Print results print("Alarm list: ") print(alarms) print(alarms.get_text( fields=['id','triggeredDate','acknowledgedDate', 'alarmName', 'acknowledgedUsername'])) # Acknowledge alarms print("Acknowledge alarms") for alarm in alarms: alarm.acknowledge()
AlarmManager
filtering feature is an addon to what the SIEM API offers, filters are applied locally as regular expressions.Alarm
Method | __init__ | Create a new alarm query |
Instance Variable | status_filter | Status filter for the alarm query. |
Instance Variable | page_size | Maximum number of alarms per query |
Method | event_filters | Undocumented |
Method | add_filter | Add a filter to the alarm query. |
Method | add_event_filter | Add a event filter to the query. |
Method | clear_filters | Reset local alarm and event filters. |
Method | load_data | Load the data into the list. Default behaviour will load all alarms informations. Meaning that foreach alarms, the full details is loaded, then the trigerring event details is loaded. |
Instance Variable | data | Undocumented |
Instance Variable | _alarm_filters | Undocumented |
Instance Variable | _event_filters | Undocumented |
Instance Variable | _status_filter | Undocumented |
Method | _get_filters | The alarm related filters |
Method | _get_status_filter | Undocumented |
Method | _set_status_filter | Undocumented |
Method | _qry_load_data | No summary |
Method | _alarm_match | Internal filter method that is going to return True if the passed alarm match all alarm related filters. |
Method | _event_match | Internal filter method that is going to return True if any triggering event match all passed event filters. |
Inherited from FilteredQueryList:
Instance Variable | not_completed | Boolean signals the query is not completed |
Instance Variable | filters | Query filters |
Instance Variable | start_time | Start time of the query in the right SIEM format. |
Instance Variable | end_time | End time of the query in the right SIEM format. |
Instance Variable | time_range | Query time range. Defaults to "CURRENT_DAY". |
Class Variable | DEFAULT_TIME_RANGE | Default time range : "CURRENT_DAY" |
Class Variable | POSSIBLE_TIME_RANGE | No summary |
Instance Variable | _time_range | Undocumented |
Instance Variable | _start_time | Undocumented |
Instance Variable | _end_time | Undocumented |
Method | _get_time_range | Undocumented |
Method | _set_time_range | Undocumented |
Method | _get_start_time | Undocumented |
Method | _set_start_time | Undocumented |
Method | _get_end_time | Undocumented |
Method | _set_end_time | Undocumented |
Method | _set_filters | Undocumented |
Inherited from NitroList (via FilteredQueryList):
Method | __str__ | str(obj) -> return text string. |
Method | keys | List items keys. Every items should have the same set of keys. |
Method | get_text | Return a csv or table string representation of the list |
Method | text | Defaut table string, a shorcut to get_text() with no arguments. |
Method | json | JSON list of dicts representing the list. |
Method | search | Search elements in the list with a regex pattern |
Method | refresh | Execute refresh function on all items. |
Method | perform | Wrapper to execute a function on the list of elements |
Static Method | _confirm_func | Ask user inut to confirm the calling of func on elements . |
Inherited from NitroObject (via FilteredQueryList, NitroList):
Class | NitroJSONEncoder | Custom JSON encoder that will use the approprtiate propertie depending of the type of NitroObject. TODO support json json dumping of QueryFilers, may be by making them inherits from NitroDict. |
Instance Variable | nitro | msiempy.core.session.NitroSession object. Interface to the SIEM. |
Create a new alarm query
status_filter
(str
): status of the alarms to query. status_filter
is not a filter like other cause it's computed on the SIEM side.None
(Default value = "").page_size
(int
): max number of rows per query.filters
(list[tuple(field, [values])]
): Filters applied to Alarm
objects. A single tuple
is also accepted.event_filters
(list[tuple(field, [values])]
): Filters applied to Event
objects. A single tuple
is also accepted.time_range
(str
): Query time range. String representation of a time range.start_time
(str
or a datetime
): Query start timeend_time
(str
or a datetime
): Query end timeEventManager
, filters
and event_filters
** are computed after the data loaded with regex matching.**Status filter for the alarm query.
Add a filter to the alarm query.
Some event related filters can be added with this method. See Alarm.ALARM_EVENT_FILTER_FIELDS
.
Arguments :
afilter
: Can be a a tuple (field, [values])
or (field, value)
or str
'field=value'Filters format is tuple(field, [values])
.
Add a event filter to the query.
afilter
: Can be a a tuple(field, [values])
or tuple(field, value)
or str
like 'field=value'.Load the data into the list. Default behaviour will load all alarms informations. Meaning that foreach alarms, the full details is loaded, then the trigerring event details is loaded.
events_details
(bool
): Load detailed events infos. (Default value = True
). If False
, no detailed events
will be loaded. Only str
representation for SIEM 10.x and minimal events records from SIEM 11.x.alarms_details
(bool
): Load detailed alarms infos. (Default value = True
). If False
, only return alarmGetTriggeredAlarms infos, no information on trigerring events at all is present.pages
(int
): Number of pages to load. (Default value = 1)workers
(int
): Number of asynchronous workers. (Default value = 10)extra_fields
(list[str]
): Applicable if use_query=True. Additionnal event fields to load in the query. See : msiempy.event.EventManager
msiempy.alarm.AlarmManager
workers
: Number of asynchronous workersalarms_details
: Load detailed alarms infos. If False
, only a couple values are loaded, no events
infos.events_details
: Load detailed events infos. If False
, no detailed events
will be loaded only str
representation.use_query
: Uses the query module to retreive event data. Only works with SIEM v11.2.1 or greater.extra_fields
: Only when use_query=True
. Additionnal event fields to load in the query. See : msiempy.event.EventManager
page_number
: Page number, default to 1. Do not touch if you're using pages
parameterReturns : tuple
: ( Results : list
, Status of the query : completed
)