bullet 8.0.5 → 8.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 257c8bc067513839f2adb33e6630d62c3b92d6cd7cbdc3656b01349cfc385e20
4
- data.tar.gz: 131c0be29b73f72d828eaf3825ab37bd2dda9e8880228f3f2b467589fb9dd080
3
+ metadata.gz: 7ed7921469ed264816680bf580bd37cc8e9033287d90a86c65bb4d486fb789f3
4
+ data.tar.gz: a0c0ca44bc16b3673b3c7ea14f03a12dee3c73fc72084ee959ef19839bbd4f68
5
5
  SHA512:
6
- metadata.gz: fe1cfd7baac8c98b3937e7c32a9b54e73446275371501e47f151bd8ec51c95089bb959280419204d33f4a7fffbb0c46bf6d403c03cefe188ab8c02e8de7c5bf4
7
- data.tar.gz: 8290a945d4ee31300b46ddc622845dc63b1ae33172331e20a4a2ef6b6b7f597766afb4e1c3632225b5de6a6c09c8e7b13fb6b42e69f7fe8148cb76af28ab5f59
6
+ metadata.gz: 354d9bd9b4d126ef45edf063184e7c9d612aa243caa7c2044a67f665f625a40e7c23ca61efcfe70193823689499bb6bb868022647770c8ed9dba60f9dff3e26f
7
+ data.tar.gz: f19a948e75f612a65143fb069559c4691d12a73bb8cd0b45699b4b80e372565d39ed0c193eabcdc4d8e289cefaa3f0845f380d2509b4d6f69a32d57392339840
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## Next Release
2
2
 
3
+ ## 8.0.7 (05/15/2025)
4
+
5
+ * Try to insert `Bullet::Rack` properly
6
+
7
+ ## 8.0.6 (05/07/2025)
8
+
9
+ * Add CSP nonce for footer styles as well
10
+ * Add support for OpenTelemetry reporting
11
+
3
12
  ## 8.0.5 (04/21/2025)
4
13
 
5
14
  * Properly insert ContentSecurityPolicy middleware
data/README.md CHANGED
@@ -74,6 +74,7 @@ config.after_initialize do
74
74
  Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]
75
75
  Bullet.stacktrace_excludes = [ 'their_gem', 'their_middleware', ['my_file.rb', 'my_method'], ['my_file.rb', 16..20] ]
76
76
  Bullet.slack = { webhook_url: 'http://some.slack.url', channel: '#default', username: 'notifier' }
77
+ Bullet.opentelemetry = true
77
78
  end
78
79
  ```
79
80
 
@@ -100,6 +101,7 @@ The code above will enable all of the Bullet notification systems:
100
101
  Each item can be a string (match substring), a regex, or an array where the first item is a path to match, and the second
101
102
  item is a line number, a Range of line numbers, or a (bare) method name, to exclude only particular lines in a file.
102
103
  * `Bullet.slack`: add notifications to slack
104
+ * `Bullet.opentelemetry`: add notifications to OpenTelemetry
103
105
  * `Bullet.raise`: raise errors, useful for making your specs fail unless they have optimized queries
104
106
  * `Bullet.always_append_html_body`: always append the html body even if no notifications are present. Note: `console` or `add_footer` must also be true. Useful for Single Page Applications where the initial page load might not have any notifications present.
105
107
  * `Bullet.skip_user_in_notification`: exclude the OS user (`whoami`) from notifications.
data/lib/bullet/rack.rb CHANGED
@@ -8,7 +8,7 @@ module Bullet
8
8
  class Rack
9
9
  include Dependency
10
10
 
11
- NONCE_MATCHER = /script-src .*'nonce-(?<nonce>[A-Za-z0-9+\/]+={0,2})'/
11
+ NONCE_MATCHER = /(script|style)-src .*'nonce-(?<nonce>[A-Za-z0-9+\/]+={0,2})'/
12
12
 
13
13
  def initialize(app)
14
14
  @app = app
@@ -29,7 +29,7 @@ module Bullet
29
29
  response_body = response_body(response)
30
30
 
31
31
  with_security_policy_nonce(headers) do |nonce|
32
- response_body = append_to_html_body(response_body, footer_note) if Bullet.add_footer
32
+ response_body = append_to_html_body(response_body, footer_note(nonce)) if Bullet.add_footer
33
33
  response_body = append_to_html_body(response_body, Bullet.gather_inline_notifications)
34
34
  if Bullet.add_footer && !Bullet.skip_http_headers
35
35
  response_body = append_to_html_body(response_body, xhr_script(nonce))
@@ -70,8 +70,22 @@ module Bullet
70
70
  end
71
71
  end
72
72
 
73
- def footer_note
74
- "<details #{details_attributes}><summary #{summary_attributes}>Bullet Warnings</summary><div #{footer_content_attributes}>#{Bullet.footer_info.uniq.join('<br>')}#{footer_console_message}</div></details>"
73
+ def footer_note(nonce = nil)
74
+ %(<details id="bullet-footer" data-is-bullet-footer><summary>Bullet Warnings</summary><div>#{Bullet.footer_info.uniq.join('<br>')}#{footer_console_message(nonce)}</div>#{footer_style(nonce)}</details>)
75
+ end
76
+
77
+ # Make footer styles work with ContentSecurityPolicy style-src as self
78
+ def footer_style(nonce = nil)
79
+ css = <<~CSS
80
+ details#bullet-footer {cursor: pointer; position: fixed; left: 0px; bottom: 0px; z-index: 9999; background: #fdf2f2; color: #9b1c1c; font-size: 12px; border-radius: 0px 8px 0px 0px; border: 1px solid #9b1c1c;}
81
+ details#bullet-footer summary {font-weight: 600; padding: 2px 8px;}
82
+ details#bullet-footer div {padding: 8px; border-top: 1px solid #9b1c1c;}
83
+ CSS
84
+ if nonce
85
+ %(<style type="text/css" nonce="#{nonce}">#{css}</style>)
86
+ else
87
+ %(<style type="text/css">#{css}</style>)
88
+ end
75
89
  end
76
90
 
77
91
  def set_header(headers, header_name, header_array)
@@ -122,28 +136,18 @@ module Bullet
122
136
 
123
137
  private
124
138
 
125
- def details_attributes
126
- <<~EOF
127
- id="bullet-footer" data-is-bullet-footer
128
- style="cursor: pointer; position: fixed; left: 0px; bottom: 0px; z-index: 9999; background: #fdf2f2; color: #9b1c1c; font-size: 12px; border-radius: 0px 8px 0px 0px; border: 1px solid #9b1c1c;"
129
- EOF
130
- end
131
-
132
- def summary_attributes
133
- <<~EOF
134
- style="font-weight: 600; padding: 2px 8px"
135
- EOF
136
- end
137
-
138
- def footer_content_attributes
139
- <<~EOF
140
- style="padding: 8px; border-top: 1px solid #9b1c1c;"
141
- EOF
142
- end
143
-
144
- def footer_console_message
139
+ def footer_console_message(nonce = nil)
145
140
  if Bullet.console_enabled?
146
- "<br/><span style='font-style: italic;'>See 'Uniform Notifier' in JS Console for Stacktrace</span>"
141
+ footer = %(<br/><span id="console-message">See 'Uniform Notifier' in JS Console for Stacktrace</span>)
142
+ css = "details#bullet-footer #console-message {font-style: italic;}"
143
+ style =
144
+ if nonce
145
+ %(<style type="text/css" nonce="#{nonce}">#{css}</style>)
146
+ else
147
+ %(<style type="text/css">#{css}</style>)
148
+ end
149
+
150
+ footer + style
147
151
  end
148
152
  end
149
153
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bullet
4
- VERSION = '8.0.5'
4
+ VERSION = '8.0.7'
5
5
  end
data/lib/bullet.rb CHANGED
@@ -24,13 +24,10 @@ module Bullet
24
24
  if defined?(Rails::Railtie)
25
25
  class BulletRailtie < Rails::Railtie
26
26
  initializer 'bullet.add_middleware' do |app|
27
- # I don't find a way to detect if the middleware is already in the stack,
28
- # so I'm using the api_only flag.
29
- # If it is true, ActionDispatch::ContentSecurityPolicy::Middleware is not in the stack.
30
- if app.config.api_only || !defined?(ActionDispatch::ContentSecurityPolicy::Middleware)
31
- app.middleware.use Bullet::Rack
32
- else
27
+ if defined?(ActionDispatch::ContentSecurityPolicy::Middleware) && Rails.application.config.content_security_policy && !app.config.api_only
33
28
  app.middleware.insert_before ActionDispatch::ContentSecurityPolicy::Middleware, Bullet::Rack
29
+ else
30
+ app.middleware.use Bullet::Rack
34
31
  end
35
32
  end
36
33
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.5
4
+ version: 8.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: 1.3.6
114
114
  requirements: []
115
- rubygems_version: 3.6.2
115
+ rubygems_version: 3.6.7
116
116
  specification_version: 4
117
117
  summary: help to kill N+1 queries and unused eager loading.
118
118
  test_files: []