1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Move payload json verification after middleware, fixes #5246

This commit is contained in:
Mike Perham 2022-03-17 10:42:33 -07:00
parent e2c3e2c704
commit a8c4966cdc
3 changed files with 5 additions and 0 deletions

View file

@ -5,6 +5,7 @@
HEAD HEAD
--------- ---------
- Strict argument checking now runs after client-side middleware [#5246]
- Fix page events with live polling [#5184] - Fix page events with live polling [#5184]
- Many under-the-hood changes to remove all usage of the term "worker" - Many under-the-hood changes to remove all usage of the term "worker"
from the Sidekiq codebase and APIs. This mostly involved RDoc and local from the Sidekiq codebase and APIs. This mostly involved RDoc and local

View file

@ -75,6 +75,7 @@ module Sidekiq
normed normed
end end
if payload if payload
verify_json(payload)
raw_push([payload]) raw_push([payload])
payload["jid"] payload["jid"]
end end
@ -110,6 +111,7 @@ module Sidekiq
copy = normed.merge("args" => job_args, "jid" => SecureRandom.hex(12)) copy = normed.merge("args" => job_args, "jid" => SecureRandom.hex(12))
copy["at"] = (at.is_a?(Array) ? at[index] : at) if at copy["at"] = (at.is_a?(Array) ? at[index] : at) if at
result = middleware.invoke(copy["class"], copy, copy["queue"], @redis_pool) do result = middleware.invoke(copy["class"], copy, copy["queue"], @redis_pool) do
verify_json(copy)
copy copy
end end
result || nil result || nil

View file

@ -12,7 +12,9 @@ module Sidekiq
raise(ArgumentError, "Job class must be either a Class or String representation of the class name: `#{item}`") unless item["class"].is_a?(Class) || item["class"].is_a?(String) raise(ArgumentError, "Job class must be either a Class or String representation of the class name: `#{item}`") unless item["class"].is_a?(Class) || item["class"].is_a?(String)
raise(ArgumentError, "Job 'at' must be a Numeric timestamp: `#{item}`") if item.key?("at") && !item["at"].is_a?(Numeric) raise(ArgumentError, "Job 'at' must be a Numeric timestamp: `#{item}`") if item.key?("at") && !item["at"].is_a?(Numeric)
raise(ArgumentError, "Job tags must be an Array: `#{item}`") if item["tags"] && !item["tags"].is_a?(Array) raise(ArgumentError, "Job tags must be an Array: `#{item}`") if item["tags"] && !item["tags"].is_a?(Array)
end
def verify_json(item)
job_class = item["wrapped"] || item["class"] job_class = item["wrapped"] || item["class"]
if Sidekiq.options[:on_complex_arguments] == :raise if Sidekiq.options[:on_complex_arguments] == :raise
msg = <<~EOM msg = <<~EOM