A platform for community discussion. Free, open, simple.
SECURITY: Local onebox handler now applies public visibility policy to shared AI conver... (#42960)
Sambec923144b76
diff --git a/plugins/discourse-ai/lib/ai_bot/entry_point.rb b/plugins/discourse-ai/lib/ai_bot/entry_point.rbindex 1d8cea5b784..d11ef5e784c 100644--- a/plugins/discourse-ai/lib/ai_bot/entry_point.rb+++ b/plugins/discourse-ai/lib/ai_bot/entry_point.rb@@ -170,7 +170,7 @@ module DiscourseAi) do |url, route|if route[:action] == "show" && share_key = route[:share_key]if conversation = SharedAiConversation.find_by(share_key: share_key)- conversation.onebox+ conversation.onebox if conversation.publicly_visible?endendenddiff --git a/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rbindex 3fbbe7a7409..1a29f03155f 100644--- a/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb@@ -12,6 +12,7 @@ RSpec.describe DiscourseAi::AiBot::SharedAiConversationsController dofab!(:claude_2) { Fabricate(:llm_model, name: "claude-2") }fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }+ fab!(:attacker) { Fabricate(:user, refresh_auto_groups: true) }fab!(:topic)fab!(:pm, :private_message_topic)fab!(:user_pm) { Fabricate(:private_message_topic, recipient: user) }@@ -433,6 +434,21 @@ RSpec.describe DiscourseAi::AiBot::SharedAiConversationsController doendend+ describe "GET /onebox" do+ it "does not expose a trashed conversation through a local onebox preview" do+ source_post = user_pm_share.posts.last+ source_post.update!(raw: "private transcript excerpt")+ conversation = SharedAiConversation.share_conversation(user, user_pm_share)+ user_pm_share.trash!++ sign_in(attacker)+ get "/onebox.json", params: { url: conversation.url }++ expect(response).to have_http_status(:success)+ expect(response.body).not_to include(source_post.raw)+ end+ end+describe "GET show" doit "redirects to home page if site require login" doSiteSetting.login_required = true