mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
intel: Add indicator_inserted and indicator_removed hooks
This change adds two new hooks to the Intel framework that can be used to intercept added and removed indicators and their type. These hooks are fairly low-level. One immediate use-case is to count the number of indicators loaded per Intel::Type and enable and disable the corresponding event groups of the intel/seen scripts. I attempted to gauge the overhead and while it's definitely there, loading a file with ~500k DOMAIN entries takes somewhere around ~0.5 seconds hooks when populated via the min_data_store store mechanism. While that doesn't sound great, it actually takes the manager on my system 2.5 seconds to serialize and Cluster::publish() the min_data_store alone and its doing that serially for every active worker. Mostly to say that the bigger overhead in that area on the manager doing redundant work per worker. Co-authored-by: Mohan Dhawan <mohan@corelight.com> (cherry picked from commit 3366d81e98ef381d843f6d76628834fdcd622e25)
This commit is contained in:
parent
a444a9cc4a
commit
0e191b25fe
18 changed files with 601 additions and 1 deletions
|
@ -96,10 +96,30 @@ event Intel::insert_indicator(item: Intel::Item) &priority=5
|
|||
Intel::_insert(item, F);
|
||||
}
|
||||
|
||||
function invoke_indicator_hook(store: MinDataStore, h: hook(v: string, t: Intel::Type))
|
||||
{
|
||||
for ( a in store$host_data )
|
||||
hook h(cat(a), Intel::ADDR);
|
||||
|
||||
for ( sn in store$subnet_data)
|
||||
hook h(cat(sn), Intel::SUBNET);
|
||||
|
||||
for ( [indicator_value, indicator_type] in store$string_data )
|
||||
hook h(indicator_value, indicator_type);
|
||||
}
|
||||
|
||||
# Handling of a complete MinDataStore snapshot
|
||||
#
|
||||
# Invoke the removed and inserted hooks using the old and new min data store
|
||||
# instances, respectively. The way this event is used, the original
|
||||
# min_data_store should essentially be empty.
|
||||
event new_min_data_store(store: MinDataStore)
|
||||
{
|
||||
invoke_indicator_hook(min_data_store, Intel::indicator_removed);
|
||||
|
||||
min_data_store = store;
|
||||
|
||||
invoke_indicator_hook(min_data_store, Intel::indicator_inserted);
|
||||
}
|
||||
@endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue