forked from idaholab/Malcolm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work on populate netbox inventory passively (idaholab#135): reorganiz…
…ing logstash pipeline so we have the data we need at autopopulate time
- Loading branch information
Showing
8 changed files
with
171 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
filter { | ||
|
||
|
||
################################################################################################ | ||
# Do enrichment based on NetBox lookups: | ||
# - source.ip -> source.device and source.segment | ||
# - destination.ip -> destination.device and destination.segment | ||
# - TODO: source.mac -> source.device | ||
# - TODO: destination.mac -> destination.device | ||
# The LOGSTASH_NETBOX_ENRICHMENT environment variable is checked inside netbox_enrich.rb | ||
# and will short-circuit unles this feature is enabled. | ||
# | ||
# Enrich zeek conn.log, notice.log, weird.log, signatures.log, software.log, known*.log and all non-zeek data sources | ||
|
||
if (([event][provider] != "zeek") or | ||
([event][dataset] == "conn") or | ||
([event][dataset] == "notice") or | ||
([event][dataset] == "weird") or | ||
([event][dataset] == "signatures") or | ||
([event][dataset] == "software") or | ||
([event][dataset] =~ /^known/)) { | ||
if ([source][ip]) and | ||
(([network][direction] == "internal") or ([network][direction] == "outbound")) { | ||
ruby { | ||
id => "ruby_netbox_enrich_source_ip_segment" | ||
path => "/usr/share/logstash/malcolm-ruby/netbox_enrich.rb" | ||
script_params => { | ||
"source" => "[source][ip]" | ||
"target" => "[source][segment]" | ||
"lookup_type" => "ip_vrf" | ||
"lookup_site_env" => "NETBOX_DEFAULT_SITE" | ||
"verbose_env" => "LOGSTASH_NETBOX_ENRICHMENT_VERBOSE" | ||
"autopopulate_env" => "LOGSTASH_NETBOX_AUTO_POPULATE" | ||
"netbox_token_env" => "SUPERUSER_API_TOKEN" | ||
} | ||
} | ||
ruby { | ||
id => "ruby_netbox_enrich_source_ip_device" | ||
path => "/usr/share/logstash/malcolm-ruby/netbox_enrich.rb" | ||
script_params => { | ||
"source" => "[source][ip]" | ||
"target" => "[source][device]" | ||
"lookup_type" => "ip_device" | ||
"lookup_site_env" => "NETBOX_DEFAULT_SITE" | ||
"lookup_service" => "false" | ||
"verbose_env" => "LOGSTASH_NETBOX_ENRICHMENT_VERBOSE" | ||
"netbox_token_env" => "SUPERUSER_API_TOKEN" | ||
# these are used for autopopulation only, not lookup/enrichment | ||
"autopopulate_env" => "LOGSTASH_NETBOX_AUTO_POPULATE" | ||
"source_hostname" => "" | ||
"source_oui" => "[source][oui]" | ||
"source_segment" => "[source][segment]" | ||
} | ||
} | ||
} | ||
if ([destination][ip]) and | ||
(([network][direction] == "internal") or ([network][direction] == "inbound")) { | ||
ruby { | ||
id => "ruby_netbox_enrich_destination_ip_segment" | ||
path => "/usr/share/logstash/malcolm-ruby/netbox_enrich.rb" | ||
script_params => { | ||
"source" => "[destination][ip]" | ||
"target" => "[destination][segment]" | ||
"lookup_type" => "ip_vrf" | ||
"lookup_site_env" => "NETBOX_DEFAULT_SITE" | ||
"verbose_env" => "LOGSTASH_NETBOX_ENRICHMENT_VERBOSE" | ||
"netbox_token_env" => "SUPERUSER_API_TOKEN" | ||
} | ||
} | ||
ruby { | ||
id => "ruby_netbox_enrich_destination_ip_device" | ||
path => "/usr/share/logstash/malcolm-ruby/netbox_enrich.rb" | ||
script_params => { | ||
"source" => "[destination][ip]" | ||
"target" => "[destination][device]" | ||
"lookup_type" => "ip_device" | ||
"lookup_site_env" => "NETBOX_DEFAULT_SITE" | ||
"lookup_service_env" => "LOGSTASH_NETBOX_ENRICHMENT_LOOKUP_SERVICE" | ||
"lookup_service_port_source" => "[destination][port]" | ||
"verbose_env" => "LOGSTASH_NETBOX_ENRICHMENT_VERBOSE" | ||
"netbox_token_env" => "SUPERUSER_API_TOKEN" | ||
# these are used for autopopulation only, not lookup/enrichment | ||
"autopopulate_env" => "LOGSTASH_NETBOX_AUTO_POPULATE" | ||
"source_hostname" => "" | ||
"source_oui" => "[destination][oui]" | ||
"source_segment" => "[destination][segment]" | ||
} | ||
} | ||
} | ||
} | ||
|
||
# collect site, role, manufacturer and device_type in "related." segment is merged as network.name in 20_enriched_to_ecs.conf | ||
if ([source][device][site]) { mutate { id => "mutate_merge_source_device_site_related" | ||
merge => { "[related][site]" => "[source][device][site]" } } } | ||
if ([destination][device][site]) { mutate { id => "mutate_merge_destination_device_site_related" | ||
merge => { "[related][site]" => "[destination][device][site]" } } } | ||
if ([source][segment][site]) { mutate { id => "mutate_merge_source_segment_site_related" | ||
merge => { "[related][site]" => "[source][segment][site]" } } } | ||
if ([destination][segment][site]) { mutate { id => "mutate_merge_destination_segment_site_related" | ||
merge => { "[related][site]" => "[destination][segment][site]" } } } | ||
if ([source][device][role]) { mutate { id => "mutate_merge_source_device_role_related" | ||
merge => { "[related][role]" => "[source][device][role]" } } } | ||
if ([destination][device][role]) { mutate { id => "mutate_merge_destination_device_role_related" | ||
merge => { "[related][role]" => "[destination][device][role]" } } } | ||
if ([source][device][manufacturer]) { mutate { id => "mutate_merge_source_device_manufacturer_related" | ||
merge => { "[related][manufacturer]" => "[source][device][manufacturer]" } } } | ||
if ([destination][device][manufacturer]) { mutate { id => "mutate_merge_destination_device_manufacturer_related" | ||
merge => { "[related][manufacturer]" => "[destination][device][manufacturer]" } } } | ||
if ([source][device][device_type]) { mutate { id => "mutate_merge_source_device_type_related" | ||
merge => { "[related][device_type]" => "[source][device][device_type]" } } } | ||
if ([destination][device][device_type]) { mutate { id => "mutate_merge_destination_device_type_related" | ||
merge => { "[related][device_type]" => "[destination][device][device_type]" } } } | ||
if ([source][device][service]) { mutate { id => "mutate_merge_source_service_related" | ||
merge => { "[related][service]" => "[source][device][service]" } } } | ||
if ([destination][device][service]) { mutate { id => "mutate_merge_destination_service_related" | ||
merge => { "[related][service]" => "[destination][device][service]" } } } | ||
if ([source][device][name]) { mutate { id => "mutate_merge_source_device_name_related" | ||
merge => { "[related][device_name]" => "[source][device][name]" } } } | ||
if ([destination][device][name]) { mutate { id => "mutate_merge_destination_device_name_related" | ||
merge => { "[related][device_name]" => "[destination][device][name]" } } } | ||
|
||
# network.name (based on info from [destination][segment][name] and [source][segment][name]) | ||
if ([destination][segment][name]) { mutate { id => "mutate_add_field_ecs_network_name_resp" | ||
merge => { "[network][name]" => "[destination][segment][name]" } } } | ||
if ([source][segment][name]) { mutate { id => "mutate_add_field_ecs_network_name_orig" | ||
merge => { "[network][name]" => "[source][segment][name]" } } } | ||
|
||
} # filter | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters