A platform for community discussion. Free, open, simple.
SECURITY: BestTopics report includes unlisted topics (#41000)
Penar Musarajc3177d729ecf
diff --git a/plugins/discourse-rewind/app/services/discourse_rewind/action/best_topics.rb b/plugins/discourse-rewind/app/services/discourse_rewind/action/best_topics.rbindex b2865e7bb1a..bd5879227ff 100644--- a/plugins/discourse-rewind/app/services/discourse_rewind/action/best_topics.rb+++ b/plugins/discourse-rewind/app/services/discourse_rewind/action/best_topics.rb@@ -35,7 +35,7 @@ module DiscourseRewind.includes(:topic).references(:topic).joins(topic: :category)- .where(topic: { deleted_at: nil, created_at: date, user_id: user.id })+ .where(topic: { deleted_at: nil, created_at: date, user_id: user.id, visible: true }).where.not(topic: { archetype: Archetype.private_message }).where("NOT categories.read_restricted").order("yearly_score DESC NULLS LAST")diff --git a/plugins/discourse-rewind/spec/actions/best_topics_spec.rb b/plugins/discourse-rewind/spec/actions/best_topics_spec.rbindex 798128ef429..9f51a4c2a2d 100644--- a/plugins/discourse-rewind/spec/actions/best_topics_spec.rb+++ b/plugins/discourse-rewind/spec/actions/best_topics_spec.rb@@ -55,6 +55,19 @@ RSpec.describe DiscourseRewind::Action::BestTopics doendend+ context "when a topic is unlisted" do+ before do+ topic_1.update!(visible: false)+ TopTopic.find_by(topic_id: topic_1.id).update!(yearly_score: 99)+ end++ it "does not expose the topic title or excerpt" do+ topic_ids = call_report[:data].map { |topic| topic[:topic_id] }++ expect(topic_ids).not_to include(topic_1.id)+ end+ end+context "when a topic belongs to another user" dobefore { topic_1.update!(user: Fabricate(:user)) }