bullet 8.0.5 → 8.0.6

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: f00b664af513340b8b094dfa967a2dbd2c3a72edfcb0031532dd4ba38a1fb4b2
4
+ data.tar.gz: 76b42f07c889542a50cc75a52d52fef26bf8647721d3c9913eb4f1dbb21db9a0
5
5
  SHA512:
6
- metadata.gz: fe1cfd7baac8c98b3937e7c32a9b54e73446275371501e47f151bd8ec51c95089bb959280419204d33f4a7fffbb0c46bf6d403c03cefe188ab8c02e8de7c5bf4
7
- data.tar.gz: 8290a945d4ee31300b46ddc622845dc63b1ae33172331e20a4a2ef6b6b7f597766afb4e1c3632225b5de6a6c09c8e7b13fb6b42e69f7fe8148cb76af28ab5f59
6
+ metadata.gz: db329cba6757c1ec372a7a7b6a8a9aa4a92fd5c63ce1a0e92cd43c89abd852768a83eddd95873a1cdeb2155abfa899d4c385df2a670b326c3eaa8736398a996e
7
+ data.tar.gz: 35c6df4a0e0aefd934c1038f2dc5faa7978cbe7b81e482ea0ca931045d4b445a67d33d0c69d603830111cee46f9bf5128a9824277de7ef3dc347c10eae5d84ea
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Next Release
2
2
 
3
+ ## 8.0.6 (05/07/2025)
4
+
5
+ * Add CSP nonce for footer styles as well
6
+ * Add support for OpenTelemetry reporting
7
+
3
8
  ## 8.0.5 (04/21/2025)
4
9
 
5
10
  * 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.6'
5
5
  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.6
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: []