From a2ea2a65a12fa530d21046a7c952cc6e4814db90 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 17 Nov 2019 02:28:19 -0600 Subject: [PATCH] db: drop IP addresses from certain tables. Don't track IP addresses for post appeals, post flags, tag aliases, tag implications, or user feedbacks. These things are already tightly limited. We don't need IPs from them to detect sockpuppets. --- app/logical/moderator/ip_addr_search.rb | 6 ---- app/models/post_appeal.rb | 3 +- app/models/tag_relationship.rb | 1 - app/views/post_appeals/_reasons.html.erb | 6 ---- app/views/post_flags/_reasons.html.erb | 4 --- ...81229_drop_ip_addrs_from_various_tables.rb | 13 ++++++++ db/structure.sql | 31 ++----------------- test/factories/tag_alias.rb | 1 - test/unit/post_flag_test.rb | 1 - 9 files changed, 17 insertions(+), 49 deletions(-) create mode 100644 db/migrate/20191117081229_drop_ip_addrs_from_various_tables.rb diff --git a/app/logical/moderator/ip_addr_search.rb b/app/logical/moderator/ip_addr_search.rb index c80a441a4..26a7ebe60 100644 --- a/app/logical/moderator/ip_addr_search.rb +++ b/app/logical/moderator/ip_addr_search.rb @@ -28,10 +28,7 @@ module Moderator add_row(sums, WikiPageVersion.where(updater_ip_addr: ip_addrs).group(:updater).count) add_row(sums, Comment.where(creator_ip_addr: ip_addrs).group(:creator).count) add_row(sums, Dmail.where(creator_ip_addr: ip_addrs).group(:from).count) - add_row(sums, PostAppeal.where(creator_ip_addr: ip_addrs).group(:creator).count) - add_row(sums, PostFlag.where(creator_ip_addr: ip_addrs).group(:creator).count) add_row(sums, Upload.where(uploader_ip_addr: ip_addrs).group(:uploader).count) - add_row(sums, UserFeedback.where(creator_ip_addr: ip_addrs).group(:creator).count) add_row(sums, Hash[User.where(last_ip_addr: ip_addrs).collect { |user| [user, 1] }]) add_row_id(sums, PoolArchive.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PoolArchive.enabled? @@ -57,11 +54,8 @@ module Moderator add_row(sums, WikiPageVersion.where(updater: users).group(:updater_ip_addr).count) add_row(sums, Comment.where(creator: users).group(:creator_ip_addr).count) add_row(sums, Dmail.where(from: users).group(:creator_ip_addr).count) - add_row(sums, PostAppeal.where(creator: users).where.not(creator_ip_addr: nil).group(:creator_ip_addr).count) - add_row(sums, PostFlag.where(creator: users).group(:creator_ip_addr).count) add_row(sums, Upload.where(uploader: users).group(:uploader_ip_addr).count) add_row(sums, User.where(id: users).where.not(last_ip_addr: nil).group(:last_ip_addr).count) - add_row(sums, UserFeedback.where(creator_id: users).where.not(creator_ip_addr: nil).group(:creator_ip_addr).count) sums end diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index 371222e94..e55dac75b 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -3,7 +3,7 @@ class PostAppeal < ApplicationRecord belongs_to :creator, :class_name => "User" belongs_to :post - validates_presence_of :reason, :creator_ip_addr + validates_presence_of :reason validate :validate_post_is_inactive validate :validate_creator_is_not_limited before_validation :initialize_creator, :on => :create @@ -60,7 +60,6 @@ class PostAppeal < ApplicationRecord def initialize_creator self.creator_id = CurrentUser.id - self.creator_ip_addr = CurrentUser.ip_addr end def appeal_count_for_creator diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index de18effda..91cce96d6 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -35,7 +35,6 @@ class TagRelationship < ApplicationRecord def initialize_creator self.creator_id = CurrentUser.user.id - self.creator_ip_addr = CurrentUser.ip_addr end def normalize_names diff --git a/app/views/post_appeals/_reasons.html.erb b/app/views/post_appeals/_reasons.html.erb index 4bfdafb74..b5430b2d7 100644 --- a/app/views/post_appeals/_reasons.html.erb +++ b/app/views/post_appeals/_reasons.html.erb @@ -2,13 +2,7 @@ <% appeals.each do |appeal| %>
  • <%= format_text(appeal.reason, inline: true) %> - - <%= link_to_user(appeal.creator) %> - - <% if CurrentUser.is_moderator? %> - (<%= link_to_ip(appeal.creator_ip_addr) %>) - <% end %> - - <%= time_ago_in_words_tagged(appeal.created_at) %>
  • <% end %> diff --git a/app/views/post_flags/_reasons.html.erb b/app/views/post_flags/_reasons.html.erb index df0c20859..18063234e 100644 --- a/app/views/post_flags/_reasons.html.erb +++ b/app/views/post_flags/_reasons.html.erb @@ -5,10 +5,6 @@ <% if CurrentUser.can_view_flagger_on_post?(flag) %> - <%= link_to_user(flag.creator) %> - - <% if CurrentUser.is_moderator? %> - (<%= link_to_ip(flag.creator_ip_addr) %>) - <% end %> <% end %> - <%= time_ago_in_words_tagged(flag.created_at) %> diff --git a/db/migrate/20191117081229_drop_ip_addrs_from_various_tables.rb b/db/migrate/20191117081229_drop_ip_addrs_from_various_tables.rb new file mode 100644 index 000000000..c58327c35 --- /dev/null +++ b/db/migrate/20191117081229_drop_ip_addrs_from_various_tables.rb @@ -0,0 +1,13 @@ +class DropIpAddrsFromVariousTables < ActiveRecord::Migration[6.0] + def change + remove_index :post_appeals, :creator_ip_addr + remove_index :post_flags, :creator_ip_addr + remove_index :user_feedback, :creator_ip_addr + + remove_column :post_appeals, :creator_ip_addr, :inet + remove_column :post_flags, :creator_ip_addr, :inet, null: false + remove_column :tag_aliases, :creator_ip_addr, :inet, null: false + remove_column :tag_implications, :creator_ip_addr, :inet, null: false + remove_column :user_feedback, :creator_ip_addr, :inet + end +end diff --git a/db/structure.sql b/db/structure.sql index 099caa5af..fcb9c9a0d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2580,7 +2580,6 @@ CREATE TABLE public.post_appeals ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, - creator_ip_addr inet, reason text, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL @@ -2680,7 +2679,6 @@ CREATE TABLE public.post_flags ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, - creator_ip_addr inet NOT NULL, reason text, is_resolved boolean DEFAULT false NOT NULL, created_at timestamp without time zone NOT NULL, @@ -2885,7 +2883,6 @@ CREATE TABLE public.tag_aliases ( antecedent_name character varying NOT NULL, consequent_name character varying NOT NULL, creator_id integer NOT NULL, - creator_ip_addr inet NOT NULL, forum_topic_id integer, status text DEFAULT 'pending'::text NOT NULL, created_at timestamp without time zone NOT NULL, @@ -2925,7 +2922,6 @@ CREATE TABLE public.tag_implications ( consequent_name character varying NOT NULL, descendant_names text[] DEFAULT '{}'::text[] NOT NULL, creator_id integer NOT NULL, - creator_ip_addr inet NOT NULL, forum_topic_id integer, status text DEFAULT 'pending'::text NOT NULL, created_at timestamp without time zone NOT NULL, @@ -3063,8 +3059,7 @@ CREATE TABLE public.user_feedback ( category character varying NOT NULL, body text NOT NULL, created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, - creator_ip_addr inet + updated_at timestamp without time zone NOT NULL ); @@ -6640,13 +6635,6 @@ CREATE INDEX index_post_appeals_on_created_at ON public.post_appeals USING btree CREATE INDEX index_post_appeals_on_creator_id ON public.post_appeals USING btree (creator_id); --- --- Name: index_post_appeals_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_post_appeals_on_creator_ip_addr ON public.post_appeals USING btree (creator_ip_addr); - - -- -- Name: index_post_appeals_on_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -6696,13 +6684,6 @@ CREATE INDEX index_post_disapprovals_on_user_id ON public.post_disapprovals USIN CREATE INDEX index_post_flags_on_creator_id ON public.post_flags USING btree (creator_id); --- --- Name: index_post_flags_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_post_flags_on_creator_ip_addr ON public.post_flags USING btree (creator_ip_addr); - - -- -- Name: index_post_flags_on_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -7032,13 +7013,6 @@ CREATE INDEX index_user_feedback_on_created_at ON public.user_feedback USING btr CREATE INDEX index_user_feedback_on_creator_id ON public.user_feedback USING btree (creator_id); --- --- Name: index_user_feedback_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_user_feedback_on_creator_ip_addr ON public.user_feedback USING btree (creator_ip_addr); - - -- -- Name: index_user_feedback_on_user_id; Type: INDEX; Schema: public; Owner: - -- @@ -7429,6 +7403,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20191116021759'), ('20191116224228'), ('20191117074642'), -('20191117080647'); +('20191117080647'), +('20191117081229'); diff --git a/test/factories/tag_alias.rb b/test/factories/tag_alias.rb index 3bedfb9d4..aa879071d 100644 --- a/test/factories/tag_alias.rb +++ b/test/factories/tag_alias.rb @@ -4,6 +4,5 @@ FactoryBot.define do consequent_name {"bbb"} status {"active"} skip_secondary_validations {true} - creator_ip_addr { FFaker::Internet.ip_v4_address } end end diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb index 1eebb857a..43d1efc07 100644 --- a/test/unit/post_flag_test.rb +++ b/test/unit/post_flag_test.rb @@ -140,7 +140,6 @@ class PostFlagTest < ActiveSupport::TestCase PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) end assert_equal(@alice.id, @post_flag.creator_id) - assert_equal(IPAddr.new("127.0.0.1"), @post_flag.creator_ip_addr) end end