honeybadger 2.1.1 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +108 -164
  3. data/lib/honeybadger/agent/worker.rb +2 -2
  4. data/lib/honeybadger/backend/base.rb +15 -1
  5. data/lib/honeybadger/cli.rb +1 -1
  6. data/lib/honeybadger/cli/heroku.rb +0 -2
  7. data/lib/honeybadger/notice.rb +5 -5
  8. data/lib/honeybadger/trace.rb +3 -2
  9. data/lib/honeybadger/util/sanitizer.rb +31 -27
  10. data/lib/honeybadger/version.rb +1 -1
  11. data/vendor/cli/inifile.rb +628 -0
  12. data/vendor/cli/thor.rb +484 -0
  13. data/vendor/cli/thor/actions.rb +319 -0
  14. data/vendor/cli/thor/actions/create_file.rb +103 -0
  15. data/vendor/cli/thor/actions/create_link.rb +59 -0
  16. data/vendor/cli/thor/actions/directory.rb +118 -0
  17. data/vendor/cli/thor/actions/empty_directory.rb +135 -0
  18. data/vendor/cli/thor/actions/file_manipulation.rb +316 -0
  19. data/vendor/cli/thor/actions/inject_into_file.rb +107 -0
  20. data/vendor/cli/thor/base.rb +656 -0
  21. data/vendor/cli/thor/command.rb +133 -0
  22. data/vendor/cli/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  23. data/vendor/cli/thor/core_ext/io_binary_read.rb +10 -0
  24. data/vendor/cli/thor/core_ext/ordered_hash.rb +98 -0
  25. data/vendor/cli/thor/error.rb +32 -0
  26. data/vendor/cli/thor/group.rb +281 -0
  27. data/vendor/cli/thor/invocation.rb +178 -0
  28. data/vendor/cli/thor/line_editor.rb +17 -0
  29. data/vendor/cli/thor/line_editor/basic.rb +35 -0
  30. data/vendor/cli/thor/line_editor/readline.rb +88 -0
  31. data/vendor/cli/thor/parser.rb +4 -0
  32. data/vendor/cli/thor/parser/argument.rb +73 -0
  33. data/vendor/cli/thor/parser/arguments.rb +175 -0
  34. data/vendor/cli/thor/parser/option.rb +125 -0
  35. data/vendor/cli/thor/parser/options.rb +218 -0
  36. data/vendor/cli/thor/rake_compat.rb +71 -0
  37. data/vendor/cli/thor/runner.rb +322 -0
  38. data/vendor/cli/thor/shell.rb +81 -0
  39. data/vendor/cli/thor/shell/basic.rb +421 -0
  40. data/vendor/cli/thor/shell/color.rb +149 -0
  41. data/vendor/cli/thor/shell/html.rb +126 -0
  42. data/vendor/cli/thor/util.rb +267 -0
  43. data/vendor/cli/thor/version.rb +3 -0
  44. metadata +35 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a304866efae8f56e2fda056d380f07171ce9a678
4
- data.tar.gz: a9e6a086d55d5384d4d776bc5d4e208fd2f34924
3
+ metadata.gz: 79fe93e10a1b35669ebcd1c438a4912da596b62f
4
+ data.tar.gz: ffd173874c4d87f717e08ca9226b86bfbfec618e
5
5
  SHA512:
6
- metadata.gz: 2126e97c4ffb1162d2840a535e714565be7aa7ff2822755c382a247ff3fb3bf0ecefcc121bd9c97878573d25dbcbac6ea1ae8ade525a628c15d32dd3e705dea7
7
- data.tar.gz: 23b99fcda16cfc38ab3e50f5628f96d4bd3a4fe22ea74e576e149ebda236281fb4936cd5ec5445418ee4b8021d6ff9003b936a423cfab0d4ca657b1a872f0ead
6
+ metadata.gz: 98e463c6e283b7e31892aa1c9375fbefc47a6093e8da98f86d81e849a853ec5733857b701631b621ac3fdf42bf808ade90eb6dbaae5d81e79d410e3f0f217caf
7
+ data.tar.gz: 381ec55c9dacf32022183c85c21898ec7ac44f90acc8f91f819cb5005b792dccff94bce57cd9bb03e4799db92ea542d90b94207924ba16ccede32568c078fcc4
@@ -1,184 +1,128 @@
1
- * Update heroku cli deprecations.
2
-
3
- *@adamkuipers*
4
-
5
- * Don't insert middleware if they're disabled.
6
-
7
- *Bradley Priest*
8
-
9
- * Don't send RAW_POST_DATA.
10
-
11
- *Joshua Wood*
12
-
13
- * Filter HTTP_COOKIE in request cgi_data.
14
-
15
- *Sam McTaggart*
16
-
17
- * Fix breakage relating to Exceptions containing a :cause attribute which is not
18
- itself an Exception.
19
-
20
- *Gabe da Silveira*
21
-
22
- * Support for extracting the correct component & action for Rails Active Jobs (previously all Active Jobs where reported as 'ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper')
23
-
24
- *Panos Korros*
25
-
26
- * Allow API key to be overridden from `Honeybadger.notify`.
27
-
28
- *Joshua Wood*
29
-
30
- * Trim all sanitized strings to 2k.
31
-
32
- *Joshua Wood*
33
-
34
- * Add events to instrumented traces (i.e. in background jobs).
35
-
36
- *Joshua Wood*
37
-
38
- * Restart workers once per hour when shutdown due to 40x.
39
-
40
- *Joshua Wood*
41
-
42
- * Fix a tracing issue with net/http requests.
43
-
44
- *Joshua Wood*
45
-
46
- * Send request data with traces.
47
-
48
- *Joshua Wood*
49
-
50
- * Ditch per-controller metrics and add render_partial event to traces.
51
-
52
- *Benjamin Curtis*
53
-
54
- * Disable local variables when BetterErrors is detected.
55
-
56
- *Joshua Wood*
57
-
58
- * Exit with 1 from deploy command when request fails but ignore the failures in
59
- the capistrano task.
60
-
61
- *Joshua Wood*
62
-
63
- * Support Resque natively.
64
-
65
- *Joshua Wood*
66
-
67
- * Configure sidekiq.attempt_threshold to suppress notifications until retry
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file. See [Keep a
3
+ CHANGELOG](http://keepachangelog.com/) for how to update this file. This project
4
+ adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [Unreleased][unreleased]
7
+
8
+ ## [2.1.3] - 2015-07-24
9
+ ### Added
10
+ - Don't send empty local_variables in payload when disabled.
11
+ - Better logging of reason when API requests are denied.
12
+ - Truncate long queries in traces rather than tossing them.
13
+
14
+ ## Fixed
15
+ - Missing vendor libs.
16
+
17
+ ## [2.1.2][yanked]
18
+
19
+ ## [2.1.1] - 2015-07-15
20
+ ### Added
21
+ - Update heroku cli deprecations. -@adamkuipers
22
+ - Don't insert middleware if they're disabled. -Bradley Priest
23
+ - Don't send RAW_POST_DATA.
24
+ - Filter HTTP_COOKIE in request cgi_data. -Sam McTaggart
25
+ - Support for extracting the correct component & action for Rails Active Jobs
26
+ (previously all Active Jobs where reported as
27
+ 'ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper'). -Panos Korros
28
+
29
+ ### Fixed
30
+ - Fix breakage relating to Exceptions containing a :cause attribute which is not
31
+ itself an Exception. -Gabe da Silveira
32
+
33
+ ## [2.1.0] - 2015-06-04
34
+ ### Added
35
+ - Add events to instrumented traces (i.e. in background jobs).
36
+ - Restart workers once per hour when shutdown due to 40x.
37
+ - Send request data with traces.
38
+ - Support Resque natively.
39
+ - Configure sidekiq.attempt_threshold to suppress notifications until retry
68
40
  threshold is reached.
41
+ - Add exceptions.unwrap to config.
69
42
 
70
- *Joshua Wood*
71
-
72
- * Prevent Sinatra from using the same middleware more than once and add
43
+ ### Changed
44
+ - Trim all sanitized strings to 2k.
45
+ - Ditch per-controller metrics and add render_partial event to traces. -Benjamin Curtis
46
+ - Exit with 1 from deploy command when request fails but ignore the failures in
47
+ the capistrano task.
48
+ - Update default ignored exceptions to include the latest Rails rescue
49
+ responses. (see issue #107)
50
+ - Exceptions with the same type but caused within different delayed jobs are not
51
+ grouped together. They have their component and action set so that the
52
+ application class name and excecuted action is displayed in the UI. -Panos
53
+ Korros
54
+ - All events logged within a delayed_job even those logged by Honeybadger.notify
55
+ inherit the context of the delayed job and include the job_id, attempts,
56
+ last_error and queue. -Panos Korros
57
+
58
+ ### Fixed
59
+ - Allow API key to be overridden from `Honeybadger.notify`.
60
+ - Fix a tracing issue with net/http requests.
61
+ - Disable local variables when BetterErrors is detected.
62
+ - Prevent Sinatra from using the same middleware more than once and add
73
63
  sinatra.enabled setting (default true) to disable auto-initialization
74
64
  of Sinatra.
65
+ - Catch Errno::ENFILE when reading system stats. -Dmitry Polushkin
66
+ - Use explicit types for config options when casting from ENV.
75
67
 
76
- *Joshua Wood*
77
-
78
- * Update default ignored exceptions to include the latest Rails rescue
79
- responses. (see issue #107)
80
-
81
- *Joshua Wood*
82
-
83
- * Fix bug when processing source extract for action_view templates.
84
-
85
- *Joshua Wood*
86
-
87
- * Exceptions with the same type but caused within different delayed jobs are not grouped together. They have their component and action set so that the application class name and excecuted action is displayed in the UI.
88
-
89
- *Panos Korros*
90
-
91
- * All events logged within a delayed_job even those logged by Honeybadger.notify inherit the context of the delayed job and include the job_id, attempts, last_error and queue
92
-
93
- *Panos Korros*
94
-
95
- * Catch Errno::ENFILE when reading system stats.
96
-
97
- *Dmitry Polushkin*
98
-
99
- * Use explicit types for config options when casting from ENV.
100
-
101
- *Joshua Wood*
102
-
103
- * Add exceptions.unwrap to config.
104
-
105
- *Joshua Wood*
106
-
107
- * Don't access secrets before Rails initialization.
108
-
109
- *Joshua Wood*
110
-
111
- * Fix a bug which introduced a hard-dependency on Rack.
112
-
113
- *Joshua Wood*
114
-
115
- * Fix a bug in ping where JSON was double-quoted.
116
-
117
- *Joshua Wood*
68
+ ## [2.0.12] - 2015-04-27
69
+ ### Fixed
70
+ - Fix bug when processing source extract for action_view templates.
118
71
 
119
- * Add support for honeybadger_user with Capistrano 2.
72
+ ## [2.0.11] - 2015-04-02
73
+ ### Fixed
74
+ - Don't access secrets before Rails initialization.
75
+ - Fix a bug which introduced a hard-dependency on Rack.
120
76
 
121
- *Nathan Fixler*
77
+ ## [2.0.10] - 2015-03-24
78
+ ### Added
79
+ - Add support for honeybadger_user with Capistrano 2. -Nathan Fixler
122
80
 
123
- * Fixed a bug introduced in v2.0.8 which applied params filters to backtrace.
81
+ ### Fixed
82
+ - Fix a bug in ping where JSON was double-quoted.
124
83
 
125
- *Joshua Wood*
84
+ ## [2.0.9] - 2015-03-15
85
+ ### Fixed
86
+ - Fixed a bug introduced in v2.0.8 which applied params filters to backtrace.
87
+ - Fail gracefully when honeybadger.yml is empty or invalid.
126
88
 
127
- * Fail gracefully when honeybadger.yml is empty or invalid.
89
+ ## [2.0.8] - 2015-03-11
90
+ ### Added
91
+ - Include full backtrace when logging worker exceptions.
92
+ - Always send a test notice on install.
93
+ - Send the id of the current process with error reports.
128
94
 
129
- *Joshua Wood*
95
+ ### Fixed
96
+ - Handle bad encodings in exception payloads.
130
97
 
131
- * Handle bad encodings in exception payloads.
98
+ ## [2.0.7][yanked] - 2015-03-11
132
99
 
133
- *Joshua Wood*
100
+ ## [2.0.6] - 2015-02-16
101
+ ### Fixed
102
+ - Don't sub partial project root in backtrace lines.
134
103
 
135
- * Include full backtrace when logging worker exceptions.
136
-
137
- *Joshua Wood*
138
-
139
- * Always send a test notice on install.
140
-
141
- *Joshua Wood*
142
-
143
- * Send the id of the current process with error reports.
144
-
145
- *Joshua Wood*
146
-
147
- * Don't sub partial project root in backtrace lines.
148
-
149
- *Joshua Wood*
150
-
151
- * Merge exceptions.ignore config values with default ignored exception class
104
+ ## [2.0.5] - 2015-02-12
105
+ ### Added
106
+ - Merge exceptions.ignore config values with default ignored exception class
152
107
  names and add exceptions.ignore_only option to override.
153
108
 
154
- *Joshua Wood*
155
-
156
- * Support for capistrano-rbenv gem in Capistrano task.
157
-
158
- *Chris Gunther*
109
+ ## [2.0.4] - 2015-02-10
110
+ ### Added
111
+ - Support for capistrano-rbenv gem in Capistrano task. -Chris Gunther
159
112
 
160
- * Support for capistrano-rvm gem in Capistrano task.
113
+ ## [2.0.3] - 2015-02-10
114
+ ### Fixed
115
+ - Support for capistrano-rvm gem in Capistrano task. -Kyle Rippey
116
+ - Don't require honeybadger.yml to be writable when reading.
161
117
 
162
- *Kyle Rippey*
163
-
164
- * Don't require honeybadger.yml to be writable when reading.
165
-
166
- *Joshua Wood*
167
-
168
- * Detect ActionDispatch::TestProcess being included globally, fix issue locally,
118
+ ## [2.0.2] - 2015-02-04
119
+ ### Fixed
120
+ - Detect ActionDispatch::TestProcess being included globally, fix issue locally,
169
121
  warn the user.
122
+ - Fix a nil logger bug when a config error occurs.
170
123
 
171
- *Joshua Wood*
172
-
173
- * Fix a nil logger bug when a config error occurs.
174
-
175
- *Joshua Wood*
176
-
177
- * Don't instrument metrics and traces in Rails when features are not available
178
- on account
179
-
180
- *Joshua Wood*
181
-
182
- * Don't send error reports when disabled via configuration
183
-
184
- *Joshua Wood*
124
+ ## [2.0.1] - 2015-01-30
125
+ ### Fixed
126
+ - Don't instrument metrics and traces in Rails when features are not available
127
+ on account.
128
+ - Don't send error reports when disabled via configuration.
@@ -202,10 +202,10 @@ module Honeybadger
202
202
  add_throttle(1.25)
203
203
  debug { sprintf('worker applying throttle=1.25 interval=%s feature=%s code=%s', throttle_interval, feature, response.code) }
204
204
  when 402
205
- warn { sprintf('data will not be reported until next restart (payment required) feature=%s code=%s', feature, response.code) }
205
+ warn { sprintf('data will not be reported (payment required) feature=%s code=%s', feature, response.code) }
206
206
  suspend(3600)
207
207
  when 403
208
- warn { sprintf('data will not be reported until next restart (unauthorized) feature=%s code=%s', feature, response.code) }
208
+ warn { sprintf('data will not be reported feature=%s code=%s error=%s', feature, response.code, response.error.to_s.dump) }
209
209
  suspend(3600)
210
210
  when 201
211
211
  if throttle = del_throttle
@@ -1,12 +1,15 @@
1
1
  require 'forwardable'
2
2
  require 'net/http'
3
+ require 'json'
3
4
 
4
5
  require 'honeybadger/logging'
5
6
 
6
7
  module Honeybadger
7
8
  module Backend
8
9
  class Response
9
- attr_reader :code, :body, :message
10
+ NOT_BLANK = /\S/
11
+
12
+ attr_reader :code, :body, :message, :error
10
13
 
11
14
  # Public: Initializes the Response instance.
12
15
  #
@@ -27,11 +30,22 @@ module Honeybadger
27
30
  end
28
31
 
29
32
  @success = (200..299).cover?(@code)
33
+ @error = parse_error(body) unless @success
30
34
  end
31
35
 
32
36
  def success?
33
37
  @success
34
38
  end
39
+
40
+ private
41
+
42
+ def parse_error(body)
43
+ return unless body =~ NOT_BLANK
44
+ obj = JSON.parse(body)
45
+ return obj['error'] if obj.kind_of?(Hash)
46
+ rescue JSON::ParserError
47
+ nil
48
+ end
35
49
  end
36
50
 
37
51
  class Base
@@ -1,4 +1,4 @@
1
- $:.unshift(File.expand_path('../../../vendor/thor/lib', __FILE__))
1
+ $:.unshift(File.expand_path('../../../vendor/cli', __FILE__))
2
2
 
3
3
  require 'thor'
4
4
 
@@ -1,5 +1,3 @@
1
- $:.unshift(File.expand_path('../../../../vendor/inifile/lib', __FILE__))
2
-
3
1
  require 'honeybadger/cli/helpers'
4
2
 
5
3
  module Honeybadger
@@ -163,6 +163,9 @@ module Honeybadger
163
163
  #
164
164
  # Returns Hash JSON representation of notice
165
165
  def as_json(*args)
166
+ @request[:context] = s(context)
167
+ @request[:local_variables] = s(local_variables) if local_variables
168
+
166
169
  {
167
170
  api_key: s(api_key),
168
171
  notifier: NOTIFIER,
@@ -176,10 +179,7 @@ module Honeybadger
176
179
  tags: s(tags),
177
180
  causes: s(causes)
178
181
  },
179
- request: @request.update({
180
- context: s(context),
181
- local_variables: s(local_variables)
182
- }),
182
+ request: @request,
183
183
  server: {
184
184
  project_root: s(config[:root]),
185
185
  environment_name: s(config[:env]),
@@ -370,7 +370,7 @@ module Honeybadger
370
370
  #
371
371
  # Returns a Hash of local variables
372
372
  def local_variables_from_exception(exception, config)
373
- return {} unless send_local_variables?(config)
373
+ return nil unless send_local_variables?(config)
374
374
  return {} unless Exception === exception
375
375
  return {} unless exception.respond_to?(:__honeybadger_bindings_stack)
376
376
  return {} if exception.__honeybadger_bindings_stack.empty?
@@ -1,6 +1,7 @@
1
1
  require 'securerandom'
2
2
 
3
3
  require 'honeybadger/agent'
4
+ require 'honeybadger/util/sanitizer'
4
5
 
5
6
  module Honeybadger
6
7
  class Trace
@@ -175,11 +176,11 @@ module Honeybadger
175
176
  end
176
177
 
177
178
  def to_s
178
- return "Super long query" if event.payload[:sql].length > 1024
179
179
  sql = event.payload[:sql]
180
180
  sql = sql.gsub(EscapedQuotes, EmptyReplacement).gsub(SQuotedData, Replacement)
181
181
  sql = sql.gsub(DQuotedData, Replacement) unless ::ActiveRecord::Base.connection_pool.spec.config[:adapter] =~ DoubleQuoters
182
- sql.gsub(NumericData, Replacement).gsub(Newline, EmptyReplacement).squeeze(' ')
182
+ sql = sql.gsub(NumericData, Replacement).gsub(Newline, EmptyReplacement).squeeze(' ')
183
+ Util::Sanitizer.sanitize_string(sql)
183
184
  end
184
185
  end
185
186
 
@@ -31,7 +31,7 @@ module Honeybadger
31
31
  end
32
32
 
33
33
  if data.kind_of?(String)
34
- sanitize_string(data)
34
+ self.class.sanitize_string(data)
35
35
  elsif data.respond_to?(:to_hash)
36
36
  return '[max depth reached]' if depth >= max_depth
37
37
  hash = data.to_hash
@@ -53,7 +53,7 @@ module Honeybadger
53
53
  elsif OBJECT_WHITELIST.any? {|c| data.kind_of?(c) }
54
54
  data
55
55
  else
56
- sanitize_string(data.to_s)
56
+ self.class.sanitize_string(data.to_s)
57
57
  end
58
58
  end
59
59
 
@@ -82,12 +82,39 @@ module Honeybadger
82
82
  filtered_url
83
83
  end
84
84
 
85
- private
86
-
87
85
  VALID_ENCODINGS = [Encoding::UTF_8, Encoding::ISO_8859_1].freeze
88
86
  ENCODE_OPTS = { invalid: :replace, undef: :replace, replace: '?'.freeze }.freeze
89
87
  UTF8_STRING = ''.freeze
90
88
 
89
+ class << self
90
+
91
+ def valid_encoding?(data)
92
+ data.valid_encoding? && (
93
+ VALID_ENCODINGS.include?(data.encoding) ||
94
+ VALID_ENCODINGS.include?(Encoding.compatible?(UTF8_STRING, data))
95
+ )
96
+ end
97
+
98
+ def valid_encoding(data)
99
+ return data if valid_encoding?(data)
100
+
101
+ if data.encoding == Encoding::UTF_8
102
+ data.encode(Encoding::UTF_16, ENCODE_OPTS).encode!(Encoding::UTF_8)
103
+ else
104
+ data.encode(Encoding::UTF_8, ENCODE_OPTS)
105
+ end
106
+ end
107
+
108
+ def sanitize_string(data)
109
+ data = valid_encoding(data)
110
+ return data unless data.respond_to?(:size) && data.size > MAX_STRING_SIZE
111
+ data[0...MAX_STRING_SIZE] + TRUNCATION_REPLACEMENT
112
+ end
113
+
114
+ end
115
+
116
+ private
117
+
91
118
  attr_reader :max_depth, :filters
92
119
 
93
120
  def recursive?(data)
@@ -105,29 +132,6 @@ module Honeybadger
105
132
  end
106
133
  end
107
134
  end
108
-
109
- def valid_encoding?(data)
110
- data.valid_encoding? && (
111
- VALID_ENCODINGS.include?(data.encoding) ||
112
- VALID_ENCODINGS.include?(Encoding.compatible?(UTF8_STRING, data))
113
- )
114
- end
115
-
116
- def valid_encoding(data)
117
- return data if valid_encoding?(data)
118
-
119
- if data.encoding == Encoding::UTF_8
120
- data.encode(Encoding::UTF_16, ENCODE_OPTS).encode!(Encoding::UTF_8)
121
- else
122
- data.encode(Encoding::UTF_8, ENCODE_OPTS)
123
- end
124
- end
125
-
126
- def sanitize_string(data)
127
- data = valid_encoding(data)
128
- return data unless data.respond_to?(:size) && data.size > MAX_STRING_SIZE
129
- data[0...MAX_STRING_SIZE] + TRUNCATION_REPLACEMENT
130
- end
131
135
  end
132
136
  end
133
137
  end