sidekiq 7.2.2 → 7.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67dd3e4a49f94aa711fa9baa0caac22c992b5c0a6a04a1cade9426f9a4a9341b
4
- data.tar.gz: 224649c4a61110b9600f70f3ccd568360642e74330fc7503f6ac03bc57f638dd
3
+ metadata.gz: 6c43e6b585c25dcfc8ef8364bb36cf74f9167b981ad03faa3a8d76e0d45ebe55
4
+ data.tar.gz: d8c65dc03008f7280b36af94db753d4c7f68267c2eb0d78cd018322887aabbb0
5
5
  SHA512:
6
- metadata.gz: 20154e18f4d51e19b68946543f4523ac452f463ef7b8f2e4445bdb1d2bf518902e94edefc9d2a4f5771c33bdc5003b5b4b55fab05495d7756f90ebdc0bfbe0b9
7
- data.tar.gz: 510fa35d3b8657b1e8e6b23bc940d0a32ae64d0e09331981728b23ea1548d2b000f1943ee39b2b2459500d86c4b3a3cd9a8bf2142ebd82ecdbdbfac75a0d521f
6
+ metadata.gz: d2687692b873ab82bda2ad32e9be795150cd0a8d3d330bc19f5b509ba729bef33189e06ebac86b1906c2682187391d6cf0d532e47d03fcbea83058109c5816ef
7
+ data.tar.gz: 431a482baeb03fc4de50fbdfba8717fc332a9d6564fde98a77699a7bd174fa3194431385951cf689c64e04853039c95fcf287084f283e8d381b3b37d5bc665e0
data/Changes.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
- HEAD
5
+ 7.2.4
6
+ ----------
7
+
8
+ - Fix XSS in metrics filtering introduced in 7.2.0, CVE-2024-32887
9
+ Thanks to @UmerAdeemCheema for the security report.
10
+
11
+ 7.2.3
12
+ ----------
13
+
14
+ - [Support Dragonfly.io](https://www.mikeperham.com/2024/02/01/supporting-dragonfly/) as an alternative Redis implementation
15
+ - Fix error unpacking some compressed error backtraces [#6241]
16
+ - Fix potential heartbeat data leak [#6227]
17
+ - Add ability to find a currently running work by jid [#6212, fatkodima]
18
+
19
+ 7.2.2
6
20
  ----------
7
21
 
8
22
  - Add `Process.warmup` call in Ruby 3.3+
data/lib/sidekiq/api.rb CHANGED
@@ -490,7 +490,7 @@ module Sidekiq
490
490
  end
491
491
 
492
492
  def uncompress_backtrace(backtrace)
493
- strict_base64_decoded = backtrace.unpack1("m0")
493
+ strict_base64_decoded = backtrace.unpack1("m")
494
494
  uncompressed = Zlib::Inflate.inflate(strict_base64_decoded)
495
495
  Sidekiq.load_json(uncompressed)
496
496
  end
@@ -1136,6 +1136,20 @@ module Sidekiq
1136
1136
  end
1137
1137
  end
1138
1138
  end
1139
+
1140
+ ##
1141
+ # Find the work which represents a job with the given JID.
1142
+ # *This is a slow O(n) operation*. Do not use for app logic.
1143
+ #
1144
+ # @param jid [String] the job identifier
1145
+ # @return [Sidekiq::Work] the work or nil
1146
+ def find_work_by_jid(jid)
1147
+ each do |_process_id, _thread_id, work|
1148
+ job = work.job
1149
+ return work if job.jid == jid
1150
+ end
1151
+ nil
1152
+ end
1139
1153
  end
1140
1154
 
1141
1155
  # Sidekiq::Work represents a job which is currently executing.
@@ -34,7 +34,7 @@ module Sidekiq
34
34
  # handle an very common error in marking deploys:
35
35
  # having every process mark its deploy, leading
36
36
  # to N marks for each deploy. Instead we round the time
37
- # to the minute so that multple marks within that minute
37
+ # to the minute so that multiple marks within that minute
38
38
  # will all naturally rollup into one mark per minute.
39
39
  whence = at.utc
40
40
  floor = Time.utc(whence.year, whence.month, whence.mday, whence.hour, whence.min, 0)
@@ -145,15 +145,17 @@ module Sidekiq
145
145
  flush_stats
146
146
 
147
147
  curstate = Processor::WORK_STATE.dup
148
+ curstate.transform_values! { |val| Sidekiq.dump_json(val) }
149
+
148
150
  redis do |conn|
149
151
  # work is the current set of executing jobs
150
152
  work_key = "#{key}:work"
151
- conn.pipelined do |transaction|
153
+ conn.multi do |transaction|
152
154
  transaction.unlink(work_key)
153
- curstate.each_pair do |tid, hash|
154
- transaction.hset(work_key, tid, Sidekiq.dump_json(hash))
155
+ if curstate.size > 0
156
+ transaction.hset(work_key, curstate)
157
+ transaction.expire(work_key, 60)
155
158
  end
156
- transaction.expire(work_key, 60)
157
159
  end
158
160
  end
159
161
 
@@ -187,7 +187,7 @@ module Sidekiq
187
187
  # we didn't properly finish it.
188
188
  rescue Sidekiq::JobRetry::Handled => h
189
189
  # this is the common case: job raised error and Sidekiq::JobRetry::Handled
190
- # signals that we created a retry successfully. We can acknowlege the job.
190
+ # signals that we created a retry successfully. We can acknowledge the job.
191
191
  ack = true
192
192
  e = h.cause || h
193
193
  handle_exception(e, {context: "Job raised exception", job: job_hash})
data/lib/sidekiq/rails.rb CHANGED
@@ -22,7 +22,7 @@ module Sidekiq
22
22
  end
23
23
 
24
24
  def to_hash
25
- { app: @app.class.name }
25
+ {app: @app.class.name}
26
26
  end
27
27
  end
28
28
 
@@ -32,8 +32,8 @@ module Sidekiq
32
32
  zremrangebyrank zremrangebyscore]
33
33
 
34
34
  USED_COMMANDS.each do |name|
35
- define_method(name) do |*args|
36
- @client.call(name, *args)
35
+ define_method(name) do |*args, **kwargs|
36
+ @client.call(name, *args, **kwargs)
37
37
  end
38
38
  end
39
39
 
@@ -144,7 +144,7 @@ module Sidekiq
144
144
  # In the example above, each process should schedule every 10 seconds on average. We special
145
145
  # case smaller clusters to add 50% so they would sleep somewhere between 5 and 15 seconds.
146
146
  # As we run more processes, the scheduling interval average will approach an even spread
147
- # between 0 and poll interval so we don't need this artifical boost.
147
+ # between 0 and poll interval so we don't need this artificial boost.
148
148
  #
149
149
  count = process_count
150
150
  interval = poll_interval_average(count)
@@ -112,7 +112,7 @@ module Sidekiq
112
112
  # The Queues class is only for testing the fake queue implementation.
113
113
  # There are 2 data structures involved in tandem. This is due to the
114
114
  # Rspec syntax of change(HardJob.jobs, :size). It keeps a reference
115
- # to the array. Because the array was dervied from a filter of the total
115
+ # to the array. Because the array was derived from a filter of the total
116
116
  # jobs enqueued, it appeared as though the array didn't change.
117
117
  #
118
118
  # To solve this, we'll keep 2 hashes containing the jobs. One with keys based
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.2.2"
4
+ VERSION = "7.2.4"
5
5
  MAJOR = 7
6
6
  end
@@ -22,6 +22,11 @@ module Sidekiq
22
22
  throw :halt, [302, {Web::LOCATION => "#{request.base_url}#{location}"}, []]
23
23
  end
24
24
 
25
+ def reload_page
26
+ current_location = request.referer.gsub(request.base_url, "")
27
+ redirect current_location
28
+ end
29
+
25
30
  def params
26
31
  indifferent_hash = Hash.new { |hash, key| hash[key.to_s] if Symbol === key }
27
32
 
@@ -49,9 +49,9 @@ module Sidekiq
49
49
 
50
50
  head "/" do
51
51
  # HEAD / is the cheapest heartbeat possible,
52
- # it hits Redis to ensure connectivity
53
- Sidekiq.redis { |c| c.llen("queue:default") }
54
- ""
52
+ # it hits Redis to ensure connectivity and returns
53
+ # the size of the default queue
54
+ Sidekiq.redis { |c| c.llen("queue:default") }.to_s
55
55
  end
56
56
 
57
57
  get "/" do
@@ -394,6 +394,18 @@ module Sidekiq
394
394
  erb :morgue
395
395
  end
396
396
 
397
+ post "/change_locale" do
398
+ locale = params["locale"]
399
+
400
+ match = available_locales.find { |available|
401
+ locale == available
402
+ }
403
+
404
+ session[:locale] = match if match
405
+
406
+ reload_page
407
+ end
408
+
397
409
  def call(env)
398
410
  action = self.class.match(env)
399
411
  return [404, {Rack::CONTENT_TYPE => "text/plain", Web::X_CASCADE => "pass"}, ["Not Found"]] unless action
@@ -115,7 +115,7 @@ module Sidekiq
115
115
  sess = session(env)
116
116
  localtoken = sess[:csrf]
117
117
 
118
- # Checks that Rack::Session::Cookie actualy contains the csrf toekn
118
+ # Checks that Rack::Session::Cookie actually contains the csrf token
119
119
  return false if localtoken.nil?
120
120
 
121
121
  # Rotate the session token after every use
@@ -121,6 +121,10 @@ module Sidekiq
121
121
  #
122
122
  # Inspiration taken from https://github.com/iain/http_accept_language/blob/master/lib/http_accept_language/parser.rb
123
123
  def locale
124
+ # session[:locale] is set via the locale selector from the footer
125
+ # defined?(session) && session are used to avoid exceptions when running tests
126
+ return session[:locale] if defined?(session) && session&.[](:locale)
127
+
124
128
  @locale ||= begin
125
129
  matched_locale = user_preferred_languages.map { |preferred|
126
130
  preferred_language = preferred.split("-", 2).first
@@ -340,7 +344,8 @@ module Sidekiq
340
344
  end
341
345
 
342
346
  def pollable?
343
- !(current_path == "" || current_path.start_with?("metrics"))
347
+ # there's no point to refreshing the metrics pages every N seconds
348
+ !(current_path == "" || current_path.index("metrics"))
344
349
  end
345
350
 
346
351
  def retry_or_delete_or_kill(job, params)
@@ -47,6 +47,8 @@ function addListeners() {
47
47
  scheduleLivePoll();
48
48
  }
49
49
  }
50
+
51
+ document.getElementById("locale-select").addEventListener("change", updateLocale);
50
52
  }
51
53
 
52
54
  function addPollingListeners(_event) {
@@ -175,3 +177,7 @@ function replacePage(text) {
175
177
  function showError(error) {
176
178
  console.error(error)
177
179
  }
180
+
181
+ function updateLocale(event) {
182
+ event.target.form.submit();
183
+ };
@@ -151,3 +151,13 @@ div.interval-slider {
151
151
  padding-left: 5px;
152
152
  }
153
153
  }
154
+
155
+ #locale-select {
156
+ float: right;
157
+ }
158
+
159
+ @media (max-width: 767px) {
160
+ #locale-select {
161
+ float: none;
162
+ }
163
+ }
@@ -731,3 +731,16 @@ div.interval-slider input {
731
731
  canvas {
732
732
  margin: 20px 0 30px;
733
733
  }
734
+
735
+ #locale-select {
736
+ float: left;
737
+ margin: 8px 15px;
738
+ }
739
+
740
+ @media (max-width: 767px) {
741
+ #locale-select {
742
+ float: none;
743
+ width: auto;
744
+ margin: 15px auto;
745
+ }
746
+ }
@@ -15,7 +15,19 @@
15
15
  <p class="navbar-text"><a rel=help href="https://github.com/sidekiq/sidekiq/wiki">docs</a></p>
16
16
  </li>
17
17
  <li>
18
- <p class="navbar-text"><a rel=external href="https://github.com/sidekiq/sidekiq/tree/main/web/locales"><%= locale %></a></p>
18
+ <form id="locale-form" class="form-inline" action="<%= root_path %>change_locale" method="post">
19
+ <%= csrf_tag %>
20
+ <label class="sr-only" for="locale">Language</label>
21
+ <select id="locale-select" class="form-control" name="locale">
22
+ <% available_locales.each do |locale_option| %>
23
+ <% if locale_option == locale %>
24
+ <option selected value="<%= locale_option %>"><%= locale_option %></option>
25
+ <% else %>
26
+ <option value="<%= locale_option %>"><%= locale_option %></option>
27
+ <% end %>
28
+ <% end %>
29
+ </select>
30
+ </form>
19
31
  </li>
20
32
  </ul>
21
33
  </div>
@@ -12,7 +12,7 @@
12
12
  <form id="metrics-form" class="form-inline" action="<%= root_path %>filter/metrics" method="post">
13
13
  <%= csrf_tag %>
14
14
  <label for="substr"><%= t('Filter') %></label>
15
- <input id="class-filter" class="form-control" type="text" name="substr" placeholder="<%= t('Name') %>" value="<%= params[:substr] %>">
15
+ <input id="class-filter" class="form-control" type="text" name="substr" placeholder="<%= t('Name') %>" value="<%= h params[:substr] %>">
16
16
  <select id="period-selector" class="form-control" name="period">
17
17
  <% @periods.each_key do |code| %>
18
18
  <% if code == @period %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.2
4
+ version: 7.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-16 00:00:00.000000000 Z
11
+ date: 2024-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client