sidekiq 8.0.8 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +42 -0
  3. data/README.md +15 -0
  4. data/bin/lint-herb +13 -0
  5. data/lib/generators/sidekiq/templates/job.rb.erb +1 -1
  6. data/lib/sidekiq/api.rb +28 -5
  7. data/lib/sidekiq/capsule.rb +4 -0
  8. data/lib/sidekiq/cli.rb +16 -4
  9. data/lib/sidekiq/config.rb +8 -2
  10. data/lib/sidekiq/fetch.rb +1 -0
  11. data/lib/sidekiq/job/iterable.rb +2 -2
  12. data/lib/sidekiq/job.rb +2 -0
  13. data/lib/sidekiq/job_logger.rb +4 -2
  14. data/lib/sidekiq/job_retry.rb +7 -3
  15. data/lib/sidekiq/launcher.rb +18 -9
  16. data/lib/sidekiq/middleware/i18n.rb +2 -0
  17. data/lib/sidekiq/monitor.rb +4 -8
  18. data/lib/sidekiq/profiler.rb +1 -0
  19. data/lib/sidekiq/redis_connection.rb +2 -2
  20. data/lib/sidekiq/ring_buffer.rb +1 -0
  21. data/lib/sidekiq/scheduled.rb +7 -5
  22. data/lib/sidekiq/version.rb +1 -1
  23. data/lib/sidekiq/web/action.rb +1 -1
  24. data/lib/sidekiq/web/application.rb +10 -0
  25. data/lib/sidekiq/web/config.rb +3 -6
  26. data/lib/sidekiq/web/helpers.rb +3 -11
  27. data/lib/sidekiq/web.rb +23 -4
  28. data/sidekiq.gemspec +5 -5
  29. data/web/assets/javascripts/application.js +17 -1
  30. data/web/assets/stylesheets/style.css +17 -2
  31. data/web/locales/ar.yml +1 -0
  32. data/web/locales/cs.yml +1 -0
  33. data/web/locales/da.yml +1 -0
  34. data/web/locales/de.yml +1 -0
  35. data/web/locales/el.yml +1 -0
  36. data/web/locales/en.yml +1 -0
  37. data/web/locales/es.yml +1 -0
  38. data/web/locales/fa.yml +1 -0
  39. data/web/locales/fr.yml +2 -1
  40. data/web/locales/gd.yml +1 -0
  41. data/web/locales/he.yml +1 -0
  42. data/web/locales/hi.yml +1 -0
  43. data/web/locales/it.yml +1 -0
  44. data/web/locales/ja.yml +1 -0
  45. data/web/locales/ko.yml +1 -0
  46. data/web/locales/lt.yml +1 -0
  47. data/web/locales/nb.yml +1 -0
  48. data/web/locales/nl.yml +1 -0
  49. data/web/locales/pl.yml +1 -0
  50. data/web/locales/pt-BR.yml +1 -0
  51. data/web/locales/pt.yml +1 -0
  52. data/web/locales/ru.yml +1 -0
  53. data/web/locales/sv.yml +1 -0
  54. data/web/locales/ta.yml +1 -0
  55. data/web/locales/tr.yml +1 -0
  56. data/web/locales/uk.yml +1 -0
  57. data/web/locales/ur.yml +1 -0
  58. data/web/locales/vi.yml +1 -0
  59. data/web/locales/zh-CN.yml +1 -0
  60. data/web/locales/zh-TW.yml +1 -0
  61. data/web/views/{_footer.erb → _footer.html.erb} +1 -1
  62. data/web/views/{_metrics_period_select.erb → _metrics_period_select.html.erb} +1 -1
  63. data/web/views/{_paging.erb → _paging.html.erb} +0 -1
  64. data/web/views/_poll_link.html.erb +4 -0
  65. data/web/views/{busy.erb → busy.html.erb} +4 -8
  66. data/web/views/{dashboard.erb → dashboard.html.erb} +3 -3
  67. data/web/views/{dead.erb → dead.html.erb} +3 -3
  68. data/web/views/filtering.html.erb +6 -0
  69. data/web/views/{layout.erb → layout.html.erb} +7 -7
  70. data/web/views/{metrics.erb → metrics.html.erb} +9 -8
  71. data/web/views/{morgue.erb → morgue.html.erb} +8 -4
  72. data/web/views/{queue.erb → queue.html.erb} +2 -2
  73. data/web/views/{queues.erb → queues.html.erb} +4 -4
  74. data/web/views/{retries.erb → retries.html.erb} +9 -5
  75. data/web/views/{retry.erb → retry.html.erb} +2 -2
  76. data/web/views/{scheduled.erb → scheduled.html.erb} +8 -4
  77. data/web/views/{scheduled_job_info.erb → scheduled_job_info.html.erb} +2 -2
  78. metadata +34 -34
  79. data/lib/sidekiq/web/csrf_protection.rb +0 -183
  80. data/web/views/_poll_link.erb +0 -4
  81. data/web/views/filtering.erb +0 -6
  82. /data/web/views/{_job_info.erb → _job_info.html.erb} +0 -0
  83. /data/web/views/{_nav.erb → _nav.html.erb} +0 -0
  84. /data/web/views/{_summary.erb → _summary.html.erb} +0 -0
  85. /data/web/views/{metrics_for_job.erb → metrics_for_job.html.erb} +0 -0
  86. /data/web/views/{profiles.erb → profiles.html.erb} +0 -0
@@ -45,8 +45,8 @@
45
45
  <td>
46
46
  <form action="<%= root_path %>queues/<%= CGI.escape(@name) %>/delete" method="post">
47
47
  <%= csrf_tag %>
48
- <input name="key_val" value="<%= h job.value %>" type="hidden" />
49
- <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
48
+ <input name="key_val" value="<%= h job.value %>" type="hidden">
49
+ <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>">
50
50
  </form>
51
51
  </td>
52
52
  </tr>
@@ -26,15 +26,15 @@
26
26
  <%= number_with_delimiter(queue_latency, precision: 2) %>
27
27
  </td>
28
28
  <td class="delete-confirm">
29
- <form action="<%=root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
29
+ <form action="<%= root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
30
30
  <%= csrf_tag %>
31
- <input class="btn btn-danger" type="submit" name="delete" title="This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future." value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>" />
31
+ <input class="btn btn-danger" type="submit" name="delete" title="This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future." value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>">
32
32
 
33
33
  <% if Sidekiq.pro? %>
34
34
  <% if queue.paused? %>
35
- <input class="btn btn-danger" type="submit" name="unpause" value="<%= t('Unpause') %>" />
35
+ <input class="btn btn-danger" type="submit" name="unpause" value="<%= t('Unpause') %>">
36
36
  <% else %>
37
- <input class="btn btn-danger" type="submit" name="pause" value="<%= t('Pause') %>" />
37
+ <input class="btn btn-danger" type="submit" name="pause" value="<%= t('Pause') %>">
38
38
  <% end %>
39
39
  <% end %>
40
40
  </form>
@@ -16,7 +16,7 @@
16
16
  <tr>
17
17
  <th>
18
18
  <label>
19
- <input type="checkbox" class="check_all" />
19
+ <input type="checkbox" class="check_all check-all-items">
20
20
  </label>
21
21
  </th>
22
22
  <th><%= t('NextRetry') %></th>
@@ -31,7 +31,7 @@
31
31
  <tr>
32
32
  <td>
33
33
  <label>
34
- <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' class='shift_clickable' />
34
+ <input type="checkbox" name="key[]" value="<%= job_params(entry.item, entry.score) %>" class="shift_clickable select-item-checkbox">
35
35
  </label>
36
36
  </td>
37
37
  <td>
@@ -58,9 +58,13 @@
58
58
  </table>
59
59
  </div>
60
60
  <div class="buttons-row">
61
- <input class="btn btn-primary" type="submit" name="retry" value="<%= t('RetryNow') %>" />
62
- <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" />
63
- <input class="btn btn-danger" type="submit" name="kill" value="<%= t('Kill') %>" />
61
+ <input class="btn btn-primary" type="submit" name="retry" value="<%= t('RetryNow') %>">
62
+ <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>">
63
+ <input class="btn btn-danger" type="submit" name="kill" value="<%= t('Kill') %>">
64
+ <!-- Retry all -->
65
+ <button class="btn btn-primary bulk-action-buttons bulk-lead-button" type="submit" name="action" value="retry_all" formaction="<%= "#{root_path}retries/all/retry" %>"><%= t('RetryAll') %></button>
66
+ <button class="btn btn-danger bulk-action-buttons" type="submit" name="action" value="delete_all" formaction="<%= "#{root_path}retries/all/delete" %>" data-confirm="<%= t('AreYouSure') %>"><%= t('DeleteAll') %></button>
67
+ <button class="btn btn-danger bulk-action-buttons" type="submit" name="action" value="kill_all" formaction="<%= "#{root_path}retries/all/kill" %>"><%= t('KillAll') %></button>
64
68
  </div>
65
69
  </form>
66
70
 
@@ -33,7 +33,7 @@
33
33
  <form action="<%= root_path %>retries/<%= job_params(@retry, @retry.score) %>" method="post">
34
34
  <%= csrf_tag %>
35
35
  <a class="btn btn-default" href="<%= root_path %>retries"><%= t('GoBack') %></a>
36
- <input class="btn btn-primary" type="submit" name="retry" value="<%= t('RetryNow') %>" />
37
- <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" />
36
+ <input class="btn btn-primary" type="submit" name="retry" value="<%= t('RetryNow') %>">
37
+ <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>">
38
38
  </form>
39
39
  </section>
@@ -16,7 +16,7 @@
16
16
  <tr>
17
17
  <th>
18
18
  <label>
19
- <input type="checkbox" class="check_all" />
19
+ <input type="checkbox" class="check_all check-all-items">
20
20
  </label>
21
21
  </th>
22
22
  <th><%= t('When') %></th>
@@ -29,7 +29,7 @@
29
29
  <tr>
30
30
  <td>
31
31
  <label>
32
- <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' class='shift_clickable' />
32
+ <input type="checkbox" name="key[]" value="<%= job_params(entry.item, entry.score) %>" class="shift_clickable select-item-checkbox">
33
33
  </label>
34
34
  </td>
35
35
  <td>
@@ -51,8 +51,12 @@
51
51
  <% end %>
52
52
  </table>
53
53
  </div>
54
- <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" />
55
- <input class="btn btn-danger" type="submit" name="add_to_queue" value="<%= t('AddToQueue') %>" />
54
+ <div class="buttons-row">
55
+ <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>">
56
+ <input class="btn btn-danger" type="submit" name="add_to_queue" value="<%= t('AddToQueue') %>">
57
+ <button class="btn btn-danger bulk-action-buttons bulk-lead-button" type="submit" name="action" value="delete_all" formaction="<%= "#{root_path}scheduled/all/delete" %>" data-confirm="<%= t('AreYouSure') %>"><%= t('DeleteAll') %></button>
58
+ <button class="btn btn-danger bulk-action-buttons" type="submit" name="action" value="add_all_to_queue" formaction="<%= "#{root_path}scheduled/all/add_to_queue" %>"><%= t('AddAllToQueue') %></button>
59
+ </div>
56
60
  </form>
57
61
  <% else %>
58
62
  <div class="alert alert-success"><%= t('NoScheduledFound') %></div>
@@ -3,6 +3,6 @@
3
3
  <form action="<%= root_path %>scheduled/<%= job_params(@job, @job.score) %>" method="post">
4
4
  <%= csrf_tag %>
5
5
  <a class="btn btn-default" href="<%= root_path %>scheduled"><%= t('GoBack') %></a>
6
- <input class="btn btn-primary" type="submit" name="add_to_queue" value="<%= t('AddToQueue') %>" />
7
- <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>" />
6
+ <input class="btn btn-primary" type="submit" name="add_to_queue" value="<%= t('AddToQueue') %>">
7
+ <input class="btn btn-danger" type="submit" name="delete" value="<%= t('Delete') %>">
8
8
  </form>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.8
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
@@ -15,70 +15,70 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.23.2
18
+ version: 0.26.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.23.2
25
+ version: 0.26.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: connection_pool
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.5.0
32
+ version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 2.5.0
39
+ version: 3.0.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rack
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 3.1.0
46
+ version: 3.2.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 3.1.0
53
+ version: 3.2.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: json
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 2.9.0
60
+ version: 2.16.0
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 2.9.0
67
+ version: 2.16.0
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: logger
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 1.6.2
74
+ version: 1.7.0
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 1.6.2
81
+ version: 1.7.0
82
82
  description: Simple, efficient background processing for Ruby.
83
83
  email:
84
84
  - info@contribsys.com
@@ -91,6 +91,7 @@ files:
91
91
  - Changes.md
92
92
  - LICENSE.txt
93
93
  - README.md
94
+ - bin/lint-herb
94
95
  - bin/multi_queue_bench
95
96
  - bin/sidekiq
96
97
  - bin/sidekiqload
@@ -151,7 +152,6 @@ files:
151
152
  - lib/sidekiq/web/action.rb
152
153
  - lib/sidekiq/web/application.rb
153
154
  - lib/sidekiq/web/config.rb
154
- - lib/sidekiq/web/csrf_protection.rb
155
155
  - lib/sidekiq/web/helpers.rb
156
156
  - lib/sidekiq/web/router.rb
157
157
  - lib/sidekiq/worker_compatibility_alias.rb
@@ -199,28 +199,28 @@ files:
199
199
  - web/locales/vi.yml
200
200
  - web/locales/zh-CN.yml
201
201
  - web/locales/zh-TW.yml
202
- - web/views/_footer.erb
203
- - web/views/_job_info.erb
204
- - web/views/_metrics_period_select.erb
205
- - web/views/_nav.erb
206
- - web/views/_paging.erb
207
- - web/views/_poll_link.erb
208
- - web/views/_summary.erb
209
- - web/views/busy.erb
210
- - web/views/dashboard.erb
211
- - web/views/dead.erb
212
- - web/views/filtering.erb
213
- - web/views/layout.erb
214
- - web/views/metrics.erb
215
- - web/views/metrics_for_job.erb
216
- - web/views/morgue.erb
217
- - web/views/profiles.erb
218
- - web/views/queue.erb
219
- - web/views/queues.erb
220
- - web/views/retries.erb
221
- - web/views/retry.erb
222
- - web/views/scheduled.erb
223
- - web/views/scheduled_job_info.erb
202
+ - web/views/_footer.html.erb
203
+ - web/views/_job_info.html.erb
204
+ - web/views/_metrics_period_select.html.erb
205
+ - web/views/_nav.html.erb
206
+ - web/views/_paging.html.erb
207
+ - web/views/_poll_link.html.erb
208
+ - web/views/_summary.html.erb
209
+ - web/views/busy.html.erb
210
+ - web/views/dashboard.html.erb
211
+ - web/views/dead.html.erb
212
+ - web/views/filtering.html.erb
213
+ - web/views/layout.html.erb
214
+ - web/views/metrics.html.erb
215
+ - web/views/metrics_for_job.html.erb
216
+ - web/views/morgue.html.erb
217
+ - web/views/profiles.html.erb
218
+ - web/views/queue.html.erb
219
+ - web/views/queues.html.erb
220
+ - web/views/retries.html.erb
221
+ - web/views/retry.html.erb
222
+ - web/views/scheduled.html.erb
223
+ - web/views/scheduled_job_info.html.erb
224
224
  homepage: https://sidekiq.org
225
225
  licenses:
226
226
  - LGPL-3.0
@@ -1,183 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # this file originally based on authenticity_token.rb from the sinatra/rack-protection project
4
- #
5
- # The MIT License (MIT)
6
- #
7
- # Copyright (c) 2011-2017 Konstantin Haase
8
- # Copyright (c) 2015-2017 Zachary Scott
9
- #
10
- # Permission is hereby granted, free of charge, to any person obtaining
11
- # a copy of this software and associated documentation files (the
12
- # 'Software'), to deal in the Software without restriction, including
13
- # without limitation the rights to use, copy, modify, merge, publish,
14
- # distribute, sublicense, and/or sell copies of the Software, and to
15
- # permit persons to whom the Software is furnished to do so, subject to
16
- # the following conditions:
17
- #
18
- # The above copyright notice and this permission notice shall be
19
- # included in all copies or substantial portions of the Software.
20
- #
21
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
22
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
-
29
- require "securerandom"
30
- require "rack/request"
31
-
32
- module Sidekiq
33
- class Web
34
- class CsrfProtection
35
- def initialize(app, options = nil)
36
- @app = app
37
- end
38
-
39
- def call(env)
40
- accept?(env) ? admit(env) : deny(env)
41
- end
42
-
43
- private
44
-
45
- def admit(env)
46
- # On each successful request, we create a fresh masked token
47
- # which will be used in any forms rendered for this request.
48
- s = session(env)
49
- s[:csrf] ||= SecureRandom.base64(TOKEN_LENGTH)
50
- env[:csrf_token] = mask_token(s[:csrf])
51
- @app.call(env)
52
- end
53
-
54
- def safe?(env)
55
- %w[GET HEAD OPTIONS TRACE].include? env["REQUEST_METHOD"]
56
- end
57
-
58
- def logger(env)
59
- @logger ||= env["rack.logger"] || ::Logger.new(env["rack.errors"])
60
- end
61
-
62
- def deny(env)
63
- logger(env).warn "attack prevented by #{self.class}"
64
- [403, {Rack::CONTENT_TYPE => "text/plain"}, ["Forbidden"]]
65
- end
66
-
67
- def session(env)
68
- env["rack.session"] || fail(<<~EOM)
69
- Sidekiq::Web needs a valid Rack session for CSRF protection. If this is a Rails app,
70
- make sure you mount Sidekiq::Web *inside* your application routes:
71
-
72
-
73
- Rails.application.routes.draw do
74
- mount Sidekiq::Web => "/sidekiq"
75
- ....
76
- end
77
-
78
-
79
- If this is a Rails app in API mode, you need to enable sessions.
80
-
81
- https://guides.rubyonrails.org/api_app.html#using-session-middlewares
82
-
83
- If this is a bare Rack app, use a session middleware before Sidekiq::Web:
84
-
85
- # first, use IRB to create a shared secret key for sessions and commit it
86
- require 'securerandom'; File.open(".session.key", "w") {|f| f.write(SecureRandom.hex(32)) }
87
-
88
- # now use the secret with a session cookie middleware
89
- use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
90
- run Sidekiq::Web
91
-
92
- EOM
93
- end
94
-
95
- def accept?(env)
96
- return true if safe?(env)
97
-
98
- giventoken = ::Rack::Request.new(env).params["authenticity_token"]
99
- valid_token?(env, giventoken)
100
- end
101
-
102
- TOKEN_LENGTH = 32
103
-
104
- # Checks that the token given to us as a parameter matches
105
- # the token stored in the session.
106
- def valid_token?(env, giventoken)
107
- return false if giventoken.nil? || giventoken.empty?
108
-
109
- begin
110
- token = decode_token(giventoken)
111
- rescue ArgumentError # client input is invalid
112
- return false
113
- end
114
-
115
- sess = session(env)
116
- localtoken = sess[:csrf]
117
-
118
- # Checks that Rack::Session::Cookie actually contains the csrf token
119
- return false if localtoken.nil?
120
-
121
- # Rotate the session token after every use
122
- sess[:csrf] = SecureRandom.base64(TOKEN_LENGTH)
123
-
124
- # See if it's actually a masked token or not. We should be able
125
- # to handle any unmasked tokens that we've issued without error.
126
-
127
- if unmasked_token?(token)
128
- compare_with_real_token token, localtoken
129
- elsif masked_token?(token)
130
- unmasked = unmask_token(token)
131
- compare_with_real_token unmasked, localtoken
132
- else
133
- false # Token is malformed
134
- end
135
- end
136
-
137
- # Creates a masked version of the authenticity token that varies
138
- # on each request. The masking is used to mitigate SSL attacks
139
- # like BREACH.
140
- def mask_token(token)
141
- token = decode_token(token)
142
- one_time_pad = SecureRandom.random_bytes(token.length)
143
- encrypted_token = xor_byte_strings(one_time_pad, token)
144
- masked_token = one_time_pad + encrypted_token
145
- encode_token(masked_token)
146
- end
147
-
148
- # Essentially the inverse of +mask_token+.
149
- def unmask_token(masked_token)
150
- # Split the token into the one-time pad and the encrypted
151
- # value and decrypt it
152
- token_length = masked_token.length / 2
153
- one_time_pad = masked_token[0...token_length]
154
- encrypted_token = masked_token[token_length..]
155
- xor_byte_strings(one_time_pad, encrypted_token)
156
- end
157
-
158
- def unmasked_token?(token)
159
- token.length == TOKEN_LENGTH
160
- end
161
-
162
- def masked_token?(token)
163
- token.length == TOKEN_LENGTH * 2
164
- end
165
-
166
- def compare_with_real_token(token, local)
167
- ::Rack::Utils.secure_compare(token.to_s, decode_token(local).to_s)
168
- end
169
-
170
- def encode_token(token)
171
- [token].pack("m0").tr("+/", "-_")
172
- end
173
-
174
- def decode_token(token)
175
- token.tr("-_", "+/").unpack1("m0")
176
- end
177
-
178
- def xor_byte_strings(s1, s2)
179
- s1.bytes.zip(s2.bytes).map { |(c1, c2)| c1 ^ c2 }.pack("c*")
180
- end
181
- end
182
- end
183
- end
@@ -1,4 +0,0 @@
1
- <% if pollable? %>
2
- <a class="btn live-poll live-poll-start btn-primary"><%= t('LivePoll') %></a>
3
- <a class="btn live-poll live-poll-stop btn-danger"><%= t('StopPolling') %></a>
4
- <% end %>
@@ -1,6 +0,0 @@
1
- <div class="filter">
2
- <form role="search" method="get" class="form-inline" action='<%= root_path %><%= which %>'>
3
- <label for="substr"><%= t('Filter') %></label>
4
- <input class="form-control" type="search" name="substr" value="<%= h url_params("substr") %>" placeholder="<%= t('AnyJobContent') %>"/>
5
- </form>
6
- </div>
File without changes
File without changes
File without changes
File without changes