<% content_for :title, "Rules" %>

Rules

Manage WAF rules for traffic filtering and control

<%= link_to "Create Rule", new_rule_path, class: "inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700" %>
Total Rules
<%= number_with_delimiter(@rules.count) %>
Active Rules
<%= number_with_delimiter(@rules.active.count) %>
Block Rules
<%= number_with_delimiter(@rules.where(action: 'deny').count) %>
Expired Rules
<%= number_with_delimiter(@rules.expired.count) %>

All Rules (<%= number_with_delimiter(@rules.count) %>)

<% if @pagy.present? && @pagy.pages > 1 %> Page <%= @pagy.page %> of <%= @pagy.pages %> <% end %>
<% if @pagy.present? && @pagy.pages > 1 %>
<%= pagy_nav_tailwind(@pagy, pagy_id: 'rules_top') %>
<% end %>
<% if @rules.any? %>
<% @rules.each do |rule| %> <% end %>
Rule Type Action Target Status Created Actions
<%= link_to "Rule ##{rule.id}", rule_path(rule), class: "text-blue-600 hover:text-blue-900" %>
<%= rule.source.humanize %> <% if rule.network_range? && rule.network_range %> • <%= link_to rule.network_range.cidr, network_range_path(rule.network_range), class: "text-blue-600 hover:text-blue-900" %> <% end %>
<%= rule.rule_type.humanize %> <%= rule.action.upcase %> <% if rule.network_range? && rule.network_range %> <%= rule.network_range.cidr %> <% if rule.network_range.company.present? %>
<%= rule.network_range.company %>
<% end %> <% elsif rule.conditions.present? %>
<%= JSON.parse(rule.conditions || "{}").map { |k, v| "#{k}: #{v}" }.join(", ") rescue "Invalid JSON" %>
<% else %> - <% end %>
<% if rule.enabled? && !rule.expired? %> Active <% elsif rule.expired? %> Expired <% else %> Disabled <% end %> <% if rule.expires_at.present? %> Expires <%= time_ago_in_words(rule.expires_at) %> from now <% end %>
<%= time_ago_in_words(rule.created_at) %> ago
by <%= rule.user&.email_address || 'System' %>
<%= link_to "View", rule_path(rule), class: "text-blue-600 hover:text-blue-900 mr-3" %> <% if rule.enabled? %> <%= link_to "Disable", disable_rule_path(rule), method: :post, data: { confirm: "Are you sure you want to disable this rule?" }, class: "text-yellow-600 hover:text-yellow-900 mr-3" %> <% else %> <%= link_to "Enable", enable_rule_path(rule), method: :post, class: "text-green-600 hover:text-green-900 mr-3" %> <% end %> <%= link_to "Edit", edit_rule_path(rule), class: "text-indigo-600 hover:text-indigo-900" %>
<% else %>

No rules

Get started by creating your first WAF rule.

<%= link_to "Create Rule", new_rule_path, class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700" %>
<% end %>
<% if @pagy.present? && @pagy.pages > 1 %>
<%= pagy_nav_tailwind(@pagy, pagy_id: 'rules_bottom') %>
<% end %>