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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
<% appeals.each do |appeal| %>
|
||||
<li class="post-appeal-reason">
|
||||
<span class="prose"><%= format_text(appeal.reason, inline: true) %></span>
|
||||
|
||||
- <%= 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) %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -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) %>
|
||||
|
||||
@@ -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
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user