This commit is contained in:
Dan Milne
2025-11-14 16:35:49 +11:00
parent df94ac9720
commit 6433f6c5bb
30 changed files with 833 additions and 245 deletions

View File

@@ -1,4 +1,4 @@
<% content_for :title, "Rule ##{@rule.id} - #{@rule.action.upcase}" %>
<% content_for :title, "Rule ##{@rule.id} - #{@rule.waf_action.upcase}" %>
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
<!-- Header -->
@@ -23,15 +23,16 @@
<div class="mt-2 flex items-center space-x-3">
<h1 class="text-3xl font-bold text-gray-900">Rule #<%= @rule.id %></h1>
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium <%=
case @rule.action
case @rule.waf_action
when 'allow' then 'bg-green-100 text-green-800'
when 'deny' then 'bg-red-100 text-red-800'
when 'rate_limit' then 'bg-yellow-100 text-yellow-800'
when 'redirect' then 'bg-indigo-100 text-indigo-800'
when 'log' then 'bg-gray-100 text-gray-800'
when 'challenge' then 'bg-orange-100 text-orange-800'
else 'bg-gray-100 text-gray-800'
end %>">
<%= @rule.action.upcase %>
<%= @rule.waf_action.upcase %>
</span>
</div>
</div>
@@ -60,12 +61,12 @@
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div>
<dt class="text-sm font-medium text-gray-500">Rule Type</dt>
<dd class="mt-1 text-sm text-gray-900"><%= @rule.rule_type.humanize %></dd>
<dd class="mt-1 text-sm text-gray-900"><%= @rule.waf_rule_type.humanize %></dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Action</dt>
<dd class="mt-1 text-sm text-gray-900"><%= @rule.action.upcase %></dd>
<dd class="mt-1 text-sm text-gray-900"><%= @rule.waf_action.upcase %></dd>
</div>
<div>
@@ -118,6 +119,38 @@
</div>
</div>
<!-- Event Statistics -->
<div class="bg-white shadow rounded-lg mb-6">
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
<h3 class="text-lg font-medium text-gray-900">Event Statistics</h3>
<%= link_to "View Events", events_path(rule_id: @rule.id), class: "text-sm text-blue-600 hover:text-blue-800" %>
</div>
<div class="px-6 py-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-blue-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-500">Total Events</div>
<div class="mt-2 text-3xl font-bold text-gray-900"><%= @rule.events.count %></div>
</div>
<div class="bg-red-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-500">Blocked Events</div>
<div class="mt-2 text-3xl font-bold text-red-900"><%= @rule.events.where(waf_action: :deny).count %></div>
</div>
<div class="bg-green-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-500">Allowed Events</div>
<div class="mt-2 text-3xl font-bold text-green-900"><%= @rule.events.where(waf_action: :allow).count %></div>
</div>
</div>
<% if @rule.events.any? %>
<div class="mt-4 text-sm text-gray-500">
Last event: <%= time_ago_in_words(@rule.events.maximum(:timestamp)) %> ago
</div>
<% end %>
</div>
</div>
<!-- Target Information -->
<% if @rule.network_rule? && @rule.network_range.present? %>
<div class="bg-white shadow rounded-lg mb-6">