Remove /ip_addresses page.

Remove the /ip_addresses page. This page allowed moderators to search
users by IP, and to see recent activity tied to an IP. However, it was
limited to IPs tied to uploads, comments, dmails, artist edits, note
edits, and wiki edits.

Remove this page because it was limited in scope and because there are
better ways of doing what it did. The /user_events page is better at
catching sockpuppets because it tracks IPs for every login, not just for
certain types of edits. And the /user_actions page is better at
monitoring user activity because it shows all activity associated with
an account, not just for certain types of edits.

Removing this allows us to drop IP addresses from all tables besides the
user_events table. This is good because these IPs are no longer necessary
for any purpose, and because storing them forever is a liability.
This commit is contained in:
evazion
2022-09-17 15:36:51 -05:00
parent 1ac56b72a7
commit 075199cd1e
18 changed files with 136 additions and 351 deletions

View File

@@ -3,21 +3,6 @@
class IpAddressesController < ApplicationController
respond_to :html, :xml, :json
def index
@ip_addresses = authorize IpAddress.visible(CurrentUser.user).paginated_search(params)
case search_params[:group_by]
when "ip_addr"
@ip_addresses = @ip_addresses.group_by_ip_addr(search_params[:ipv4_masklen], search_params[:ipv6_masklen])
when "user"
@ip_addresses = @ip_addresses.group_by_user.includes(:user)
else
@ip_addresses = @ip_addresses.includes(:user, :model)
end
respond_with(@ip_addresses)
end
def show
@ip_address = authorize IpAddress.new(ip_addr: params[:id])
@ip_info = @ip_address.ip_addr.ip_info

View File

@@ -195,7 +195,7 @@ module ApplicationHelper
def link_to_ip(ip, shorten: false, **options)
ip_addr = IPAddr.new(ip.to_s)
ip_addr.prefix = 64 if ip_addr.ipv6? && shorten
link_to ip_addr.to_s, ip_addresses_path(search: { ip_addr: ip, group_by: "user" }), **options
link_to ip_addr.to_s, user_events_path(search: { user_session: { ip_addr: ip }}), **options
end
def link_to_search(tag, **options)

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
class IpAddressPolicy < ApplicationPolicy
def index?
def show?
user.is_moderator?
end

View File

@@ -1,9 +1,6 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:user_name, bans_path, "users", autocomplete: "user") %>
<%= subnav_link_to "Listing", bans_path %>
<% if policy(IpAddress).index? %>
<%= subnav_link_to "IP Addresses", ip_addresses_path %>
<% end %>
<% if policy(IpBan).index? %>
<%= subnav_link_to "IP Bans", ip_bans_path %>
<% end %>

View File

@@ -1,24 +0,0 @@
<%= table_for @ip_addresses, class: "striped autofit" do |t| %>
<% t.column "IP Address" do |ip| %>
<%= link_to ip.ip_addr, ip_addresses_path(search: { ip_addr: ip.ip_addr }) %>
<%= link_to "»", ip_addresses_path(search: { ip_addr: ip.ip_addr, group_by: "user" }) %>
<% end %>
<% t.column "Source" do |ip| %>
<%= link_to ip.model_type.underscore.humanize, ip_addresses_path(search: { model_type: ip.model_type }) %>
<% end %>
<% t.column "ID" do |ip| %>
<%= link_to "##{ip.model_id}", ip.model %>
<% end %>
<% t.column "User" do |ip| %>
<%= link_to_user ip.user %>
<%= link_to "»", ip_addresses_path(search: { user_id: ip.user_id, group_by: "ip_addr" }) %>
<% end %>
<% t.column "Date" do |ip| %>
<%= time_ago_in_words_tagged ip.created_at %>
<% end %>
<% t.column column: "ip-info" do |ip| %>
<%= link_to "Details", ip_address_path(ip.ip_addr.to_s) %>
| <%= link_to "Ban IP", new_ip_ban_path(ip_ban: { ip_addr: ip.ip_addr.to_s }) %>
| <%= link_to "Ban User", new_ban_path(ban: { user_name: ip.user.name, duration: 999999 }) %>
<% end %>
<% end %>

View File

@@ -1,16 +0,0 @@
<p>
<%= link_to "Find all users associated with the top 10 IP addresses", ip_addresses_path(search: { ip_addr: @ip_addresses.map(&:to_s).take(10).join(" "), group_by: "user" }) %>
</p>
<%= table_for @ip_addresses, class: "striped autofit" do |t| %>
<% t.column "IP Address" do |ip| %>
<%= link_to ip.to_s, ip_addresses_path(search: { ip_addr: ip.to_s }) %>
<%= link_to "»", ip_addresses_path(search: { ip_addr: ip.to_s, group_by: "user" }) %>
<% end %>
<% t.column "Uses" do |ip| %>
<%= link_to ip.count_all, ip_addresses_path(search: { ip_addr: ip.to_s }) %>
<% end %>
<% t.column column: "ip-info" do |ip| %>
<%= link_to "Details", ip_address_path(ip.ip_addr.to_s) %>
<% end %>
<% end %>

View File

@@ -1,14 +0,0 @@
<p>
<%= link_to "Find all IP addresses associated with these users", ip_addresses_path(search: { user_id: @ip_addresses.map(&:user_id).join(" "), group_by: "ip_addr" }) %>
</p>
<%= table_for @ip_addresses, class: "striped autofit" do |t| %>
<% t.column "User" do |ip| %>
<%= link_to_user ip.user %>
<%= link_to "»", ip_addresses_path(search: { user_id: ip.user_id, group_by: "ip_addr" }) %>
<% end %>
<% t.column "Uses" do |ip| %>
<%= link_to ip.count_all, ip_addresses_path(search: { user_id: ip.user_id, ip_addr: params[:search][:ip_addr] }) %>
<% end %>
<% end %>

View File

@@ -20,7 +20,7 @@
<tr>
<th>Network</th>
<td>
<%= link_to ip_info[:network], ip_addresses_path(search: { ip_addr: ip_info[:network] }) %>
<%= link_to ip_info[:network], user_events_path(search: { user_session: { ip_addr: ip_info[:network] }}) %>
(<%= link_to "info", "https://ipinfo.io/AS#{ip_info[:asn]}/#{ip_info[:network]}" %>)
</td>
</tr>

View File

@@ -1,6 +1,4 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:ip_addr, ip_addresses_path, "ip addresses") %>
<%= subnav_link_to "Listing", ip_addresses_path %>
<%= subnav_link_to "IP Bans", ip_bans_path %>
<%= subnav_link_to "Bans", bans_path %>
<%= subnav_link_to "Feedbacks", user_feedbacks_path %>

View File

@@ -1,35 +0,0 @@
<%= render "secondary_links" %>
<div id="c-ip-addresses">
<div id="a-index">
<% if @ip_address %>
<h1>IP Address: <%= @ip_address.ip_addr %></h1>
<% else %>
<h1>IP Addresses</h1>
<% end %>
<%= search_form_for(ip_addresses_path) do |f| %>
<%= f.input :user_id, label: "User ID", input_html: { value: params[:search][:user_id] }, hint: "Separate with spaces" %>
<%= f.input :user_name, label: "User Name", input_html: { "data-autocomplete": "user", value: params[:search][:user_name] } %>
<%= f.input :ip_addr, label: "IP Address", input_html: { value: params[:search][:ip_addr] }, hint: '<a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation">CIDR notation</a> supported.'.html_safe %>
<%= f.input :created_at, label: "Date", input_html: { value: params[:search][:created_at] } %>
<%= f.input :model_type, label: "Source", collection: IpAddress.model_types, include_blank: true, selected: params[:search][:model_type] %>
<%= f.input :group_by, label: "Group By", collection: [["User", "user"], ["IP Address", "ip_addr"]], include_blank: true, selected: params[:search][:group_by] %>
<% if params[:search][:group_by] == "ip_addr" %>
<%= f.input :ipv4_masklen, label: "IPv4 Subnet", collection: [["/32", 32], ["/24", 24], ["/16", 16], ["/8", 8]], include_blank: false, selected: params[:search][:ipv4_masklen], hint: "Lower to group together IPs with the same prefix." %>
<%= f.input :ipv6_masklen, label: "IPv6 Subnet", collection: [["/128", 128], ["/80", 80], ["/64", 64], ["/48", 48]], include_blank: false, selected: params[:search][:ipv6_masklen] %>
<% end %>
<%= f.submit "Search" %>
<% end %>
<% if params[:search][:group_by] == "user" %>
<%= render "index_by_user" %>
<% elsif params[:search][:group_by] == "ip_addr" %>
<%= render "index_by_ip_addr" %>
<% elsif @ip_addresses.present? %>
<%= render "index" %>
<% end %>
<%= numbered_paginator(@ip_addresses) %>
</div>
</div>

View File

@@ -1,9 +1,6 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:ip_addr, ip_bans_path, "ip addresses") %>
<%= subnav_link_to "Listing", ip_bans_path %>
<% if policy(IpAddress).index? %>
<%= subnav_link_to "IP Addresses", ip_addresses_path %>
<% end %>
<%= subnav_link_to "Bans", bans_path %>
<%= subnav_link_to "Feedbacks", user_feedbacks_path %>
<% if policy(IpBan).create? %>

View File

@@ -184,10 +184,6 @@
<li><%= link_to("Moderation Reports", moderation_reports_path) %></li>
<% end %>
<% if policy(IpAddress).index? %>
<li><%= link_to("IP Addresses", ip_addresses_path) %></li>
<% end %>
<% if policy(NewsUpdate).index? %>
<li><%= link_to("News Updates", news_updates_path) %></li>
<% end %>

View File

@@ -1,9 +1,6 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:user_name, user_feedbacks_path, "users", autocomplete: "user") %>
<%= subnav_link_to "Listing", user_feedbacks_path %>
<% if policy(IpAddress).index? %>
<%= subnav_link_to "IP Addresses", ip_addresses_path %>
<% end %>
<% if policy(IpBan).index? %>
<%= subnav_link_to "IP Bans", ip_bans_path %>
<% end %>

View File

@@ -23,13 +23,9 @@
<th>Last IP</th>
<td>
<% if user.last_ip_addr.present? %>
<%= link_to user.last_ip_addr, ip_addresses_path(search: { ip_addr: user.last_ip_addr }) %>
(<%= link_to "info", ip_address_path(user.last_ip_addr) %>,
<%= link_to "users", ip_addresses_path(search: { ip_addr: user.last_ip_addr, group_by: "user" }) %>,
<%= link_to "IPs", ip_addresses_path(search: { user_id: user.id, group_by: "ip_addr" }) %>)
<%= link_to user.last_ip_addr, ip_address_path(user.last_ip_addr) %>
<% else %>
<em>unknown</em>
(<%= link_to "IPs", ip_addresses_path(search: { user_id: user.id, group_by: "ip_addr" }) %>)
<% end %>
</td>
</tr>
@@ -39,8 +35,12 @@
<tr>
<th>User Events</th>
<td>
<%= link_to "By Name", user_events_path(search: { user_name: user.name }) %>,
<%= link_to "By IP", user_events_path(search: { user_session: { ip_addr: user.last_ip_addr }}) %>
<% if user.last_ip_addr.present? %>
<%= link_to "By Name", user_events_path(search: { user_name: user.name }) %>,
<%= link_to "By IP", user_events_path(search: { user_session: { ip_addr: user.last_ip_addr }}) %>
<% else %>
<%= link_to "By Name", user_events_path(search: { user_name: user.name }) %>
<% end %>
<td>
</tr>
<% end %>