-
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.
* Redmine bugfix #19198: Change vault default priority filter * Feature/#18682 add way to split instrusion (#69) * Fix lint * Add check for dst address * Change location of yml file * fix splitting and order of execution * Change template to use Ruby Code instead of cidr plugin --------- Co-authored-by: jsotof <jsotof@localhost.localdomain> * release 3.2.0 --------- Co-authored-by: ptorresred <ptorres@redborder.com> Co-authored-by: Juan Soto <127120525+jsotofernandez@users.noreply.github.com> Co-authored-by: jsotof <jsotof@localhost.localdomain> Co-authored-by: Pablo Pérez <pperez@redborder.com>
- Loading branch information
1 parent
5d3ccf7
commit f498cfd
Showing
5 changed files
with
88 additions
and
3 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 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
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,55 @@ | ||
<% if @split_intrusion_logstash %> | ||
filter { | ||
ruby { | ||
code => " | ||
require 'ipaddr' | ||
|
||
event_ip = event.get('src') | ||
if event_ip && !event.get('organization') | ||
ip_src = IPAddr.new(event_ip) rescue nil | ||
if ip_src | ||
<% @sensors.each do |sensor_name, sensor_data| %> | ||
subnets = [ | ||
<% sensor_data['subnets'].each_with_index do |subnet, index| %> | ||
IPAddr.new('<%= subnet.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') %>')<%= ',' unless index == sensor_data['subnets'].length - 1 %> | ||
<% end %> | ||
] | ||
if subnets.any? { |subnet| subnet.include?(ip_src) } | ||
<% sensor_data['fields'].each do |field_name, field_value| %> | ||
event.set('<%= field_name %>', '<%= field_value.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').gsub("'", "\\\\'") %>') | ||
<% end %> | ||
break # If found a match | ||
end | ||
<% end %> | ||
end | ||
end | ||
|
||
# If there is not match in src ip's | ||
if !event.get('organization') | ||
event_ip = event.get('dst') | ||
if event_ip | ||
ip_dst = IPAddr.new(event_ip) rescue nil | ||
if ip_dst | ||
<% @sensors.each do |sensor_name, sensor_data| %> | ||
subnets = [ | ||
<% sensor_data['subnets'].each_with_index do |subnet, index| %> | ||
IPAddr.new('<%= subnet.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') %>')<%= ',' unless index == sensor_data['subnets'].length - 1 %> | ||
<% end %> | ||
] | ||
if subnets.any? { |subnet| subnet.include?(ip_dst) } | ||
<% sensor_data['fields'].each do |field_name, field_value| %> | ||
event.set('<%= field_name %>', '<%= field_value.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').gsub("'", "\\\\'") %>') | ||
<% end %> | ||
break # If found a match | ||
end | ||
<% end %> | ||
end | ||
end | ||
end | ||
" | ||
} | ||
} | ||
<% else %> | ||
filter { | ||
} | ||
<% end %> |