bullet 6.1.3 → 6.1.4
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/lib/bullet.rb +2 -2
- data/lib/bullet/rack.rb +2 -2
- data/lib/bullet/stack_trace_filter.rb +3 -6
- data/lib/bullet/version.rb +1 -1
- data/spec/bullet/rack_spec.rb +63 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ea4e863bfe254dde17af73253ffe7041cd2b2dabee2dad05d1eccb6904f229
|
4
|
+
data.tar.gz: 284dcd1a516922384bdaf1b3dd9e6a5e6776c213c3ecbc9ca41b223c5b92d36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26c43bfdac9582f059d067d4f56d4d85ed28416654ff5fd4686bf9977cbfbc8d92f887079954662e904fbe3d1b861d02482ac2fefac30a859fbdad8c3833e225
|
7
|
+
data.tar.gz: 48decfa9d28b9936f5c1f39c669b6e8061fae649f9036c29d4b28138083a43db8739f3b73bb9c390e9f6baea62aa1f66f79e8ced69cf13e789b8f116c101f25f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -93,7 +93,8 @@ The code above will enable all of the Bullet notification systems:
|
|
93
93
|
* `Bullet.rollbar`: add notifications to rollbar
|
94
94
|
* `Bullet.sentry`: add notifications to sentry
|
95
95
|
* `Bullet.add_footer`: adds the details in the bottom left corner of the page. Double click the footer or use close button to hide footer.
|
96
|
-
* `Bullet.skip_html_injection`: prevents Bullet from injecting
|
96
|
+
* `Bullet.skip_html_injection`: prevents Bullet from injecting code into the returned HTML. This must be false for receiving alerts, showing the footer or console logging.
|
97
|
+
* `Bullet.skip_http_headers`: don't add headers to API requests, and remove the javascript that relies on them. Note that this prevents bullet from logging warnings to the browser console or updating the footer.
|
97
98
|
* `Bullet.stacktrace_includes`: include paths with any of these substrings in the stack trace, even if they are not in your main app
|
98
99
|
* `Bullet.stacktrace_excludes`: ignore paths with any of these substrings in the stack trace, even if they are not in your main app.
|
99
100
|
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
|
data/lib/bullet.rb
CHANGED
@@ -39,7 +39,7 @@ module Bullet
|
|
39
39
|
:stacktrace_excludes,
|
40
40
|
:skip_html_injection
|
41
41
|
attr_reader :whitelist
|
42
|
-
attr_accessor :add_footer, :orm_patches_applied
|
42
|
+
attr_accessor :add_footer, :orm_patches_applied, :skip_http_headers
|
43
43
|
|
44
44
|
available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }.map { |notifier| "#{notifier}=" }
|
45
45
|
available_notifiers_options = { to: UniformNotifier }
|
@@ -73,7 +73,7 @@ module Bullet
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def app_root
|
76
|
-
(defined?(::Rails.root) ? Rails.root.to_s : Dir.pwd).to_s
|
76
|
+
@app_root ||= (defined?(::Rails.root) ? Rails.root.to_s : Dir.pwd).to_s
|
77
77
|
end
|
78
78
|
|
79
79
|
def n_plus_one_query_enable?
|
data/lib/bullet/rack.rb
CHANGED
@@ -22,9 +22,9 @@ module Bullet
|
|
22
22
|
response_body = response_body(response)
|
23
23
|
response_body = append_to_html_body(response_body, footer_note) if Bullet.add_footer
|
24
24
|
response_body = append_to_html_body(response_body, Bullet.gather_inline_notifications)
|
25
|
-
response_body = append_to_html_body(response_body, xhr_script) if Bullet.add_footer
|
25
|
+
response_body = append_to_html_body(response_body, xhr_script) if Bullet.add_footer && !Bullet.skip_http_headers
|
26
26
|
headers['Content-Length'] = response_body.bytesize.to_s
|
27
|
-
|
27
|
+
elsif !Bullet.skip_http_headers
|
28
28
|
set_header(headers, 'X-bullet-footer-text', Bullet.footer_info.uniq) if Bullet.add_footer
|
29
29
|
set_header(headers, 'X-bullet-console-text', Bullet.text_notifications) if Bullet.console_enabled?
|
30
30
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Bullet
|
4
4
|
module StackTraceFilter
|
5
5
|
VENDOR_PATH = '/vendor'
|
6
|
+
IS_RUBY_19 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
|
6
7
|
|
7
8
|
def caller_in_project
|
8
9
|
vendor_root = Bullet.app_root + VENDOR_PATH
|
@@ -47,19 +48,15 @@ module Bullet
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def location_as_path(location)
|
50
|
-
|
51
|
+
IS_RUBY_19 ? location : location.absolute_path.to_s
|
51
52
|
end
|
52
53
|
|
53
54
|
def select_caller_locations
|
54
|
-
if
|
55
|
+
if IS_RUBY_19
|
55
56
|
caller.select { |caller_path| yield caller_path }
|
56
57
|
else
|
57
58
|
caller_locations.select { |location| yield location }
|
58
59
|
end
|
59
60
|
end
|
60
|
-
|
61
|
-
def ruby_19?
|
62
|
-
@ruby_19 ||= Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
|
63
|
-
end
|
64
61
|
end
|
65
62
|
end
|
data/lib/bullet/version.rb
CHANGED
data/spec/bullet/rack_spec.rb
CHANGED
@@ -90,7 +90,7 @@ module Bullet
|
|
90
90
|
before do
|
91
91
|
expect(Bullet).to receive(:notification?).and_return(true)
|
92
92
|
allow(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
93
|
-
allow(middleware).to receive(:xhr_script).and_return('')
|
93
|
+
allow(middleware).to receive(:xhr_script).and_return('<script></script>')
|
94
94
|
allow(middleware).to receive(:footer_note).and_return('footer')
|
95
95
|
expect(Bullet).to receive(:perform_out_of_channel_notifications)
|
96
96
|
end
|
@@ -99,9 +99,8 @@ module Bullet
|
|
99
99
|
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
|
100
100
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
101
101
|
|
102
|
-
expect(headers['Content-Length']).to eq((
|
103
|
-
expect(response
|
104
|
-
expect(response.first).to include('<bullet></bullet><')
|
102
|
+
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
|
103
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
|
105
104
|
end
|
106
105
|
|
107
106
|
it 'should change response body for html safe string if add_footer is true' do
|
@@ -111,9 +110,16 @@ module Bullet
|
|
111
110
|
end
|
112
111
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
113
112
|
|
114
|
-
expect(headers['Content-Length']).to eq((
|
115
|
-
expect(response
|
116
|
-
|
113
|
+
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
|
114
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should add the footer-text header for non-html requests when add_footer is true' do
|
118
|
+
allow(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
119
|
+
allow(Bullet).to receive(:footer_info).and_return(['footer text'])
|
120
|
+
app.headers = {'Content-Type' => 'application/json'}
|
121
|
+
_, headers, _response = middleware.call({})
|
122
|
+
expect(headers).to include('X-bullet-footer-text' => '["footer text"]')
|
117
123
|
end
|
118
124
|
|
119
125
|
it 'should change response body if console_enabled is true' do
|
@@ -133,12 +139,62 @@ module Bullet
|
|
133
139
|
expect(response).to eq(%w[<html><head></head><body><bullet></bullet></body></html>])
|
134
140
|
end
|
135
141
|
|
142
|
+
it 'should add headers for non-html requests when console_enabled is true' do
|
143
|
+
allow(Bullet).to receive(:console_enabled?).at_least(:once).and_return(true)
|
144
|
+
allow(Bullet).to receive(:text_notifications).and_return(['text notifications'])
|
145
|
+
app.headers = {'Content-Type' => 'application/json'}
|
146
|
+
_, headers, _response = middleware.call({})
|
147
|
+
expect(headers).to include('X-bullet-console-text' => '["text notifications"]')
|
148
|
+
end
|
149
|
+
|
136
150
|
it "shouldn't change response body unnecessarily" do
|
137
151
|
expected_response = Support::ResponseDouble.new 'Actual body'
|
138
152
|
app.response = expected_response
|
139
153
|
_, _, response = middleware.call({})
|
140
154
|
expect(response).to eq(expected_response)
|
141
155
|
end
|
156
|
+
|
157
|
+
it "shouldn't add headers unnecessarily" do
|
158
|
+
app.headers = {'Content-Type' => 'application/json'}
|
159
|
+
_, headers, _response = middleware.call({})
|
160
|
+
expect(headers).not_to include('X-bullet-footer-text')
|
161
|
+
expect(headers).not_to include('X-bullet-console-text')
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when skip_http_headers is enabled" do
|
165
|
+
before do
|
166
|
+
allow(Bullet).to receive(:skip_http_headers).and_return(true)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should include the footer but not the xhr script tag if add_footer is true' do
|
170
|
+
expect(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
171
|
+
_, headers, response = middleware.call({})
|
172
|
+
|
173
|
+
expect(headers['Content-Length']).to eq((56 + middleware.send(:footer_note).length).to_s)
|
174
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet></body></html>])
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should not include the xhr script tag if console_enabled is true' do
|
178
|
+
expect(Bullet).to receive(:console_enabled?).and_return(true)
|
179
|
+
_, headers, response = middleware.call({})
|
180
|
+
expect(headers['Content-Length']).to eq('56')
|
181
|
+
expect(response).to eq(%w[<html><head></head><body><bullet></bullet></body></html>])
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should not add the footer-text header for non-html requests when add_footer is true' do
|
185
|
+
allow(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
186
|
+
app.headers = {'Content-Type' => 'application/json'}
|
187
|
+
_, headers, _response = middleware.call({})
|
188
|
+
expect(headers).not_to include('X-bullet-footer-text')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should not add headers for non-html requests when console_enabled is true' do
|
192
|
+
allow(Bullet).to receive(:console_enabled?).at_least(:once).and_return(true)
|
193
|
+
app.headers = {'Content-Type' => 'application/json'}
|
194
|
+
_, headers, _response = middleware.call({})
|
195
|
+
expect(headers).not_to include('X-bullet-console-text')
|
196
|
+
end
|
197
|
+
end
|
142
198
|
end
|
143
199
|
|
144
200
|
context 'when skip_html_injection is enabled' do
|
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: 6.1.
|
4
|
+
version: 6.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|