bugsnag 6.6.4 → 6.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4833943785d255e81284063ae7e3c6f9a751613
4
- data.tar.gz: 56e345f1855da00e3a8ea239d721810dece1bc38
3
+ metadata.gz: 60129feaa76e872e91284f6c222eeeaa6728fb23
4
+ data.tar.gz: ab2269d57bd7c131967acf0a37b7508fd1095d7a
5
5
  SHA512:
6
- metadata.gz: b2bdb0d75b43d858e57679eb456131e699785ea3af5c1173ba20948b341812a20811a251c1923038fcb66f716abc564b3c2fc39af37798e302b37b2ecf21f492
7
- data.tar.gz: bd75ebbabe899516b47e1d8126fe12491ef998076b4479f7adc6fdfb4d1b3ee40197588c0e3c6cf951ebb0fc2d588c68278f1b389892aace502b15894cc36246
6
+ metadata.gz: 123b069a26b2e6d3b611eb65a43b36c79878ad49075e63e7b0d600fcdcaecd9396bf7c9a42e66cbeb236d4d06a44290bdc7125b8eff0dab54ae4531209882b07
7
+ data.tar.gz: 2afa07a981784dff59491cb8a156f977905f06e462dcaacb352b3f09241d6ae90afadf6b3bd0bbecd4ce1a321e88bda4af35a8e03f9a2dbfce3009ac886bc976
@@ -1,6 +1,26 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 6.7.0 (05 Apr 2018)
5
+
6
+ ### Enhancements
7
+
8
+ * Support HTTP proxy from `http_proxy` and `https_proxy` environment variables
9
+ | [#424](https://github.com/bugsnag/bugsnag-ruby/pull/424)
10
+ | [#437](https://github.com/bugsnag/bugsnag-ruby/pull/437)
11
+ | [Bill Kirtley](https://github.com/cluesque)
12
+
13
+ * Add option to disable auto-configuration
14
+ | [#419](https://github.com/bugsnag/bugsnag-ruby/pull/419)
15
+
16
+ * Add `warden.user.rack` data to default filters
17
+ | [#436](https://github.com/bugsnag/bugsnag-ruby/pull/436)
18
+
19
+ ### Fixes
20
+
21
+ * Ensure logged messages include Bugsnag progname
22
+ | [#443](https://github.com/bugsnag/bugsnag-ruby/pull/443)
23
+
4
24
  ## 6.6.4 (14 Feb 2018)
5
25
 
6
26
  ### Fixes
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![build status](https://travis-ci.org/bugsnag/bugsnag-ruby.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-ruby)
3
3
 
4
4
 
5
- The Bugsnag exception reporter for Ruby gives you instant notification of exceptions thrown from your **[Rails](https://bugsnag.com/platforms/rails)**, **Sinatra**, **Rack** or **plain Ruby** app. Any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.
5
+ The Bugsnag exception reporter for Ruby gives you instant notification of exceptions thrown from your **[Rails](https://www.bugsnag.com/platforms/rails)**, **Sinatra**, **Rack** or **plain Ruby** app. Any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.
6
6
 
7
7
  ## Features
8
8
 
@@ -13,26 +13,26 @@ The Bugsnag exception reporter for Ruby gives you instant notification of except
13
13
 
14
14
  ## Getting started
15
15
 
16
- 1. [Create a Bugsnag account](https://bugsnag.com)
16
+ 1. [Create a Bugsnag account](https://www.bugsnag.com)
17
17
  2. Complete the instructions in the integration guide for your framework:
18
- * [Que](http://docs.bugsnag.com/platforms/ruby/que)
19
- * [Rack](http://docs.bugsnag.com/platforms/ruby/rack)
20
- * [Rails](http://docs.bugsnag.com/platforms/ruby/rails)
21
- * [Rake](http://docs.bugsnag.com/platforms/ruby/rake)
22
- * [Sidekiq](http://docs.bugsnag.com/platforms/ruby/sidekiq)
23
- * [Other Ruby apps](http://docs.bugsnag.com/platforms/ruby/other)
24
- * For [EventMachine](http://rubyeventmachine.com) integration, see [`bugsnag-em`](https://github.com/bugsnag/bugsnag-em)
18
+ * [Que](https://docs.bugsnag.com/platforms/ruby/que)
19
+ * [Rack](https://docs.bugsnag.com/platforms/ruby/rack)
20
+ * [Rails](https://docs.bugsnag.com/platforms/ruby/rails)
21
+ * [Rake](https://docs.bugsnag.com/platforms/ruby/rake)
22
+ * [Sidekiq](https://docs.bugsnag.com/platforms/ruby/sidekiq)
23
+ * [Other Ruby apps](https://docs.bugsnag.com/platforms/ruby/other)
24
+ * For [EventMachine](https://rubyeventmachine.com) integration, see [`bugsnag-em`](https://github.com/bugsnag/bugsnag-em)
25
25
  3. Relax!
26
26
 
27
27
  ## Support
28
28
 
29
29
  * Read the configuration reference:
30
- * [Que](http://docs.bugsnag.com/platforms/ruby/que/configuration-options)
31
- * [Rack](http://docs.bugsnag.com/platforms/ruby/rack/configuration-options)
32
- * [Rails](http://docs.bugsnag.com/platforms/ruby/rails/configuration-options)
33
- * [Rake](http://docs.bugsnag.com/platforms/ruby/rake/configuration-options)
34
- * [Sidekiq](http://docs.bugsnag.com/platforms/ruby/sidekiq/configuration-options)
35
- * [Other Ruby apps](http://docs.bugsnag.com/platforms/ruby/other/configuration-options)
30
+ * [Que](https://docs.bugsnag.com/platforms/ruby/que/configuration-options)
31
+ * [Rack](https://docs.bugsnag.com/platforms/ruby/rack/configuration-options)
32
+ * [Rails](https://docs.bugsnag.com/platforms/ruby/rails/configuration-options)
33
+ * [Rake](https://docs.bugsnag.com/platforms/ruby/rake/configuration-options)
34
+ * [Sidekiq](https://docs.bugsnag.com/platforms/ruby/sidekiq/configuration-options)
35
+ * [Other Ruby apps](https://docs.bugsnag.com/platforms/ruby/other/configuration-options)
36
36
  * Check out some [example apps integrated with Bugsnag](https://github.com/bugsnag/bugsnag-example-apps/tree/master/apps/ruby) using Rails, Sinatra, Padrino, and more.
37
37
  * [Search open and closed issues](https://github.com/bugsnag/bugsnag-ruby/issues?utf8=✓&q=is%3Aissue) for similar problems
38
38
  * [Report a bug or request a feature](https://github.com/bugsnag/bugsnag-ruby/issues/new)
@@ -39,7 +39,7 @@ guide](https://docs.bugsnag.com/api/deploy-tracking/capistrano/) for more inform
39
39
  + end
40
40
  ```
41
41
 
42
- * `Bugsnag.notify_or_ignore` and `Bugsnag.auto_notify` have been removed removed. Call `notify` directly instead.
42
+ * `Bugsnag.notify_or_ignore` and `Bugsnag.auto_notify` have been removed. Call `notify` directly instead.
43
43
  * `after_notify_callbacks` has been removed
44
44
  * `Bugsnag::Notification` has been renamed to `Bugsnag::Report`
45
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.6.4
1
+ 6.7.0
@@ -13,6 +13,8 @@ require "bugsnag/delivery"
13
13
  require "bugsnag/delivery/synchronous"
14
14
  require "bugsnag/delivery/thread_queue"
15
15
 
16
+ # Rack is not bundled with the other integrations
17
+ # as it doesn't auto-configure when loaded
16
18
  require "bugsnag/integrations/rack"
17
19
 
18
20
  require "bugsnag/middleware/rack_request"
@@ -28,6 +30,7 @@ require "bugsnag/middleware/classify_error"
28
30
 
29
31
  module Bugsnag
30
32
  LOCK = Mutex.new
33
+ INTEGRATIONS = [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que]
31
34
 
32
35
  class << self
33
36
  ##
@@ -155,13 +158,28 @@ module Bugsnag
155
158
  def before_notify_callbacks
156
159
  Bugsnag.configuration.request_data[:before_callbacks] ||= []
157
160
  end
158
- end
159
- end
160
161
 
161
- require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
162
- [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que].each do |integration|
163
- begin
164
- require "bugsnag/integrations/#{integration}"
165
- rescue LoadError
162
+ # Attempts to load all integrations through auto-discovery
163
+ def load_integrations
164
+ require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
165
+ INTEGRATIONS.each do |integration|
166
+ begin
167
+ require "bugsnag/integrations/#{integration}"
168
+ rescue LoadError
169
+ end
170
+ end
171
+ end
172
+
173
+ # Load a specific integration
174
+ def load_integration(integration)
175
+ integration = :railtie if integration == :rails
176
+ if INTEGRATIONS.include?(integration) || integration == :railtie
177
+ require "bugsnag/integrations/#{integration}"
178
+ else
179
+ configuration.debug("Integration #{integration} is not currently supported")
180
+ end
181
+ end
166
182
  end
167
183
  end
184
+
185
+ Bugsnag.load_integrations unless ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"]
@@ -47,6 +47,7 @@ module Bugsnag
47
47
  /cookie/i,
48
48
  /password/i,
49
49
  /secret/i,
50
+ /warden\.user\.([^.]+)\.key/,
50
51
  "rack.request.form_vars"
51
52
  ].freeze
52
53
 
@@ -75,14 +76,16 @@ module Bugsnag
75
76
  # Read the API key from the environment
76
77
  self.api_key = ENV["BUGSNAG_API_KEY"]
77
78
 
78
- # Read NET::HTTP proxy environment variable
79
- self.proxy_host = ENV["http_proxy"]
79
+ # Read NET::HTTP proxy environment variables
80
+ if (proxy_uri = ENV["https_proxy"] || ENV['http_proxy'])
81
+ parse_proxy(proxy_uri)
82
+ end
80
83
 
81
84
  # Set up logging
82
85
  self.logger = Logger.new(STDOUT)
83
86
  self.logger.level = Logger::INFO
84
87
  self.logger.formatter = proc do |severity, datetime, progname, msg|
85
- "** [Bugsnag] #{datetime}: #{msg}\n"
88
+ "** #{progname} #{datetime}: #{msg}\n"
86
89
  end
87
90
 
88
91
  # Configure the bugsnag middleware stack
@@ -162,23 +165,35 @@ module Bugsnag
162
165
  ##
163
166
  # Logs an info level message
164
167
  def info(message)
165
- logger.info(message)
168
+ logger.info(PROG_NAME) { message }
166
169
  end
167
170
 
168
171
  ##
169
172
  # Logs a warning level message
170
173
  def warn(message)
171
- logger.warn(message)
174
+ logger.warn(PROG_NAME) { message }
172
175
  end
173
176
 
174
177
  ##
175
178
  # Logs a debug level message
176
179
  def debug(message)
177
- logger.debug(message)
180
+ logger.debug(PROG_NAME) { message }
181
+ end
182
+
183
+ ##
184
+ # Parses and sets proxy from a uri
185
+ def parse_proxy(uri)
186
+ proxy = URI.parse(uri)
187
+ self.proxy_host = proxy.host
188
+ self.proxy_port = proxy.port
189
+ self.proxy_user = proxy.user
190
+ self.proxy_password = proxy.password
178
191
  end
179
192
 
180
193
  private
181
194
 
195
+ PROG_NAME = "[Bugsnag]"
196
+
182
197
  def default_hostname
183
198
  # Send the heroku dyno name instead of hostname if available
184
199
  ENV["DYNO"] || Socket.gethostname;
@@ -16,4 +16,71 @@ describe Bugsnag do
16
16
  expect(Bugsnag.configuration.logger).to have_received(:warn)
17
17
  end
18
18
  end
19
+
20
+ describe 'loading integrations' do
21
+ before do
22
+ module Kernel
23
+ REQUIRED = []
24
+ alias_method :old_require, :require
25
+ def require(path)
26
+ if path.include?("bugsnag/integrations/")
27
+ REQUIRED << path
28
+ else
29
+ old_require(path)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ it 'attempts to load integrations' do
36
+ Kernel::REQUIRED = []
37
+ ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = nil
38
+ load "./lib/bugsnag.rb"
39
+ Bugsnag::INTEGRATIONS.each do |integration|
40
+ expect(Kernel::REQUIRED).to include("bugsnag/integrations/#{integration}")
41
+ end
42
+ end
43
+
44
+ it 'does not load integrations when BUGSNAG_DISABLE_AUTOCONFIGURE is true' do
45
+ Kernel::REQUIRED = []
46
+ ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = 'true'
47
+ load "./lib/bugsnag.rb"
48
+ expect(Kernel::REQUIRED).to eq(["bugsnag/integrations/rack"])
49
+ end
50
+
51
+ it 'loads all integrations if requested' do
52
+ Kernel::REQUIRED = []
53
+ expect(Kernel::REQUIRED).to eq([])
54
+ Bugsnag.load_integrations
55
+ Bugsnag::INTEGRATIONS.each do |integration|
56
+ expect(Kernel::REQUIRED).to include("bugsnag/integrations/#{integration}")
57
+ end
58
+ end
59
+
60
+ it 'loads singular integrations' do
61
+ Kernel::REQUIRED = []
62
+ expect(Kernel::REQUIRED).to eq([])
63
+ Bugsnag::INTEGRATIONS.each do |integration|
64
+ Kernel::REQUIRED = []
65
+ Bugsnag.load_integration(integration)
66
+ expect(Kernel::REQUIRED).to include("bugsnag/integrations/#{integration}")
67
+ end
68
+ end
69
+
70
+ it 'loads railtie for :rails or :railtie' do
71
+ Kernel::REQUIRED = []
72
+ Bugsnag.load_integration(:rails)
73
+ expect(Kernel::REQUIRED).to include("bugsnag/integrations/railtie")
74
+ Kernel::REQUIRED = []
75
+ Bugsnag.load_integration(:railtie)
76
+ expect(Kernel::REQUIRED).to include("bugsnag/integrations/railtie")
77
+ end
78
+
79
+ after do
80
+ module Kernel
81
+ alias_method :require, :old_require
82
+ end
83
+ Kernel.send(:remove_const, :REQUIRED)
84
+ end
85
+ end
19
86
  end
@@ -29,6 +29,135 @@ describe Bugsnag::Configuration do
29
29
  end
30
30
  end
31
31
 
32
+ describe "set_proxy" do
33
+ it "defaults proxy settings to nil" do
34
+ expect(subject.proxy_host).to be nil
35
+ expect(subject.proxy_port).to be nil
36
+ expect(subject.proxy_user).to be nil
37
+ expect(subject.proxy_password).to be nil
38
+ end
39
+
40
+ it "allows proxy settings to be set directly" do
41
+ subject.proxy_host = "http://localhost"
42
+ subject.proxy_port = 34000
43
+ subject.proxy_user = "user"
44
+ subject.proxy_password = "password"
45
+ expect(subject.proxy_host).to eq("http://localhost")
46
+ expect(subject.proxy_port).to eq(34000)
47
+ expect(subject.proxy_user).to eq("user")
48
+ expect(subject.proxy_password).to eq("password")
49
+ end
50
+
51
+ it "parses a uri if provided" do
52
+ subject.parse_proxy("http://user:password@localhost:34000")
53
+ expect(subject.proxy_host).to eq("localhost")
54
+ expect(subject.proxy_port).to eq(34000)
55
+ expect(subject.proxy_user).to eq("user")
56
+ expect(subject.proxy_password).to eq("password")
57
+ end
58
+
59
+ it "automatically parses http_proxy environment variable" do
60
+ ENV['http_proxy'] = "http://user:password@localhost:34000"
61
+ expect(subject.proxy_host).to eq("localhost")
62
+ expect(subject.proxy_port).to eq(34000)
63
+ expect(subject.proxy_user).to eq("user")
64
+ expect(subject.proxy_password).to eq("password")
65
+ end
66
+
67
+ it "automatically parses https_proxy environment variable" do
68
+ ENV['https_proxy'] = "https://user:password@localhost:34000"
69
+ expect(subject.proxy_host).to eq("localhost")
70
+ expect(subject.proxy_port).to eq(34000)
71
+ expect(subject.proxy_user).to eq("user")
72
+ expect(subject.proxy_password).to eq("password")
73
+ end
74
+
75
+ after do
76
+ ENV['http_proxy'] = nil
77
+ ENV['https_proxy'] = nil
78
+ end
79
+ end
80
+
81
+ describe "logger" do
82
+ class TestLogger
83
+ attr_accessor :logs
84
+
85
+ def initialize
86
+ @logs = []
87
+ end
88
+
89
+ def log(level, name, &block)
90
+ message = block.call
91
+ @logs << {
92
+ :level => level,
93
+ :name => name,
94
+ :message => message
95
+ }
96
+ end
97
+
98
+ def info(name, &block)
99
+ log('info', name, &block)
100
+ end
101
+
102
+ def warn(name, &block)
103
+ log('warning', name, &block)
104
+ end
105
+
106
+ def debug(name, &block)
107
+ log('debug', name, &block)
108
+ end
109
+ end
110
+
111
+ before do
112
+ @logger = TestLogger.new
113
+ Bugsnag.configure do |bugsnag|
114
+ bugsnag.logger = @logger
115
+ end
116
+ end
117
+
118
+ it "should log info messages to the set logger" do
119
+ expect(@logger.logs.size).to eq(0)
120
+ Bugsnag.configuration.info("Info message")
121
+ expect(@logger.logs.size).to eq(1)
122
+ log = @logger.logs.first
123
+ expect(log).to eq({
124
+ :level => "info",
125
+ :name => "[Bugsnag]",
126
+ :message => "Info message"
127
+ })
128
+ end
129
+
130
+ it "should log warning messages to the set logger" do
131
+ expect(@logger.logs.size).to eq(0)
132
+ Bugsnag.configuration.warn("Warning message")
133
+ expect(@logger.logs.size).to eq(1)
134
+ log = @logger.logs.first
135
+ expect(log).to eq({
136
+ :level => "warning",
137
+ :name => "[Bugsnag]",
138
+ :message => "Warning message"
139
+ })
140
+ end
141
+
142
+ it "should log debug messages to the set logger" do
143
+ expect(@logger.logs.size).to eq(0)
144
+ Bugsnag.configuration.debug("Debug message")
145
+ expect(@logger.logs.size).to eq(1)
146
+ log = @logger.logs.first
147
+ expect(log).to eq({
148
+ :level => "debug",
149
+ :name => "[Bugsnag]",
150
+ :message => "Debug message"
151
+ })
152
+ end
153
+
154
+ after do
155
+ Bugsnag.configure do |bugsnag|
156
+ bugsnag.logger = Logger.new(StringIO.new)
157
+ end
158
+ end
159
+ end
160
+
32
161
  it "should have exit exception classes ignored by default" do
33
162
  expect(subject.ignore_classes).to eq(Set.new([SystemExit, Interrupt]))
34
163
  end
@@ -574,7 +574,27 @@ describe Bugsnag::Report do
574
574
  it "filters params from all payload hashes if they are set in default meta_data_filters" do
575
575
 
576
576
  Bugsnag.notify(BugsnagTestException.new("It crashed")) do |report|
577
- report.meta_data.merge!({:request => {:params => {:password => "1234", :other_password => "12345", :other_data => "123456"}}})
577
+ report.meta_data.merge!({
578
+ :request => {
579
+ :params => {
580
+ :password => "1234",
581
+ :other_password => "12345",
582
+ :other_data => "123456"
583
+ },
584
+ :cookie => "1234567890",
585
+ :authorization => "token",
586
+ :user_authorization => "token",
587
+ :secret_key => "key",
588
+ :user_secret => "key"
589
+ }
590
+ })
591
+ report.meta_data.merge!({
592
+ :session => {
593
+ :"warden.user.user.key" => "1234",
594
+ :"warden.user.foobar.key" => "1234",
595
+ :"warden.user.test" => "1234"
596
+ }
597
+ })
578
598
  end
579
599
 
580
600
  expect(Bugsnag).to have_sent_notification{ |payload, headers|
@@ -585,6 +605,15 @@ describe Bugsnag::Report do
585
605
  expect(event["metaData"]["request"]["params"]["password"]).to eq("[FILTERED]")
586
606
  expect(event["metaData"]["request"]["params"]["other_password"]).to eq("[FILTERED]")
587
607
  expect(event["metaData"]["request"]["params"]["other_data"]).to eq("123456")
608
+ expect(event["metaData"]["request"]["cookie"]).to eq("[FILTERED]")
609
+ expect(event["metaData"]["request"]["authorization"]).to eq("[FILTERED]")
610
+ expect(event["metaData"]["request"]["user_authorization"]).to eq("[FILTERED]")
611
+ expect(event["metaData"]["request"]["secret_key"]).to eq("[FILTERED]")
612
+ expect(event["metaData"]["request"]["user_secret"]).to eq("[FILTERED]")
613
+ expect(event["metaData"]["session"]).not_to be_nil
614
+ expect(event["metaData"]["session"]["warden.user.user.key"]).to eq("[FILTERED]")
615
+ expect(event["metaData"]["session"]["warden.user.foobar.key"]).to eq("[FILTERED]")
616
+ expect(event["metaData"]["session"]["warden.user.test"]).to eq("1234")
588
617
  }
589
618
  end
590
619
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.4
4
+ version: 6.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby