Skip to content

Commit f67a7ab

Browse files
committed
Cherry pick:
1. Minitest module fix in tests 2. standard formatting 3. Logger.broadcast fix for ActiveSupport 7.1
1 parent 101435c commit f67a7ab

9 files changed

+34
-18
lines changed

Changes.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/main/Ent-Changes.md)
44

5+
6.5.10
6+
----------
7+
8+
- Web UI DoS vector [#6045] CVE-2023-26141
9+
- Fix broadcast logger with Rails 7.1 [#6054]
10+
511
6.5.9
612
----------
713

lib/sidekiq/rails.rb

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ def inspect
6262
config.after_initialize do
6363
Sidekiq.configure_server do |config|
6464
config[:reloader] = Sidekiq::Rails::Reloader.new
65+
66+
# This is the integration code necessary so that if a job uses `Rails.logger.info "Hello"`,
67+
# it will appear in the Sidekiq console with all of the job context.
68+
unless ::Rails.logger == config.logger || ::ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, $stdout)
69+
if ::Rails::VERSION::STRING < "7.1"
70+
::Rails.logger.extend(::ActiveSupport::Logger.broadcast(config.logger))
71+
else
72+
::Rails.logger = ::ActiveSupport::BroadcastLogger.new(::Rails.logger, config.logger)
73+
end
74+
end
6575
end
6676
end
6777
end

lib/sidekiq/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Sidekiq
4-
VERSION = "6.5.9"
4+
VERSION = "6.5.10"
55
end

test/test_client.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,15 @@ class DWorker < BaseWorker
440440
end
441441

442442
it "allows sidekiq_options to point to different Redi" do
443-
conn = MiniTest::Mock.new
443+
conn = Minitest::Mock.new
444444
conn.expect(:pipelined, [0, 1])
445445
DWorker.sidekiq_options("pool" => ConnectionPool.new(size: 1) { conn })
446446
DWorker.perform_async(1, 2, 3)
447447
conn.verify
448448
end
449449

450450
it "allows #via to point to same Redi" do
451-
conn = MiniTest::Mock.new
451+
conn = Minitest::Mock.new
452452
conn.expect(:pipelined, [0, 1])
453453
sharded_pool = ConnectionPool.new(size: 1) { conn }
454454
Sidekiq::Client.via(sharded_pool) do
@@ -462,11 +462,11 @@ class DWorker < BaseWorker
462462
it "allows #via to point to different Redi" do
463463
default = Sidekiq::Client.new.redis_pool
464464

465-
moo = MiniTest::Mock.new
465+
moo = Minitest::Mock.new
466466
moo.expect(:pipelined, [0, 1])
467467
beef = ConnectionPool.new(size: 1) { moo }
468468

469-
oink = MiniTest::Mock.new
469+
oink = Minitest::Mock.new
470470
oink.expect(:pipelined, [0, 1])
471471
pork = ConnectionPool.new(size: 1) { oink }
472472

@@ -485,7 +485,7 @@ class DWorker < BaseWorker
485485
end
486486

487487
it "allows Resque helpers to point to different Redi" do
488-
conn = MiniTest::Mock.new
488+
conn = Minitest::Mock.new
489489
conn.expect(:pipelined, []) { |*args, &block| block.call(conn) }
490490
conn.expect(:zadd, 1, [String, Array])
491491
DWorker.sidekiq_options("pool" => ConnectionPool.new(size: 1) { conn })

test/test_csrf.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require_relative "./helper"
3+
require_relative "helper"
44
require "sidekiq/web/csrf_protection"
55

66
describe "Csrf" do

test/test_current_attributes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require_relative "./helper"
3+
require_relative "helper"
44
require "sidekiq/middleware/current_attributes"
55
require "sidekiq/fetch"
66

test/test_processor.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def call(worker, item, queue)
156156
let(:raise_after_yield) { false }
157157
let(:skip_job) { false }
158158
let(:worker_args) { ["myarg"] }
159-
let(:work) { MiniTest::Mock.new }
159+
let(:work) { Minitest::Mock.new }
160160

161161
before do
162162
work.expect(:queue_name, "queue:default")

test/test_transaction_aware_client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require "sidekiq/rails"
66
require "sidekiq/transaction_aware_client"
77

8-
require_relative "./dummy/config/environment"
8+
require_relative "dummy/config/environment"
99

1010
class Schema < ActiveRecord::Migration["6.1"]
1111
def change

test/test_web.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def perform(a, b)
293293

294294
get "/retries"
295295
assert_equal 200, last_response.status
296-
refute_match(/#{params.first['args'][2]}/, last_response.body)
296+
refute_match(/#{params.first["args"][2]}/, last_response.body)
297297
end
298298

299299
it "can delete all retries" do
@@ -313,7 +313,7 @@ def perform(a, b)
313313

314314
get "/queues/default"
315315
assert_equal 200, last_response.status
316-
assert_match(/#{params.first['args'][2]}/, last_response.body)
316+
assert_match(/#{params.first["args"][2]}/, last_response.body)
317317
end
318318

319319
it "can kill a single retry now" do
@@ -324,7 +324,7 @@ def perform(a, b)
324324

325325
get "/morgue"
326326
assert_equal 200, last_response.status
327-
assert_match(/#{params.first['args'][2]}/, last_response.body)
327+
assert_match(/#{params.first["args"][2]}/, last_response.body)
328328
end
329329

330330
it "can display scheduled" do
@@ -370,7 +370,7 @@ def perform(a, b)
370370

371371
get "/queues/default"
372372
assert_equal 200, last_response.status
373-
assert_match(/#{params.first['args'][2]}/, last_response.body)
373+
assert_match(/#{params.first["args"][2]}/, last_response.body)
374374
end
375375

376376
it "can delete a single scheduled job" do
@@ -381,7 +381,7 @@ def perform(a, b)
381381

382382
get "/scheduled"
383383
assert_equal 200, last_response.status
384-
refute_match(/#{params.first['args'][2]}/, last_response.body)
384+
refute_match(/#{params.first["args"][2]}/, last_response.body)
385385
end
386386

387387
it "can delete scheduled" do
@@ -408,7 +408,7 @@ def perform(a, b)
408408
assert_equal 1, q.size
409409
get "/queues/default"
410410
assert_equal 200, last_response.status
411-
assert_match(/#{params[0]['args'][2]}/, last_response.body)
411+
assert_match(/#{params[0]["args"][2]}/, last_response.body)
412412
end
413413
end
414414

@@ -423,7 +423,7 @@ def perform(a, b)
423423

424424
get "/queues/default"
425425
assert_equal 200, last_response.status
426-
assert_match(/#{msg['args'][2]}/, last_response.body)
426+
assert_match(/#{msg["args"][2]}/, last_response.body)
427427
end
428428

429429
it "escape job args and error messages" do
@@ -629,7 +629,7 @@ def perform(a, b)
629629

630630
get "/queues/foo"
631631
assert_equal 200, last_response.status
632-
assert_match(/#{params.first['args'][2]}/, last_response.body)
632+
assert_match(/#{params.first["args"][2]}/, last_response.body)
633633
end
634634
end
635635

0 commit comments

Comments
 (0)