Migrate to Postgresql for better network handling. Add more user functionality.
This commit is contained in:
@@ -71,10 +71,12 @@
|
||||
<span class="badge bg-secondary ms-1"><%= current_user.role %></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><%= link_to "Account Settings", edit_password_path, class: "dropdown-item" %></li>
|
||||
<% if current_user_admin? %>
|
||||
<li><%= link_to "Manage Users", users_path, class: "dropdown-item" %></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><%= link_to "Manage Users", users_path, class: "dropdown-item" %></li>
|
||||
<% end %>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><%= link_to "Sign Out", session_path, data: { turbo_method: :delete }, class: "dropdown-item" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
313
app/views/network_ranges/index.html.erb
Normal file
313
app/views/network_ranges/index.html.erb
Normal file
@@ -0,0 +1,313 @@
|
||||
<% content_for :title, "Network Ranges - #{@project.name}" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<!-- Header -->
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900">Network Ranges</h1>
|
||||
<p class="mt-2 text-gray-600">Browse and manage network ranges with intelligence data</p>
|
||||
</div>
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "IP Lookup", lookup_network_ranges_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<%= link_to "Add Range", new_network_range_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" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Active Filters -->
|
||||
<% if params[:asn].present? || params[:country].present? || params[:company].present? || params[:datacenter].present? || params[:vpn].present? || params[:proxy].present? || params[:source].present? || params[:search].present? %>
|
||||
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-sm font-medium text-blue-900">Active Filters</h3>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<% if params[:asn].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
ASN: <%= params[:asn] %>
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:country].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Country: <%= params[:country] %>
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:company].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Company: <%= params[:company] %>
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:datacenter].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Datacenter
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:vpn].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
VPN
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:proxy].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Proxy
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:source].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Source: <%= params[:source] %>
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if params[:search].present? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Search: <%= params[:search] %>
|
||||
<%= link_to "×", network_ranges_path, class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<%= link_to "Clear All", network_ranges_path, class: "text-sm text-blue-600 hover:text-blue-800 font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Statistics Cards -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4 mb-8">
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Total Ranges</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@total_ranges) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">With Intelligence</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@ranges_with_intelligence) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-orange-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Datacenters</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@datacenter_ranges) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-purple-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">VPNs</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@vpn_ranges) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Proxies</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@proxy_ranges) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filters and Search -->
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="p-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Filters & Search</h3>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<%= form_with url: network_ranges_path, method: :get, class: "space-y-4" do |form| %>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<%= form.label :search, "Search", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_field :search, value: params[:search], placeholder: "CIDR, Company, 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" %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :country, "Country", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :country, options_for_select([["All Countries", ""]] + @top_countries.map { |c, _| [c, c] }), { selected: params[:country] }, { 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 :source, "Source", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :source, options_for_select([["All Sources", ""], "production_import", "user_created", "api_imported", "manual", "auto:scanner_detected"], params[:source]), { }, { 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 :flags, "Flags", class: "block text-sm font-medium text-gray-700" %>
|
||||
<div class="mt-2 space-x-4">
|
||||
<label class="inline-flex items-center">
|
||||
<%= check_box_tag "datacenter", "true", params[:datacenter] == "true", class: "rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" %>
|
||||
<span class="ml-2 text-sm text-gray-700">Datacenter</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<%= check_box_tag "vpn", "true", params[:vpn] == "true", class: "rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" %>
|
||||
<span class="ml-2 text-sm text-gray-700">VPN</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<%= check_box_tag "proxy", "true", params[:proxy] == "true", class: "rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" %>
|
||||
<span class="ml-2 text-sm text-gray-700">Proxy</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<%= form.submit "Apply Filters", 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" %>
|
||||
<%= link_to "Clear", network_ranges_path, class: "ml-3 inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network Ranges Table -->
|
||||
<div class="bg-white shadow overflow-hidden sm:rounded-md">
|
||||
<div class="px-4 py-5 sm:px-6 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Network Ranges</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Showing <%= @network_ranges.count %> of <%= number_with_delimiter(@total_ranges) %> ranges</p>
|
||||
</div>
|
||||
|
||||
<ul class="divide-y divide-gray-200">
|
||||
<% @network_ranges.each do |range| %>
|
||||
<li class="hover:bg-gray-50">
|
||||
<div class="px-4 py-4 sm:px-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="text-sm font-medium text-gray-900"><%= range.cidr %></span>
|
||||
<% if range.ipv4? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">IPv4</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">IPv6</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="mt-1 flex items-center space-x-4 text-sm text-gray-500">
|
||||
<% if range.company.present? %>
|
||||
<span><%= range.company %></span>
|
||||
<% end %>
|
||||
<% if range.asn.present? %>
|
||||
<span>ASN <%= range.asn %></span>
|
||||
<% end %>
|
||||
<% if range.country.present? %>
|
||||
<span class="flex items-center">
|
||||
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<%= range.country %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span class="text-gray-400">Source: <%= range.source %></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-2">
|
||||
<% if range.is_datacenter? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-orange-100 text-orange-800">DC</span>
|
||||
<% end %>
|
||||
<% if range.is_vpn? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800">VPN</span>
|
||||
<% end %>
|
||||
<% if range.is_proxy? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">Proxy</span>
|
||||
<% end %>
|
||||
|
||||
<% if range.rules.any? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
<%= range.rules.count %> rule<%= 's' if range.rules.count > 1 %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<%= link_to "View", network_range_path(range), class: "text-blue-600 hover:text-blue-900 text-sm font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% if @network_ranges.empty? %>
|
||||
<div class="text-center py-12">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-sm font-medium text-gray-900">No network ranges found</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Get started by importing network data or creating ranges manually.</p>
|
||||
<div class="mt-6">
|
||||
<%= link_to "Add Network Range", new_network_range_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" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<% if @pagy.present? %>
|
||||
<div class="mt-6 flex justify-center">
|
||||
<%= pagy_nav(@pagy) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
131
app/views/network_ranges/lookup.html.erb
Normal file
131
app/views/network_ranges/lookup.html.erb
Normal file
@@ -0,0 +1,131 @@
|
||||
<% content_for :title, "IP Address Lookup" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<div class="mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-900">IP Address Lookup</h1>
|
||||
<p class="mt-2 text-gray-600">Lookup IP addresses to find matching network ranges and intelligence</p>
|
||||
</div>
|
||||
|
||||
<!-- Search Form -->
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="p-6">
|
||||
<%= form_with url: lookup_network_ranges_path, method: :get, local: true, class: "space-y-4" do |form| %>
|
||||
<div>
|
||||
<%= form.label :ip_address, "IP Address", class: "block text-sm font-medium text-gray-700" %>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<%= form.text_field :ip, value: params[:ip], placeholder: "Enter IP address (e.g., 8.8.8.8)", class: "flex-1 min-w-0 block w-full rounded-none rounded-l-md border-gray-300 focus:border-blue-500 focus:ring-blue-500 sm:text-sm" %>
|
||||
<%= form.submit "Lookup", class: "-ml-px relative inline-flex items-center px-4 py-2 border border-transparent rounded-r-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if params[:ip].present? && @ranges %>
|
||||
<!-- IP Intelligence -->
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">IP Intelligence: <%= params[:ip] %></h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-gray-900 mb-3">Matching Network Ranges</h4>
|
||||
<% if @ranges.any? %>
|
||||
<div class="space-y-3">
|
||||
<% @ranges.each do |range| %>
|
||||
<div class="border border-gray-200 rounded-lg p-4">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<%= link_to range.cidr, network_range_path(range), class: "text-sm font-medium text-blue-600 hover:text-blue-900" %>
|
||||
<span class="text-xs text-gray-500">Priority: <%= range[:specificity] %></span>
|
||||
</div>
|
||||
|
||||
<% intel = range[:intelligence] %>
|
||||
<div class="space-y-1 text-sm">
|
||||
<% if intel[:company] %>
|
||||
<div><span class="font-medium">Company:</span> <%= intel[:company] %></div>
|
||||
<% end %>
|
||||
<% if intel[:asn] %>
|
||||
<div><span class="font-medium">ASN:</span> <%= intel[:asn] %> (<%= intel[:asn_org] %>)</div>
|
||||
<% end %>
|
||||
<% if intel[:country] %>
|
||||
<div><span class="font-medium">Country:</span> <%= intel[:country] %></div>
|
||||
<% end %>
|
||||
|
||||
<div class="flex space-x-2 pt-2">
|
||||
<% if intel[:is_datacenter] %>
|
||||
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-orange-100 text-orange-800">DC</span>
|
||||
<% end %>
|
||||
<% if intel[:is_vpn] %>
|
||||
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-purple-100 text-purple-800">VPN</span>
|
||||
<% end %>
|
||||
<% if intel[:is_proxy] %>
|
||||
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-red-100 text-red-800">Proxy</span>
|
||||
<% end %>
|
||||
<% if intel[:inherited] %>
|
||||
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-gray-100 text-gray-800">Inherited</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="text-sm text-gray-500">No network ranges found for this IP address.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-gray-900 mb-3">Suggested Block Ranges</h4>
|
||||
<% if @suggested_blocks.any? %>
|
||||
<div class="space-y-2">
|
||||
<% @suggested_blocks.each do |suggestion| %>
|
||||
<div class="flex items-center justify-between p-3 border border-gray-200 rounded">
|
||||
<div>
|
||||
<div class="text-sm font-medium"><%= suggestion[:cidr] %></div>
|
||||
<div class="text-xs text-gray-500"><%= suggestion[:description] %></div>
|
||||
</div>
|
||||
<% if suggestion[:current_block] %>
|
||||
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-red-100 text-red-800">Already Blocked</span>
|
||||
<% else %>
|
||||
<%= link_to "Block Range", new_rule_path(cidr: suggestion[:cidr]), class: "inline-flex items-center px-3 py-1 border border-transparent text-xs font-medium rounded text-white bg-red-600 hover:bg-red-700" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="text-sm text-gray-500">No suggestions available.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Quick Actions -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div class="bg-white shadow rounded-lg p-6 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 15l-2 5L9 9l11 4-5 2z" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-lg font-medium text-gray-900">Quick Lookup</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Enter any IP address to instantly find matching network ranges</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow rounded-lg p-6 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-lg font-medium text-gray-900">Network Intelligence</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">View company, ASN, country, and classification data</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow rounded-lg p-6 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 0A9 9 0 005.636 5.636m12.728 0L5.636 5.636" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-lg font-medium text-gray-900">Create Rules</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Block ranges or create surgical exceptions instantly</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
128
app/views/network_ranges/new.html.erb
Normal file
128
app/views/network_ranges/new.html.erb
Normal file
@@ -0,0 +1,128 @@
|
||||
<% content_for :title, "Add Network Range" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<div class="mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-900">Add Network Range</h1>
|
||||
<p class="mt-2 text-gray-600">Create a new network range for tracking and rule management</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<%= form_with(model: @network_range, local: true, class: "space-y-6") do |form| %>
|
||||
<% if @network_range.errors.any? %>
|
||||
<div class="rounded-md bg-red-50 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-800">
|
||||
There were <%= pluralize(@network_range.errors.count, "error") %> with your submission:
|
||||
</h3>
|
||||
<div class="mt-2 text-sm text-red-700">
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% @network_range.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Network Information</h3>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 space-y-6">
|
||||
<div>
|
||||
<%= form.label :network, "Network Range (CIDR)", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_field :network, 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 or 2001:db8::/32" %>
|
||||
<p class="mt-2 text-sm text-gray-500">Enter the network range in CIDR notation. Supports both IPv4 and IPv6.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :source, "Source", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :source, options_for_select([
|
||||
["User Created", "user_created"],
|
||||
["Manual Import", "manual"],
|
||||
["API Imported", "api_imported"],
|
||||
["Auto Generated", "auto_generated"]
|
||||
], "user_created"), {}, { 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 :creation_reason, "Creation Reason", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_area :creation_reason, rows: 3, 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: "Optional reason for creating this network range" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Network Intelligence</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Optional intelligence data about this network range</p>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<%= form.label :asn, "ASN", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.number_field :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: "e.g., 15169" %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :asn_org, "ASN Organization", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_field :asn_org, 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., Google LLC" %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :company, "Company", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_field :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., Google LLC" %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :country, "Country Code", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_field :country, 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., US" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center space-x-6">
|
||||
<%= form.check_box :is_datacenter, class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
|
||||
<%= form.label :is_datacenter, "Datacenter Network", class: "text-sm font-medium text-gray-900" %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-6">
|
||||
<%= form.check_box :is_vpn, class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
|
||||
<%= form.label :is_vpn, "VPN Network", class: "text-sm font-medium text-gray-900" %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-6">
|
||||
<%= form.check_box :is_proxy, class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
|
||||
<%= form.label :is_proxy, "Proxy Network", class: "text-sm font-medium text-gray-900" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :abuser_scores, "Abuser Scores", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_area :abuser_scores, rows: 3, 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: '{ "score": "0.001", "source": "api" }' %>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format with abuser scoring information</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :additional_data, "Additional Data", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_area :additional_data, rows: 4, 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: '{ "custom_field": "value" }' %>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format for any additional metadata</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
|
||||
<div class="flex justify-end space-x-3">
|
||||
<%= link_to "Cancel", network_ranges_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<%= form.submit "Create Network Range", 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" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
347
app/views/network_ranges/show.html.erb
Normal file
347
app/views/network_ranges/show.html.erb
Normal file
@@ -0,0 +1,347 @@
|
||||
<% content_for :title, "#{@network_range.cidr} - Network Range Details" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<!-- Header -->
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<nav class="flex" aria-label="Breadcrumb">
|
||||
<ol class="flex items-center space-x-4">
|
||||
<li>
|
||||
<%= link_to "Network Ranges", network_ranges_path, class: "text-gray-500 hover:text-gray-700" %>
|
||||
</li>
|
||||
<li>
|
||||
<div class="flex items-center">
|
||||
<svg class="flex-shrink-0 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span class="ml-4 text-gray-700 font-medium"><%= @network_range.cidr %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<div class="mt-2 flex items-center space-x-3">
|
||||
<h1 class="text-3xl font-bold text-gray-900"><%= @network_range.cidr %></h1>
|
||||
<% if @network_range.ipv4? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800">IPv4</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">IPv6</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "Edit", edit_network_range_path(@network_range), class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<%= link_to "Create Rule", new_rule_path(network_range_id: @network_range.id), 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" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network Intelligence Card -->
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Network Intelligence</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<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">Network Address</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 font-mono"><%= @network_range.network_address %></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Prefix Length</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">/<%= @network_range.prefix_length %></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Family</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @network_range.ipv4? ? "IPv4" : "IPv6" %></dd>
|
||||
</div>
|
||||
|
||||
<% if @network_range.asn.present? %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">ASN</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<%= link_to "#{@network_range.asn} (#{@network_range.asn_org})", network_ranges_path(asn: @network_range.asn),
|
||||
class: "text-blue-600 hover:text-blue-900 hover:underline" %>
|
||||
</dd>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @network_range.company.present? %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Company</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<%= link_to @network_range.company, network_ranges_path(company: @network_range.company),
|
||||
class: "text-blue-600 hover:text-blue-900 hover:underline" %>
|
||||
</dd>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @network_range.country.present? %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Country</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<%= link_to @network_range.country, network_ranges_path(country: @network_range.country),
|
||||
class: "text-blue-600 hover:text-blue-900 hover:underline" %>
|
||||
</dd>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Source</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @network_range.source %></dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Created</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= time_ago_in_words(@network_range.created_at) %> ago</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Updated</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= time_ago_in_words(@network_range.updated_at) %> ago</dd>
|
||||
</div>
|
||||
|
||||
<!-- Classification Flags -->
|
||||
<div class="md:col-span-2 lg:col-span-3">
|
||||
<dt class="text-sm font-medium text-gray-500 mb-2">Classification</dt>
|
||||
<dd class="flex flex-wrap gap-2">
|
||||
<% if @network_range.is_datacenter? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-orange-100 text-orange-800">
|
||||
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z" />
|
||||
</svg>
|
||||
Datacenter
|
||||
</span>
|
||||
<% end %>
|
||||
<% if @network_range.is_vpn? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-purple-100 text-purple-800">
|
||||
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z" />
|
||||
</svg>
|
||||
VPN
|
||||
</span>
|
||||
<% end %>
|
||||
<% if @network_range.is_proxy? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-red-100 text-red-800">
|
||||
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M3 5a2 2 0 012-2h10a2 2 0 012 2v8a2 2 0 01-2 2h-2.22l.123.489.804.804A1 1 0 0113 18H7a1 1 0 01-.894-.553l.804-.804L7.22 15H5a2 2 0 01-2-2V5zm5.771 7H5V5h10v7H8.771z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Proxy
|
||||
</span>
|
||||
<% end %>
|
||||
<% if @network_range.abuser_scores_hash.any? %>
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800">
|
||||
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Abuser Score: <%= @network_range.abuser_scores_hash['score'] || 'Unknown' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</dd>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @network_range.additional_data_hash.any? %>
|
||||
<div class="mt-6 pt-6 border-t border-gray-200">
|
||||
<dt class="text-sm font-medium text-gray-500 mb-2">Additional Data</dt>
|
||||
<dd class="mt-1">
|
||||
<pre class="bg-gray-50 p-3 rounded-md text-xs overflow-x-auto"><%= JSON.pretty_generate(@network_range.additional_data_hash) %></pre>
|
||||
</dd>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Traffic Statistics -->
|
||||
<% if @traffic_stats[:total_requests] > 0 %>
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Traffic Statistics</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-bold text-gray-900"><%= number_with_delimiter(@traffic_stats[:total_requests]) %></div>
|
||||
<div class="text-sm text-gray-500">Total Requests</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-bold text-gray-900"><%= number_with_delimiter(@traffic_stats[:unique_ips]) %></div>
|
||||
<div class="text-sm text-gray-500">Unique IPs</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-bold text-green-600"><%= number_with_delimiter(@traffic_stats[:allowed_requests]) %></div>
|
||||
<div class="text-sm text-gray-500">Allowed</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-bold text-red-600"><%= number_with_delimiter(@traffic_stats[:blocked_requests]) %></div>
|
||||
<div class="text-sm text-gray-500">Blocked</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @traffic_stats[:top_paths].any? %>
|
||||
<div class="border-t border-gray-200 pt-4">
|
||||
<h4 class="text-sm font-medium text-gray-900 mb-2">Top Paths</h4>
|
||||
<div class="space-y-1">
|
||||
<% @traffic_stats[:top_paths].first(5).each do |path, count| %>
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-600 truncate"><%= path %></span>
|
||||
<span class="font-medium"><%= count %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Associated Rules -->
|
||||
<% if @associated_rules.any? %>
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Associated Rules (<%= @associated_rules.count %>)</h3>
|
||||
</div>
|
||||
<div class="divide-y divide-gray-200">
|
||||
<% @associated_rules.each do |rule| %>
|
||||
<div class="px-6 py-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="text-sm font-medium text-gray-900">
|
||||
<%= rule.action.upcase %> <%= rule.cidr %>
|
||||
</span>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
Priority: <%= rule.priority %>
|
||||
</span>
|
||||
<% if rule.source.include?('surgical') %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800">
|
||||
Surgical
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-gray-500">
|
||||
Created <%= time_ago_in_words(rule.created_at) %> ago by <%= rule.user&.email_address || 'System' %>
|
||||
</div>
|
||||
<% if rule.metadata&.dig('reason').present? %>
|
||||
<div class="mt-1 text-sm text-gray-600">
|
||||
Reason: <%= rule.metadata['reason'] %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<% if rule.enabled? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">Active</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Disabled</span>
|
||||
<% end %>
|
||||
<%= link_to "View", rule_path(rule), class: "text-blue-600 hover:text-blue-900 text-sm font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Network Relationships -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
|
||||
<!-- Parent Ranges -->
|
||||
<% if @parent_ranges.any? %>
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Parent Network Ranges</h3>
|
||||
</div>
|
||||
<div class="divide-y divide-gray-200">
|
||||
<% @parent_ranges.each do |parent| %>
|
||||
<div class="px-6 py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<%= link_to parent.cidr, network_range_path(parent), class: "text-sm font-medium text-gray-900 hover:text-blue-600" %>
|
||||
<div class="text-sm text-gray-500">
|
||||
Prefix: /<%= parent.prefix_length %> |
|
||||
<% if parent.company.present? %><%= parent.company %> | <% end %>
|
||||
<%= parent.source %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Child Ranges -->
|
||||
<% if @child_ranges.any? %>
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Child Network Ranges</h3>
|
||||
</div>
|
||||
<div class="divide-y divide-gray-200">
|
||||
<% @child_ranges.each do |child| %>
|
||||
<div class="px-6 py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<%= link_to child.cidr, network_range_path(child), class: "text-sm font-medium text-gray-900 hover:text-blue-600" %>
|
||||
<div class="text-sm text-gray-500">
|
||||
Prefix: /<%= child.prefix_length %> |
|
||||
<% if child.company.present? %><%= child.company %> | <% end %>
|
||||
<%= child.source %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Recent Events -->
|
||||
<% if @related_events.any? %>
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Recent Events (<%= @related_events.count %>)</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Path</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">User Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
<% @related_events.first(20).each do |event| %>
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||
<%= event.timestamp.strftime("%H:%M:%S") %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-mono text-gray-900">
|
||||
<%= event.ip_address %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||
<%= event.request_path || "-" %>
|
||||
</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 <%= event.waf_action == 'deny' ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800' %>">
|
||||
<%= event.waf_action %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-900">
|
||||
<div class="truncate max-w-xs" title="<%= event.user_agent %>">
|
||||
<%= event.user_agent&.truncate(50) || "-" %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,21 +1,91 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<% if alert = flash[:alert] %>
|
||||
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
|
||||
<% end %>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<% if alert = flash[:alert] %>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<%= alert %>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h1 class="font-bold text-4xl">Update your password</h1>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title mb-0">Account Settings</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- User Info -->
|
||||
<div class="mb-4">
|
||||
<h5>Profile Information</h5>
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th>Email:</th>
|
||||
<td><%= @user.email_address %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Role:</th>
|
||||
<td><span class="badge bg-<%= @user.admin? ? 'danger' : @user.viewer? ? 'info' : 'primary' %>"><%= @user.role %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Authentication:</th>
|
||||
<td>
|
||||
<% if @user.password_digest.present? %>
|
||||
<span class="badge bg-success">Local Password</span>
|
||||
<% else %>
|
||||
<span class="badge bg-info">OIDC</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Active Sessions:</th>
|
||||
<td><%= @user.sessions.count %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Member Since:</th>
|
||||
<td><%= @user.created_at.strftime('%B %d, %Y') %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%= form_with url: password_path(params[:token]), method: :put, class: "contents" do |form| %>
|
||||
<div class="my-5">
|
||||
<%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: "Enter new password", maxlength: 72, class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
|
||||
<% if @user.password_digest.present? %>
|
||||
<!-- Password Change Form -->
|
||||
<div class="border-top pt-4">
|
||||
<h5>Change Password</h5>
|
||||
<p class="text-muted">Changing your password will log you out of all other devices.</p>
|
||||
|
||||
<%= form_with model: @user, url: password_path, method: :patch, class: "row g-3" do |form| %>
|
||||
<div class="col-md-6">
|
||||
<%= form.label :current_password, "Current Password", class: "form-label" %>
|
||||
<%= form.password_field :current_password, required: true, autocomplete: "current-password", class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<%= form.label :password, "New Password", class: "form-label" %>
|
||||
<%= form.password_field :password, required: true, autocomplete: "new-password", minlength: 8, class: "form-control" %>
|
||||
<div class="form-text">Minimum 8 characters</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<%= form.label :password_confirmation, "Confirm New Password", class: "form-label" %>
|
||||
<%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", minlength: 8, class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<%= form.submit "Update Password", class: "btn btn-primary" %>
|
||||
<%= link_to "Cancel", root_path, class: "btn btn-secondary ms-2" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<!-- OIDC User Info -->
|
||||
<div class="border-top pt-4">
|
||||
<div class="alert alert-info">
|
||||
<h6>🔐 OIDC Authentication</h6>
|
||||
<p class="mb-0">Your account is managed through your OIDC provider. To change your password, please use your provider's account management tools.</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: "Repeat new password", maxlength: 72, class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit "Save", class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<% if alert = flash[:alert] %>
|
||||
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
|
||||
<% end %>
|
||||
|
||||
<h1 class="font-bold text-4xl">Forgot your password?</h1>
|
||||
|
||||
<%= form_with url: passwords_path, class: "contents" do |form| %>
|
||||
<div class="my-5">
|
||||
<%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address], class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit "Email reset instructions", class: "w-full sm:w-auto text-center rounded-lg px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<p>
|
||||
You can reset your password on
|
||||
<%= link_to "this password reset page", edit_password_url(@user.password_reset_token) %>.
|
||||
|
||||
This link will expire in <%= distance_of_time_in_words(0, @user.password_reset_token_expires_in) %>.
|
||||
</p>
|
||||
@@ -1,4 +0,0 @@
|
||||
You can reset your password on
|
||||
<%= edit_password_url(@user.password_reset_token) %>
|
||||
|
||||
This link will expire in <%= distance_of_time_in_words(0, @user.password_reset_token_expires_in) %>.
|
||||
213
app/views/rules/edit.html.erb
Normal file
213
app/views/rules/edit.html.erb
Normal file
@@ -0,0 +1,213 @@
|
||||
<% content_for :title, "Edit Rule ##{@rule.id}" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900">Edit Rule #<%= @rule.id %></h1>
|
||||
<p class="mt-2 text-gray-600">Modify the WAF rule configuration</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<%= form_with(model: @rule, local: true, class: "space-y-6") do |form| %>
|
||||
<% if @rule.errors.any? %>
|
||||
<div class="rounded-md bg-red-50 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-800">
|
||||
There were <%= pluralize(@rule.errors.count, "error") %> with your submission:
|
||||
</h3>
|
||||
<div class="mt-2 text-sm text-red-700">
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% @rule.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Rule Type Selection -->
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Rule Configuration</h3>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<%= form.label :rule_type, "Rule Type", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :rule_type,
|
||||
options_for_select(@rule_types.map { |type| [type.humanize, type] }, @rule.rule_type),
|
||||
{ prompt: "Select rule 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",
|
||||
id: "rule_type_select",
|
||||
disabled: true } %>
|
||||
<p class="mt-2 text-sm text-gray-500">Rule type cannot be changed after creation</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :action, "Action", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :action,
|
||||
options_for_select(@actions.map { |action| [action.humanize, action] }, @rule.action),
|
||||
{ },
|
||||
{ class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">What action to take when this rule matches</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network Range Selection (shown for network rules) -->
|
||||
<% if @rule.network_rule? %>
|
||||
<div id="network_range_section">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<%= form.label :network_range_id, "Network Range", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :network_range_id,
|
||||
options_from_collection_for_select(NetworkRange.order(:network).limit(100), :id, :cidr, @rule.network_range_id),
|
||||
{ prompt: "Select a network range" },
|
||||
{ class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">Select from recent network ranges or create new ones</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-end">
|
||||
<%= link_to "Create New Network Range", new_network_range_path,
|
||||
class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @rule.network_range.present? %>
|
||||
<div class="bg-blue-50 border border-blue-200 rounded-md p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-blue-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<p class="text-sm text-blue-800">
|
||||
Currently targeting: <strong><%= link_to @rule.network_range.cidr, network_range_path(@rule.network_range), class: "text-blue-600 hover:text-blue-900 underline" %></strong>
|
||||
<% if @rule.network_range.company.present? %>
|
||||
- <%= @rule.network_range.company %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Conditions (shown for non-network rules) -->
|
||||
<% unless @rule.network_rule? %>
|
||||
<div id="conditions_section">
|
||||
<div>
|
||||
<%= form.label :conditions, "Conditions", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_area :conditions, rows: 4,
|
||||
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: '{"path_pattern": "/admin/*", "user_agent": "bot*"}' %>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format with matching conditions</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Metadata -->
|
||||
<div data-controller="json-validator" data-json-validator-valid-class="json-valid" data-json-validator-invalid-class="json-invalid" data-json-validator-valid-status-class="json-valid-status" data-json-validator-invalid-status-class="json-invalid-status">
|
||||
<%= form.label :metadata, "Metadata", class: "block text-sm font-medium text-gray-700" %>
|
||||
<div class="relative">
|
||||
<%= form.text_area :metadata, rows: 3,
|
||||
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: '{"reason": "Suspicious activity detected", "source": "manual"}',
|
||||
data: { json_validator_target: "textarea", action: "input->json-validator#validate" } %>
|
||||
<div class="mt-1 flex items-center justify-between">
|
||||
<div data-json-validator-target="status" class="text-sm"></div>
|
||||
<div class="flex space-x-2">
|
||||
<button type="button"
|
||||
data-action="click->json-validator#format"
|
||||
class="text-xs text-gray-500 hover:text-gray-700 underline">
|
||||
Format JSON
|
||||
</button>
|
||||
<button type="button"
|
||||
data-action="click->json-validator#insertSample"
|
||||
data-json-validator-json-sample='{"reason": "Block malicious ISP", "threat_type": "botnet", "confidence": "high", "source": "manual"}'
|
||||
class="text-xs text-gray-500 hover:text-gray-700 underline">
|
||||
Insert Sample
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format with additional metadata</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div>
|
||||
<%= form.label :expires_at, "Expires At", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.datetime_local_field :expires_at,
|
||||
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" %>
|
||||
<p class="mt-2 text-sm text-gray-500">Leave blank for permanent rule</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :source, "Source", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :source,
|
||||
options_for_select(Rule::SOURCES.map { |source| [source.humanize, source] }, @rule.source),
|
||||
{ },
|
||||
{ class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">How this rule was created</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center pt-6">
|
||||
<%= form.check_box :enabled, class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
|
||||
<%= form.label :enabled, "Rule Enabled", class: "ml-2 block text-sm text-gray-900" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "Cancel", @rule, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
</div>
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "Delete Rule", @rule,
|
||||
method: :delete,
|
||||
data: { confirm: "Are you sure you want to delete this rule? This action cannot be undone." },
|
||||
class: "inline-flex items-center px-4 py-2 border border-red-300 rounded-md shadow-sm text-sm font-medium text-red-700 bg-red-50 hover:bg-red-100" %>
|
||||
<%= form.submit "Update Rule", 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" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Show/hide sections based on rule type
|
||||
const ruleTypeSelect = document.getElementById('rule_type_select');
|
||||
const networkSection = document.getElementById('network_range_section');
|
||||
const conditionsSection = document.getElementById('conditions_section');
|
||||
|
||||
function toggleSections() {
|
||||
if (ruleTypeSelect && ruleTypeSelect.value === 'network') {
|
||||
networkSection.classList.remove('hidden');
|
||||
if (conditionsSection) conditionsSection.classList.add('hidden');
|
||||
} else {
|
||||
if (networkSection) networkSection.classList.add('hidden');
|
||||
if (conditionsSection) conditionsSection.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
if (ruleTypeSelect) {
|
||||
ruleTypeSelect.addEventListener('change', toggleSections);
|
||||
toggleSections(); // Initial state
|
||||
}
|
||||
});
|
||||
</script>
|
||||
224
app/views/rules/index.html.erb
Normal file
224
app/views/rules/index.html.erb
Normal file
@@ -0,0 +1,224 @@
|
||||
<% content_for :title, "Rules - #{@project.name}" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<!-- Header -->
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900">Rules</h1>
|
||||
<p class="mt-2 text-gray-600">Manage WAF rules for traffic filtering and control</p>
|
||||
</div>
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "Add Network Range", new_network_range_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistics Cards -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-8">
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Total Rules</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@rules.count) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Active Rules</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@rules.active.count) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Block Rules</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@rules.where(action: 'deny').count) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white overflow-hidden shadow rounded-lg">
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-6 w-6 text-yellow-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">Expired Rules</dt>
|
||||
<dd class="text-lg font-medium text-gray-900"><%= number_with_delimiter(@rules.expired.count) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rules List -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">All Rules</h3>
|
||||
</div>
|
||||
|
||||
<% if @rules.any? %>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Rule</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Target</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
|
||||
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
<% @rules.each do |rule| %>
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-900">
|
||||
<%= link_to "Rule ##{rule.id}", rule_path(rule), class: "text-blue-600 hover:text-blue-900" %>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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 <%=
|
||||
case rule.rule_type
|
||||
when 'network' then 'bg-blue-100 text-blue-800'
|
||||
when 'rate_limit' then 'bg-yellow-100 text-yellow-800'
|
||||
when 'path_pattern' then 'bg-purple-100 text-purple-800'
|
||||
else 'bg-gray-100 text-gray-800'
|
||||
end %>">
|
||||
<%= rule.rule_type.humanize %>
|
||||
</span>
|
||||
</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 <%=
|
||||
case rule.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'
|
||||
else 'bg-gray-100 text-gray-800'
|
||||
end %>">
|
||||
<%= rule.action.upcase %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||
<% if rule.network_range? && rule.network_range %>
|
||||
<%= rule.network_range.cidr %>
|
||||
<% if rule.network_range.company.present? %>
|
||||
<div class="text-xs text-gray-500"><%= rule.network_range.company %></div>
|
||||
<% end %>
|
||||
<% elsif rule.conditions.present? %>
|
||||
<div class="max-w-xs truncate">
|
||||
<%= JSON.parse(rule.conditions || "{}").map { |k, v| "#{k}: #{v}" }.join(", ") rescue "Invalid JSON" %>
|
||||
</div>
|
||||
<% else %>
|
||||
<span class="text-gray-400">-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center space-x-2">
|
||||
<% if rule.enabled? && !rule.expired? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">Active</span>
|
||||
<% elsif rule.expired? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Expired</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Disabled</span>
|
||||
<% end %>
|
||||
|
||||
<% if rule.expires_at.present? %>
|
||||
<span class="text-xs text-gray-500" title="Expires at <%= rule.expires_at.strftime('%Y-%m-%d %H:%M') %>">
|
||||
<%= distance_of_time_in_words(Time.current, rule.expires_at) %> left
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<%= time_ago_in_words(rule.created_at) %> ago
|
||||
<div class="text-xs">
|
||||
by <%= rule.user&.email_address || 'System' %>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
<%= 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" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="text-center py-12">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-sm font-medium text-gray-900">No rules</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Get started by creating your first WAF rule.</p>
|
||||
<div class="mt-6">
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
372
app/views/rules/new.html.erb
Normal file
372
app/views/rules/new.html.erb
Normal file
@@ -0,0 +1,372 @@
|
||||
<% content_for :title, "Create New Rule" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<div class="mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-900">Create New Rule</h1>
|
||||
<p class="mt-2 text-gray-600">Create a WAF rule to allow, block, or rate limit traffic</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<%= form_with(model: @rule, local: true, class: "space-y-6") do |form| %>
|
||||
<% if @rule.errors.any? %>
|
||||
<div class="rounded-md bg-red-50 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-800">
|
||||
There were <%= pluralize(@rule.errors.count, "error") %> with your submission:
|
||||
</h3>
|
||||
<div class="mt-2 text-sm text-red-700">
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% @rule.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Rule Type Selection -->
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Rule Configuration</h3>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<%= form.label :rule_type, "Rule Type", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :rule_type,
|
||||
options_for_select(@rule_types.map { |type| [type.humanize, type] }, @rule.rule_type),
|
||||
{ prompt: "Select rule 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",
|
||||
id: "rule_type_select" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">Choose the type of rule you want to create</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :action, "Action", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :action,
|
||||
options_for_select(@actions.map { |action| [action.humanize, action] }, @rule.action),
|
||||
{ prompt: "Select action" },
|
||||
{ class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">What action to take when this rule matches</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network Range Selection (shown for network rules) -->
|
||||
<div id="network_range_section" class="hidden">
|
||||
<%= form.label :network_range_id, "Network Range", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||
|
||||
<!-- Selected Network Range Display -->
|
||||
<div id="selected_network_display" class="hidden mb-4 p-4 bg-blue-50 border border-blue-200 rounded-md">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-blue-800">Selected Network Range</h4>
|
||||
<div id="selected_network_info" class="mt-1 text-sm text-blue-700"></div>
|
||||
</div>
|
||||
<button type="button" onclick="clearSelectedNetwork()" class="text-blue-600 hover:text-blue-800">
|
||||
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network Selection Interface -->
|
||||
<div id="network_selection_interface" class="space-y-4">
|
||||
<!-- Search Input -->
|
||||
<div>
|
||||
<input type="text"
|
||||
id="network_search"
|
||||
placeholder="Search by CIDR, IP, company, or ASN..."
|
||||
class="w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm">
|
||||
<p class="mt-2 text-sm text-gray-500">Search existing network ranges or enter a CIDR/IP address below</p>
|
||||
</div>
|
||||
|
||||
<!-- Quick Create Input -->
|
||||
<div class="flex space-x-2">
|
||||
<%= text_field_tag :new_cidr, params[:cidr],
|
||||
placeholder: "e.g., 192.168.1.0/24 or 203.0.113.1",
|
||||
class: "flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm",
|
||||
id: "new_cidr_input" %>
|
||||
<button type="button" onclick="quickCreateNetwork()"
|
||||
class="px-4 py-2 bg-green-600 text-white text-sm rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500">
|
||||
Create & Select
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Search Results -->
|
||||
<div id="network_search_results" class="hidden">
|
||||
<div class="border rounded-md divide-y max-h-64 overflow-y-auto">
|
||||
<!-- Results will be populated here -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden field to store selected network range ID -->
|
||||
<%= form.hidden_field :network_range_id, id: "selected_network_range_id", value: @rule.network_range_id %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Conditions (shown for non-network rules) -->
|
||||
<div id="conditions_section" class="hidden">
|
||||
<div>
|
||||
<%= form.label :conditions, "Conditions", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.text_area :conditions, rows: 4,
|
||||
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: '{"path_pattern": "/admin/*", "user_agent": "bot*"}' %>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format with matching conditions</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metadata -->
|
||||
<div data-controller="json-validator" data-json-validator-valid-class="json-valid" data-json-validator-invalid-class="json-invalid" data-json-validator-valid-status-class="json-valid-status" data-json-validator-invalid-status-class="json-invalid-status">
|
||||
<%= form.label :metadata, "Metadata", class: "block text-sm font-medium text-gray-700" %>
|
||||
<div class="relative">
|
||||
<%= form.text_area :metadata, rows: 3,
|
||||
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: '{"reason": "Suspicious activity detected", "source": "manual"}',
|
||||
data: { json_validator_target: "textarea", action: "input->json-validator#validate" } %>
|
||||
<div class="mt-1 flex items-center justify-between">
|
||||
<div data-json-validator-target="status" class="text-sm"></div>
|
||||
<div class="flex space-x-2">
|
||||
<button type="button"
|
||||
data-action="click->json-validator#format"
|
||||
class="text-xs text-gray-500 hover:text-gray-700 underline">
|
||||
Format JSON
|
||||
</button>
|
||||
<button type="button"
|
||||
data-action="click->json-validator#insertSample"
|
||||
data-json-validator-json-sample='{"reason": "Block malicious ISP", "threat_type": "botnet", "confidence": "high", "source": "manual"}'
|
||||
class="text-xs text-gray-500 hover:text-gray-700 underline">
|
||||
Insert Sample
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">JSON format with additional metadata</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div>
|
||||
<%= form.label :source, "Source", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :source,
|
||||
options_for_select(Rule::SOURCES.map { |source| [source.humanize, source] }, @rule.source || "manual"),
|
||||
{ },
|
||||
{ class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" } %>
|
||||
<p class="mt-2 text-sm text-gray-500">How this rule was created</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :expires_at, "Expires At", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.datetime_local_field :expires_at,
|
||||
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm" %>
|
||||
<p class="mt-2 text-sm text-gray-500">Leave blank for permanent rule</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center pt-6">
|
||||
<%= form.check_box :enabled, class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
|
||||
<%= form.label :enabled, "Enable immediately", class: "ml-2 block text-sm text-gray-900" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
|
||||
<div class="flex justify-end space-x-3">
|
||||
<%= link_to "Cancel", rules_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<%= form.submit "Create Rule", 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" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let selectedNetworkData = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const ruleTypeSelect = document.getElementById('rule_type_select');
|
||||
const networkSection = document.getElementById('network_range_section');
|
||||
const conditionsSection = document.getElementById('conditions_section');
|
||||
|
||||
function toggleSections() {
|
||||
if (ruleTypeSelect.value === 'network') {
|
||||
networkSection.classList.remove('hidden');
|
||||
conditionsSection.classList.add('hidden');
|
||||
} else {
|
||||
networkSection.classList.add('hidden');
|
||||
conditionsSection.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
ruleTypeSelect.addEventListener('change', toggleSections);
|
||||
toggleSections(); // Initial state
|
||||
|
||||
// Pre-select network range if provided
|
||||
<% if @rule.network_range.present? %>
|
||||
// Show selected network display
|
||||
const displayDiv = document.getElementById('selected_network_display');
|
||||
const infoDiv = document.getElementById('selected_network_info');
|
||||
const selectionInterface = document.getElementById('network_selection_interface');
|
||||
|
||||
let infoHtml = '<strong><%= @rule.network_range.network %></strong>';
|
||||
<% if @rule.network_range.company.present? %>
|
||||
infoHtml += ' - <%= @rule.network_range.company %>';
|
||||
<% end %>
|
||||
<% if @rule.network_range.asn_org.present? %>
|
||||
infoHtml += ' (ASN: <%= @rule.network_range.asn_org %>)';
|
||||
<% end %>
|
||||
|
||||
infoDiv.innerHTML = infoHtml;
|
||||
displayDiv.classList.remove('hidden');
|
||||
selectionInterface.classList.add('hidden');
|
||||
<% end %>
|
||||
|
||||
// Pre-fill CIDR if provided
|
||||
<% if params[:cidr].present? %>
|
||||
if (ruleTypeSelect.value === 'network') {
|
||||
document.getElementById('new_cidr_input').value = '<%= params[:cidr] %>';
|
||||
}
|
||||
<% end %>
|
||||
|
||||
// Set up search on Enter key
|
||||
document.getElementById('network_search').addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
searchNetworkRanges();
|
||||
}
|
||||
});
|
||||
|
||||
// Set up quick create on Enter key
|
||||
document.getElementById('new_cidr_input').addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
quickCreateNetwork();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function searchNetworkRanges() {
|
||||
const query = document.getElementById('network_search').value.trim();
|
||||
if (!query) return;
|
||||
|
||||
const resultsDiv = document.getElementById('network_search_results');
|
||||
resultsDiv.innerHTML = '<div class="p-4 text-center text-gray-500">Searching...</div>';
|
||||
resultsDiv.classList.remove('hidden');
|
||||
|
||||
fetch(`/network_ranges/search?q=${encodeURIComponent(query)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.length === 0) {
|
||||
resultsDiv.innerHTML = '<div class="p-4 text-center text-gray-500">No network ranges found. Try creating a new one below.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const html = data.map(network => `
|
||||
<div class="p-3 hover:bg-gray-50 cursor-pointer flex justify-between items-center"
|
||||
onclick="selectNetworkRange(${network.id}, '${network.network}', '${network.company || ''}', '${network.asn_org || ''}')">
|
||||
<div>
|
||||
<div class="font-medium text-gray-900">${network.network}</div>
|
||||
${network.company ? `<div class="text-sm text-gray-600">${network.company}</div>` : ''}
|
||||
${network.asn_org ? `<div class="text-sm text-gray-500">ASN: ${network.asn} - ${network.asn_org}</div>` : ''}
|
||||
${network.country ? `<div class="text-sm text-gray-400">Country: ${network.country}</div>` : ''}
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">
|
||||
${network.is_datacenter ? '<span class="bg-gray-100 px-2 py-1 rounded">DC</span>' : ''}
|
||||
${network.is_vpn ? '<span class="bg-blue-100 px-2 py-1 rounded">VPN</span>' : ''}
|
||||
${network.is_proxy ? '<span class="bg-red-100 px-2 py-1 rounded">Proxy</span>' : ''}
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
resultsDiv.innerHTML = html;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Search error:', error);
|
||||
resultsDiv.innerHTML = '<div class="p-4 text-center text-red-500">Search failed. Please try again.</div>';
|
||||
});
|
||||
}
|
||||
|
||||
function selectNetworkRange(id, network, company, asnOrg) {
|
||||
selectedNetworkData = { id, network, company, asnOrg };
|
||||
|
||||
// Update hidden field
|
||||
document.getElementById('selected_network_range_id').value = id;
|
||||
|
||||
// Update display
|
||||
const displayDiv = document.getElementById('selected_network_display');
|
||||
const infoDiv = document.getElementById('selected_network_info');
|
||||
|
||||
let infoHtml = `<strong>${network}</strong>`;
|
||||
if (company) infoHtml += ` - ${company}`;
|
||||
if (asnOrg) infoHtml += ` (ASN: ${asnOrg})`;
|
||||
|
||||
infoDiv.innerHTML = infoHtml;
|
||||
displayDiv.classList.remove('hidden');
|
||||
|
||||
// Hide the entire selection interface
|
||||
document.getElementById('network_selection_interface').classList.add('hidden');
|
||||
|
||||
// Clear search results
|
||||
document.getElementById('network_search_results').classList.add('hidden');
|
||||
document.getElementById('network_search').value = '';
|
||||
}
|
||||
|
||||
function clearSelectedNetwork() {
|
||||
selectedNetworkData = null;
|
||||
document.getElementById('selected_network_range_id').value = '';
|
||||
document.getElementById('selected_network_display').classList.add('hidden');
|
||||
|
||||
// Show the selection interface again
|
||||
document.getElementById('network_selection_interface').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function quickCreateNetwork() {
|
||||
const cidr = document.getElementById('new_cidr_input').value.trim();
|
||||
if (!cidr) {
|
||||
alert('Please enter a CIDR or IP address');
|
||||
return;
|
||||
}
|
||||
|
||||
// Simple CIDR validation
|
||||
const cidrRegex = /^(\d{1,3}\.){3}\d{1,3}(\/\d{1,2})?$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}(\/\d{1,3})?$/;
|
||||
if (!cidrRegex.test(cidr)) {
|
||||
alert('Invalid CIDR or IP address format');
|
||||
return;
|
||||
}
|
||||
|
||||
// Create network range via API
|
||||
fetch('/network_ranges', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
network_range: {
|
||||
network: cidr,
|
||||
source: 'manual',
|
||||
creation_reason: 'Created from rule form'
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.id) {
|
||||
selectNetworkRange(data.id, data.network, data.company, data.asn_org);
|
||||
document.getElementById('new_cidr_input').value = '';
|
||||
} else {
|
||||
alert('Failed to create network range: ' + (data.error || 'Unknown error'));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Create error:', error);
|
||||
alert('Failed to create network range. Please try again.');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
210
app/views/rules/show.html.erb
Normal file
210
app/views/rules/show.html.erb
Normal file
@@ -0,0 +1,210 @@
|
||||
<% content_for :title, "Rule ##{@rule.id} - #{@rule.action.upcase}" %>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
<!-- Header -->
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<nav class="flex" aria-label="Breadcrumb">
|
||||
<ol class="flex items-center space-x-4">
|
||||
<li>
|
||||
<%= link_to "Rules", rules_path, class: "text-gray-500 hover:text-gray-700" %>
|
||||
</li>
|
||||
<li>
|
||||
<div class="flex items-center">
|
||||
<svg class="flex-shrink-0 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span class="ml-4 text-gray-700 font-medium">Rule #<%= @rule.id %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<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
|
||||
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'
|
||||
else 'bg-gray-100 text-gray-800'
|
||||
end %>">
|
||||
<%= @rule.action.upcase %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex space-x-3">
|
||||
<%= link_to "Edit", edit_rule_path(@rule), class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
<% if @rule.enabled? %>
|
||||
<%= link_to "Disable", disable_rule_path(@rule),
|
||||
method: :post,
|
||||
data: { confirm: "Are you sure you want to disable this rule?" },
|
||||
class: "inline-flex items-center px-4 py-2 border border-yellow-300 rounded-md shadow-sm text-sm font-medium text-yellow-700 bg-yellow-50 hover:bg-yellow-100" %>
|
||||
<% else %>
|
||||
<%= link_to "Enable", enable_rule_path(@rule),
|
||||
method: :post,
|
||||
class: "inline-flex items-center px-4 py-2 border border-green-300 rounded-md shadow-sm text-sm font-medium text-green-700 bg-green-50 hover:bg-green-100" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rule Details -->
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Rule Details</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<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>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Status</dt>
|
||||
<dd class="mt-1">
|
||||
<% if @rule.enabled? && !@rule.expired? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">Active</span>
|
||||
<% elsif @rule.expired? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Expired</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Disabled</span>
|
||||
<% end %>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Source</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.source.humanize %></dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Priority</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.priority %></dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Created</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.created_at.strftime("%Y-%m-%d %H:%M:%S UTC") %></dd>
|
||||
</div>
|
||||
|
||||
<% if @rule.expires_at.present? %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Expires At</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.expires_at.strftime("%Y-%m-%d %H:%M:%S UTC") %></dd>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Created By</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.user&.email_address || 'System' %></dd>
|
||||
</div>
|
||||
|
||||
<% if @rule.updated_at != @rule.created_at %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Last Updated</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= @rule.updated_at.strftime("%Y-%m-%d %H:%M:%S UTC") %></dd>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Target Information -->
|
||||
<% if @rule.network_rule? && @rule.network_range.present? %>
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Network Target</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<div class="bg-gray-50 rounded-lg p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-lg font-medium text-gray-900">
|
||||
<%= link_to @rule.network_range.cidr, network_range_path(@rule.network_range), class: "text-blue-600 hover:text-blue-900" %>
|
||||
</div>
|
||||
<% if @rule.network_range.company.present? %>
|
||||
<div class="text-sm text-gray-600"><%= @rule.network_range.company %></div>
|
||||
<% end %>
|
||||
<% if @rule.network_range.asn.present? %>
|
||||
<div class="text-sm text-gray-500">
|
||||
ASN <%= @rule.network_range.asn %><% if @rule.network_range.asn_org.present? %> (<%= @rule.network_range.asn_org %>)<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @rule.network_range.country.present? %>
|
||||
<div class="text-sm text-gray-500">Country: <%= @rule.network_range.country %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<% if @rule.network_range.is_datacenter? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-orange-100 text-orange-800">Datacenter</span>
|
||||
<% end %>
|
||||
<% if @rule.network_range.is_vpn? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800">VPN</span>
|
||||
<% end %>
|
||||
<% if @rule.network_range.is_proxy? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">Proxy</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Conditions -->
|
||||
<% if @rule.conditions.present? %>
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Conditions</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<pre class="bg-gray-50 p-4 rounded-md text-sm overflow-x-auto"><%= JSON.pretty_generate(JSON.parse(@rule.conditions)) rescue @rule.conditions %></pre>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Metadata -->
|
||||
<% if @rule.metadata.present? %>
|
||||
<div class="bg-white shadow rounded-lg mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Metadata</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<pre class="bg-gray-50 p-4 rounded-md text-sm overflow-x-auto"><%= JSON.pretty_generate(JSON.parse(@rule.metadata)) rescue @rule.metadata %></pre>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Rule Actions -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-medium text-gray-900">Actions</h3>
|
||||
</div>
|
||||
<div class="px-6 py-4">
|
||||
<div class="flex space-x-4">
|
||||
<%= link_to "Edit Rule", edit_rule_path(@rule), class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
|
||||
<% if @rule.enabled? %>
|
||||
<%= form_with(model: @rule, url: disable_rule_path(@rule), method: :post, class: "inline-flex") do |form| %>
|
||||
<%= form.submit "Disable Rule", class: "inline-flex items-center px-4 py-2 border border-yellow-300 rounded-md shadow-sm text-sm font-medium text-yellow-700 bg-yellow-50 hover:bg-yellow-100 cursor-pointer" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= form_with(model: @rule, url: enable_rule_path(@rule), method: :post, class: "inline-flex") do |form| %>
|
||||
<%= form.submit "Enable Rule", class: "inline-flex items-center px-4 py-2 border border-green-300 rounded-md shadow-sm text-sm font-medium text-green-700 bg-green-50 hover:bg-green-100 cursor-pointer" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to "View All Rules", rules_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user