bullet 7.1.0 → 7.1.1

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: 3556ad95bac8e87086710acf1c5b7ea5aa8252ee83ab3b20dfb4ec9e06a06474
4
- data.tar.gz: 5d3695f3e2ab1ff51232e56d056aaf994630d465f5902106ceef125a7c6426d9
3
+ metadata.gz: f3337004db8160edc4f3fecbb4b9d9caf5db356f2bc53cbb8a87dc32661747db
4
+ data.tar.gz: cf987a580af8f2451043a7ccc0ad0fd2f4f30b4832c8889e2a7891a85e1ed062
5
5
  SHA512:
6
- metadata.gz: 150e4ba5ae1900d1e50b87cfed8f325ff2615bbe613e908bc5e253d7072a0018869a6a67ca311a3f22cd190cadc87882e99700e0f9ae1e54277b64ddd0d2fe45
7
- data.tar.gz: cf3c2bf147e67915dd46670a8cf2b77b90c236fddca56fe1663ff62d8bf10a1a10506ee54773a28b7759d892ed6ed7fcdd7e0952d6b67ec8074b5a66abce0a8f
6
+ metadata.gz: 88ba85427aeb892d39b66d6f98edfa2dd1d80a23eba3080c2497b7b2b496add6cf3835239bc81b349a5176413fe771637e1218e72eca1d15b24f9f6cd737826d
7
+ data.tar.gz: d3982d128702e65d65ec669be5a8ef0c15725e2f474db26911186aafedf6192f2278709cc1dee0f8d5857ca43105bb34fa6d2fa59eafaadb7b3284e5821a1388
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Next Release
2
2
 
3
+ ## 7.1.1 (10/07/2023)
4
+
5
+ * Add support for `Content-Security-Policy-Report-Only` nonces
6
+ * Fix count method signature
7
+
3
8
  ## 7.1.0 (10/06/2023)
4
9
 
5
10
  * Support rails 7.1
@@ -178,11 +178,11 @@ module Bullet
178
178
  end
179
179
 
180
180
  ::ActiveRecord::Associations::CollectionProxy.class_eval do
181
- def count
181
+ def count(column_name = nil, options = {})
182
182
  if Bullet.start?
183
183
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
184
184
  end
185
- super
185
+ super(column_name, options)
186
186
  end
187
187
  end
188
188
  end
@@ -170,11 +170,11 @@ module Bullet
170
170
  end
171
171
 
172
172
  ::ActiveRecord::Associations::CollectionProxy.class_eval do
173
- def count
173
+ def count(column_name = nil, options = {})
174
174
  if Bullet.start?
175
175
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
176
176
  end
177
- super
177
+ super(column_name, options)
178
178
  end
179
179
  end
180
180
  end
@@ -235,11 +235,11 @@ module Bullet
235
235
  end
236
236
 
237
237
  ::ActiveRecord::Associations::CollectionProxy.class_eval do
238
- def count
238
+ def count(column_name = nil, options = {})
239
239
  if Bullet.start?
240
240
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
241
241
  end
242
- super
242
+ super(column_name, options)
243
243
  end
244
244
  end
245
245
  end
@@ -265,7 +265,10 @@ module Bullet
265
265
  Module.new do
266
266
  def count
267
267
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
268
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
268
+ Bullet::Detector::CounterCache.add_counter_cache(
269
+ proxy_association.owner,
270
+ proxy_association.reflection.name
271
+ )
269
272
  end
270
273
  super
271
274
  end
@@ -245,11 +245,14 @@ module Bullet
245
245
 
246
246
  ::ActiveRecord::Associations::CollectionProxy.prepend(
247
247
  Module.new do
248
- def count
248
+ def count(column_name = nil)
249
249
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
250
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
250
+ Bullet::Detector::CounterCache.add_counter_cache(
251
+ proxy_association.owner,
252
+ proxy_association.reflection.name
253
+ )
251
254
  end
252
- super
255
+ super(column_name)
253
256
  end
254
257
  end
255
258
  )
@@ -274,7 +274,10 @@ module Bullet
274
274
  Module.new do
275
275
  def count
276
276
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
277
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
277
+ Bullet::Detector::CounterCache.add_counter_cache(
278
+ proxy_association.owner,
279
+ proxy_association.reflection.name
280
+ )
278
281
  end
279
282
  super
280
283
  end
@@ -272,11 +272,14 @@ module Bullet
272
272
 
273
273
  ::ActiveRecord::Associations::CollectionProxy.prepend(
274
274
  Module.new do
275
- def count
275
+ def count(column_name = nil)
276
276
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
277
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
277
+ Bullet::Detector::CounterCache.add_counter_cache(
278
+ proxy_association.owner,
279
+ proxy_association.reflection.name
280
+ )
278
281
  end
279
- super
282
+ super(column_name)
280
283
  end
281
284
  end
282
285
  )
@@ -65,7 +65,9 @@ module Bullet
65
65
  def call
66
66
  if Bullet.start?
67
67
  @preloaders.each do |preloader|
68
- preloader.records.each { |record| Bullet::Detector::Association.add_object_associations(record, preloader.associations) }
68
+ preloader.records.each { |record|
69
+ Bullet::Detector::Association.add_object_associations(record, preloader.associations)
70
+ }
69
71
  Bullet::Detector::UnusedEagerLoading.add_eager_loadings(preloader.records, preloader.associations)
70
72
  end
71
73
  end
@@ -80,7 +82,9 @@ module Bullet
80
82
  if Bullet.start?
81
83
  reflection_records.compact!
82
84
  if reflection_records.first.class.name !~ /^HABTM_/
83
- reflection_records.each { |record| Bullet::Detector::Association.add_object_associations(record, reflection.name) }
85
+ reflection_records.each { |record|
86
+ Bullet::Detector::Association.add_object_associations(record, reflection.name)
87
+ }
84
88
  Bullet::Detector::UnusedEagerLoading.add_eager_loadings(reflection_records, reflection.name)
85
89
  end
86
90
  end
@@ -284,11 +288,14 @@ module Bullet
284
288
 
285
289
  ::ActiveRecord::Associations::CollectionProxy.prepend(
286
290
  Module.new do
287
- def count
291
+ def count(column_name = nil)
288
292
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
289
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
293
+ Bullet::Detector::CounterCache.add_counter_cache(
294
+ proxy_association.owner,
295
+ proxy_association.reflection.name
296
+ )
290
297
  end
291
- super
298
+ super(column_name)
292
299
  end
293
300
  end
294
301
  )
@@ -65,7 +65,9 @@ module Bullet
65
65
  def call
66
66
  if Bullet.start?
67
67
  @preloaders.each do |preloader|
68
- preloader.records.each { |record| Bullet::Detector::Association.add_object_associations(record, preloader.associations) }
68
+ preloader.records.each { |record|
69
+ Bullet::Detector::Association.add_object_associations(record, preloader.associations)
70
+ }
69
71
  Bullet::Detector::UnusedEagerLoading.add_eager_loadings(preloader.records, preloader.associations)
70
72
  end
71
73
  end
@@ -80,7 +82,9 @@ module Bullet
80
82
  if Bullet.start?
81
83
  reflection_records.compact!
82
84
  if reflection_records.first.class.name !~ /^HABTM_/
83
- reflection_records.each { |record| Bullet::Detector::Association.add_object_associations(record, reflection.name) }
85
+ reflection_records.each { |record|
86
+ Bullet::Detector::Association.add_object_associations(record, reflection.name)
87
+ }
84
88
  Bullet::Detector::UnusedEagerLoading.add_eager_loadings(reflection_records, reflection.name)
85
89
  end
86
90
  end
@@ -284,11 +288,14 @@ module Bullet
284
288
 
285
289
  ::ActiveRecord::Associations::CollectionProxy.prepend(
286
290
  Module.new do
287
- def count
291
+ def count(column_name = nil)
288
292
  if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
289
- Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
293
+ Bullet::Detector::CounterCache.add_counter_cache(
294
+ proxy_association.owner,
295
+ proxy_association.reflection.name
296
+ )
290
297
  end
291
- super
298
+ super(column_name)
292
299
  end
293
300
  end
294
301
  )
@@ -44,13 +44,10 @@ module Bullet
44
44
  unless obj.bullet_primary_key_value.nil?
45
45
  primary_key_values_are_empty = false
46
46
  end
47
- keys_joined += "#{(keys_joined.empty?? '' : ', ')}#{obj.bullet_key}"
47
+ keys_joined += "#{(keys_joined.empty? ? '' : ', ')}#{obj.bullet_key}"
48
48
  end
49
49
  unless class_names_match_regex || primary_key_values_are_empty
50
- Bullet.debug(
51
- 'Detector::NPlusOneQuery#add_possible_objects',
52
- "objects: #{keys_joined}"
53
- )
50
+ Bullet.debug('Detector::NPlusOneQuery#add_possible_objects', "objects: #{keys_joined}")
54
51
  objects.each { |object| possible_objects.add object.bullet_key }
55
52
  end
56
53
  end
@@ -65,7 +65,10 @@ module Bullet
65
65
  private
66
66
 
67
67
  def create_notification(callers, klazz, associations)
68
- notify_associations = Array.wrap(associations) - Bullet.get_safelist_associations(:unused_eager_loading, klazz)
68
+ notify_associations = Array.wrap(associations) - Bullet.get_safelist_associations(
69
+ :unused_eager_loading,
70
+ klazz
71
+ )
69
72
 
70
73
  if notify_associations.present?
71
74
  notice = Bullet::Notification::UnusedEagerLoading.new(callers, klazz, notify_associations)
@@ -9,7 +9,8 @@ class Object
9
9
  return if respond_to?(:persisted?) && !persisted?
10
10
 
11
11
  if self.class.respond_to?(:primary_keys) && self.class.primary_keys
12
- self.class.primary_keys.map { |primary_key| send primary_key }.join(',')
12
+ self.class.primary_keys.map { |primary_key| send primary_key }
13
+ .join(',')
13
14
  elsif self.class.respond_to?(:primary_key) && self.class.primary_key
14
15
  send self.class.primary_key
15
16
  else
@@ -1,4 +1,3 @@
1
-
2
1
  module Bullet
3
2
  module Mongoid
4
3
  def self.enable
@@ -23,6 +22,7 @@ module Bullet
23
22
 
24
23
  def each(&block)
25
24
  return to_enum unless block_given?
25
+
26
26
  records = []
27
27
  origin_each { |record| records << record }
28
28
  if records.length > 1
@@ -28,13 +28,13 @@ module Bullet
28
28
  def whoami
29
29
  @user ||=
30
30
  ENV['USER'].presence ||
31
- (
32
- begin
33
- `whoami`.chomp
34
- rescue StandardError
35
- ''
36
- end
37
- )
31
+ (
32
+ begin
33
+ `whoami`.chomp
34
+ rescue StandardError
35
+ ''
36
+ end
37
+ )
38
38
  @user.present? ? "user: #{@user}" : ''
39
39
  end
40
40
 
@@ -73,7 +73,8 @@ module Bullet
73
73
  end
74
74
 
75
75
  def associations_str
76
- ".includes(#{@associations.map { |a| a.to_s.to_sym }.inspect})"
76
+ ".includes(#{@associations.map { |a| a.to_s.to_sym }
77
+ .inspect})"
77
78
  end
78
79
  end
79
80
  end
data/lib/bullet/rack.rb CHANGED
@@ -49,6 +49,7 @@ module Bullet
49
49
  # response may be ["Not Found"], ["Move Permanently"], etc, but
50
50
  # those should not happen if the status is 200
51
51
  return true if !response.respond_to?(:body) && !response.respond_to?(:first)
52
+
52
53
  body = response_body(response)
53
54
  body.nil? || body.empty?
54
55
  end
@@ -135,7 +136,8 @@ module Bullet
135
136
  end
136
137
 
137
138
  def with_security_policy_nonce(headers)
138
- matched = (headers['Content-Security-Policy'] || '').match(NONCE_MATCHER)
139
+ csp = headers['Content-Security-Policy'] || headers['Content-Security-Policy-Report-Only'] || ''
140
+ matched = csp.match(NONCE_MATCHER)
139
141
  nonce = matched[:nonce] if matched
140
142
 
141
143
  if nonce
@@ -8,7 +8,8 @@ module Bullet
8
8
  end
9
9
 
10
10
  def similarly_associated(base, associations)
11
- @registry.select { |key, value| key.include?(base) && value == associations }.collect(&:first).flatten
11
+ @registry.select { |key, value| key.include?(base) && value == associations }
12
+ .collect(&:first).flatten
12
13
  end
13
14
  end
14
15
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler"
3
4
 
4
5
  module Bullet
@@ -14,8 +15,8 @@ module Bullet
14
15
  caller_path = location_as_path(location)
15
16
  caller_path.include?(Bullet.app_root) && !caller_path.include?(vendor_root) &&
16
17
  !caller_path.include?(bundler_path) || Bullet.stacktrace_includes.any? { |include_pattern|
17
- pattern_matches?(location, include_pattern)
18
- }
18
+ pattern_matches?(location, include_pattern)
19
+ }
19
20
  end
20
21
  end
21
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bullet
4
- VERSION = '7.1.0'
4
+ VERSION = '7.1.1'
5
5
  end
data/lib/bullet.rb CHANGED
@@ -43,7 +43,8 @@ module Bullet
43
43
  attr_accessor :add_footer, :orm_patches_applied, :skip_http_headers, :always_append_html_body
44
44
 
45
45
  available_notifiers =
46
- UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }.map { |notifier| "#{notifier}=" }
46
+ UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }
47
+ .map { |notifier| "#{notifier}=" }
47
48
  available_notifiers_options = { to: UniformNotifier }
48
49
  delegate(*available_notifiers, **available_notifiers_options)
49
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport