Add WafPolicies

This commit is contained in:
Dan Milne
2025-11-10 14:10:37 +11:00
parent af7413c899
commit 772fae7e8b
22 changed files with 1784 additions and 147 deletions

View File

@@ -14,6 +14,7 @@
</div>
<div class="p-6">
<%= form_with url: events_path, method: :get, local: true, class: "space-y-4" do |form| %>
<!-- Basic Filters Row -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div>
<%= form.label :ip, "IP Address", class: "block text-sm font-medium text-gray-700" %>
@@ -40,6 +41,43 @@
class: "inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" %>
</div>
</div>
<!-- Network Intelligence Filters Row -->
<div class="border-t border-gray-200 pt-4">
<h4 class="text-sm font-medium text-gray-900 mb-3">Network Intelligence Filters</h4>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div>
<%= form.label :company, "Company", class: "block text-sm font-medium text-gray-700" %>
<%= form.text_field :company, value: params[:company],
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm",
placeholder: "e.g., Amazon, Google" %>
</div>
<div>
<%= form.label :network_type, "Network Type", class: "block text-sm font-medium text-gray-700" %>
<%= form.select :network_type,
options_for_select([
['All', ''],
['Standard ( Residential/Business )', 'standard'],
['Datacenter', 'datacenter'],
['VPN', 'vpn'],
['Proxy', 'proxy']
], params[:network_type]),
{ }, { class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
</div>
<div>
<%= form.label :asn, "ASN", class: "block text-sm font-medium text-gray-700" %>
<%= form.text_field :asn, value: params[:asn],
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm",
placeholder: "Autonomous System Number" %>
</div>
<div>
<%= form.label :network_cidr, "Network CIDR", class: "block text-sm font-medium text-gray-700" %>
<%= form.text_field :network_cidr, value: params[:network_cidr],
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm",
placeholder: "e.g., 192.168.1.0/24" %>
</div>
</div>
</div>
<% end %>
</div>
</div>
@@ -52,6 +90,8 @@
<div class="flex items-center space-x-4">
<%= link_to "📊 Analytics Dashboard", analytics_path,
class: "text-sm text-blue-600 hover:text-blue-800 font-medium" %>
<%= link_to "🌐 Network Analytics", analytics_networks_path,
class: "text-sm text-blue-600 hover:text-blue-800 font-medium" %>
<% if @pagy.pages > 1 %>
<span class="text-sm text-gray-500">
Page <%= @pagy.page %> of <%= @pagy.pages %>
@@ -92,8 +132,45 @@
<%= event.timestamp.strftime("%Y-%m-%d") %>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-mono text-gray-900">
<%= event.ip_address %>
<td class="px-6 py-4 text-sm text-gray-900">
<% network_range = @network_ranges_by_ip[event.ip_address.to_s] %>
<% if network_range %>
<%= link_to event.ip_address, network_range_path(network_range),
class: "text-blue-600 hover:text-blue-800 hover:underline font-mono" %>
<!-- Network Intelligence Summary -->
<div class="mt-1 space-y-1">
<% if network_range.company.present? %>
<div class="text-xs text-gray-600 font-medium">
<%= network_range.company %>
</div>
<% end %>
<% if network_range.is_datacenter? || network_range.is_vpn? || network_range.is_proxy? %>
<div class="flex flex-wrap gap-1">
<% if network_range.is_datacenter? %>
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-orange-100 text-orange-800" title="Datacenter">DC</span>
<% end %>
<% if network_range.is_vpn? %>
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800" title="VPN">VPN</span>
<% end %>
<% if network_range.is_proxy? %>
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800" title="Proxy">PROXY</span>
<% end %>
</div>
<% end %>
<div class="text-xs text-gray-500">
<%= network_range.cidr %>
<% if network_range.asn.present? %>
• ASN <%= network_range.asn %>
<% end %>
</div>
</div>
<% else %>
<span class="font-mono"><%= event.ip_address %></span>
<div class="mt-1 text-xs text-gray-400">Unknown network</div>
<% end %>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
@@ -117,9 +194,9 @@
<%= event.response_status || '-' %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<% if event.country_code.present? %>
<% if event.lookup_country.present? %>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
<%= event.country_code %>
<%= event.lookup_country %>
</span>
<% else %>
<span class="text-gray-400">-</span>