honeybadger 5.0.2 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +713 -701
  3. data/LICENSE +19 -19
  4. data/README.md +57 -57
  5. data/TROUBLESHOOTING.md +3 -3
  6. data/bin/honeybadger +5 -5
  7. data/lib/honeybadger/agent.rb +488 -488
  8. data/lib/honeybadger/backend/base.rb +116 -116
  9. data/lib/honeybadger/backend/debug.rb +22 -22
  10. data/lib/honeybadger/backend/null.rb +29 -29
  11. data/lib/honeybadger/backend/server.rb +62 -62
  12. data/lib/honeybadger/backend/test.rb +46 -46
  13. data/lib/honeybadger/backend.rb +27 -27
  14. data/lib/honeybadger/backtrace.rb +181 -181
  15. data/lib/honeybadger/breadcrumbs/active_support.rb +119 -119
  16. data/lib/honeybadger/breadcrumbs/breadcrumb.rb +53 -53
  17. data/lib/honeybadger/breadcrumbs/collector.rb +82 -82
  18. data/lib/honeybadger/breadcrumbs/logging.rb +51 -51
  19. data/lib/honeybadger/breadcrumbs/ring_buffer.rb +44 -44
  20. data/lib/honeybadger/breadcrumbs.rb +8 -8
  21. data/lib/honeybadger/cli/deploy.rb +43 -43
  22. data/lib/honeybadger/cli/exec.rb +143 -143
  23. data/lib/honeybadger/cli/helpers.rb +28 -28
  24. data/lib/honeybadger/cli/heroku.rb +129 -129
  25. data/lib/honeybadger/cli/install.rb +101 -101
  26. data/lib/honeybadger/cli/main.rb +237 -237
  27. data/lib/honeybadger/cli/notify.rb +67 -67
  28. data/lib/honeybadger/cli/test.rb +267 -267
  29. data/lib/honeybadger/cli.rb +14 -14
  30. data/lib/honeybadger/config/defaults.rb +336 -333
  31. data/lib/honeybadger/config/env.rb +42 -42
  32. data/lib/honeybadger/config/ruby.rb +146 -146
  33. data/lib/honeybadger/config/yaml.rb +76 -76
  34. data/lib/honeybadger/config.rb +413 -413
  35. data/lib/honeybadger/const.rb +20 -20
  36. data/lib/honeybadger/context_manager.rb +55 -55
  37. data/lib/honeybadger/conversions.rb +16 -16
  38. data/lib/honeybadger/init/rails.rb +38 -38
  39. data/lib/honeybadger/init/rake.rb +66 -66
  40. data/lib/honeybadger/init/ruby.rb +11 -11
  41. data/lib/honeybadger/init/sinatra.rb +51 -51
  42. data/lib/honeybadger/logging.rb +177 -177
  43. data/lib/honeybadger/notice.rb +579 -568
  44. data/lib/honeybadger/plugin.rb +210 -210
  45. data/lib/honeybadger/plugins/breadcrumbs.rb +111 -111
  46. data/lib/honeybadger/plugins/delayed_job/plugin.rb +56 -56
  47. data/lib/honeybadger/plugins/delayed_job.rb +22 -22
  48. data/lib/honeybadger/plugins/faktory.rb +52 -52
  49. data/lib/honeybadger/plugins/lambda.rb +71 -71
  50. data/lib/honeybadger/plugins/local_variables.rb +44 -44
  51. data/lib/honeybadger/plugins/passenger.rb +23 -23
  52. data/lib/honeybadger/plugins/rails.rb +72 -63
  53. data/lib/honeybadger/plugins/resque.rb +72 -72
  54. data/lib/honeybadger/plugins/shoryuken.rb +52 -52
  55. data/lib/honeybadger/plugins/sidekiq.rb +71 -62
  56. data/lib/honeybadger/plugins/sucker_punch.rb +18 -18
  57. data/lib/honeybadger/plugins/thor.rb +32 -32
  58. data/lib/honeybadger/plugins/warden.rb +19 -19
  59. data/lib/honeybadger/rack/error_notifier.rb +92 -92
  60. data/lib/honeybadger/rack/user_feedback.rb +88 -88
  61. data/lib/honeybadger/rack/user_informer.rb +45 -45
  62. data/lib/honeybadger/ruby.rb +2 -2
  63. data/lib/honeybadger/singleton.rb +103 -103
  64. data/lib/honeybadger/tasks.rb +22 -22
  65. data/lib/honeybadger/templates/feedback_form.erb +84 -84
  66. data/lib/honeybadger/util/http.rb +92 -92
  67. data/lib/honeybadger/util/lambda.rb +32 -32
  68. data/lib/honeybadger/util/request_hash.rb +73 -73
  69. data/lib/honeybadger/util/request_payload.rb +41 -41
  70. data/lib/honeybadger/util/revision.rb +39 -39
  71. data/lib/honeybadger/util/sanitizer.rb +214 -214
  72. data/lib/honeybadger/util/sql.rb +34 -34
  73. data/lib/honeybadger/util/stats.rb +50 -50
  74. data/lib/honeybadger/version.rb +4 -4
  75. data/lib/honeybadger/worker.rb +253 -253
  76. data/lib/honeybadger.rb +11 -11
  77. data/resources/ca-bundle.crt +3376 -3376
  78. data/vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb +5 -5
  79. data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +89 -89
  80. data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano/legacy.rb +47 -47
  81. data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -2
  82. data/vendor/cli/inifile.rb +628 -628
  83. data/vendor/cli/thor/actions/create_file.rb +103 -103
  84. data/vendor/cli/thor/actions/create_link.rb +59 -59
  85. data/vendor/cli/thor/actions/directory.rb +118 -118
  86. data/vendor/cli/thor/actions/empty_directory.rb +135 -135
  87. data/vendor/cli/thor/actions/file_manipulation.rb +316 -316
  88. data/vendor/cli/thor/actions/inject_into_file.rb +107 -107
  89. data/vendor/cli/thor/actions.rb +319 -319
  90. data/vendor/cli/thor/base.rb +656 -656
  91. data/vendor/cli/thor/command.rb +133 -133
  92. data/vendor/cli/thor/core_ext/hash_with_indifferent_access.rb +77 -77
  93. data/vendor/cli/thor/core_ext/io_binary_read.rb +10 -10
  94. data/vendor/cli/thor/core_ext/ordered_hash.rb +98 -98
  95. data/vendor/cli/thor/error.rb +32 -32
  96. data/vendor/cli/thor/group.rb +281 -281
  97. data/vendor/cli/thor/invocation.rb +178 -178
  98. data/vendor/cli/thor/line_editor/basic.rb +35 -35
  99. data/vendor/cli/thor/line_editor/readline.rb +88 -88
  100. data/vendor/cli/thor/line_editor.rb +17 -17
  101. data/vendor/cli/thor/parser/argument.rb +73 -73
  102. data/vendor/cli/thor/parser/arguments.rb +175 -175
  103. data/vendor/cli/thor/parser/option.rb +125 -125
  104. data/vendor/cli/thor/parser/options.rb +218 -218
  105. data/vendor/cli/thor/parser.rb +4 -4
  106. data/vendor/cli/thor/rake_compat.rb +71 -71
  107. data/vendor/cli/thor/runner.rb +322 -322
  108. data/vendor/cli/thor/shell/basic.rb +421 -421
  109. data/vendor/cli/thor/shell/color.rb +149 -149
  110. data/vendor/cli/thor/shell/html.rb +126 -126
  111. data/vendor/cli/thor/shell.rb +81 -81
  112. data/vendor/cli/thor/util.rb +267 -267
  113. data/vendor/cli/thor/version.rb +3 -3
  114. data/vendor/cli/thor.rb +484 -484
  115. metadata +10 -5
@@ -1,42 +1,42 @@
1
- require 'set'
2
-
3
- module Honeybadger
4
- class Config
5
- module Env
6
- CONFIG_KEY = /\AHONEYBADGER_(.+)\Z/.freeze
7
- CONFIG_MAPPING = Hash[DEFAULTS.keys.map {|k| [k.to_s.upcase.gsub(KEY_REPLACEMENT, '_'), k] }].freeze
8
- ARRAY_VALUES = Regexp.new('\s*,\s*').freeze
9
- IGNORED_TYPES = Set[Hash]
10
-
11
- def self.new(env = ENV)
12
- hash = {}
13
-
14
- env.each_pair do |k,v|
15
- next unless k.match(CONFIG_KEY)
16
- next unless config_key = CONFIG_MAPPING[$1]
17
- type = OPTIONS[config_key][:type]
18
- next if IGNORED_TYPES.include?(type)
19
- hash[config_key] = cast_value(v, type)
20
- end
21
-
22
- hash
23
- end
24
-
25
- def self.cast_value(value, type = String)
26
- v = value.to_s
27
-
28
- if type == Boolean
29
- !!(v =~ /\A(true|t|1)\z/i)
30
- elsif type == Array
31
- v.split(ARRAY_VALUES).map(&method(:cast_value))
32
- elsif type == Integer
33
- v.to_i
34
- elsif type == Float
35
- v.to_f
36
- else
37
- v
38
- end
39
- end
40
- end
41
- end
42
- end
1
+ require 'set'
2
+
3
+ module Honeybadger
4
+ class Config
5
+ module Env
6
+ CONFIG_KEY = /\AHONEYBADGER_(.+)\Z/.freeze
7
+ CONFIG_MAPPING = Hash[DEFAULTS.keys.map {|k| [k.to_s.upcase.gsub(KEY_REPLACEMENT, '_'), k] }].freeze
8
+ ARRAY_VALUES = Regexp.new('\s*,\s*').freeze
9
+ IGNORED_TYPES = Set[Hash]
10
+
11
+ def self.new(env = ENV)
12
+ hash = {}
13
+
14
+ env.each_pair do |k,v|
15
+ next unless k.match(CONFIG_KEY)
16
+ next unless config_key = CONFIG_MAPPING[$1]
17
+ type = OPTIONS[config_key][:type]
18
+ next if IGNORED_TYPES.include?(type)
19
+ hash[config_key] = cast_value(v, type)
20
+ end
21
+
22
+ hash
23
+ end
24
+
25
+ def self.cast_value(value, type = String)
26
+ v = value.to_s
27
+
28
+ if type == Boolean
29
+ !!(v =~ /\A(true|t|1)\z/i)
30
+ elsif type == Array
31
+ v.split(ARRAY_VALUES).map(&method(:cast_value))
32
+ elsif type == Integer
33
+ v.to_i
34
+ elsif type == Float
35
+ v.to_f
36
+ else
37
+ v
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,146 +1,146 @@
1
- module Honeybadger
2
- class Config
3
- class Mash
4
- KEYS = DEFAULTS.keys.map(&:to_s).freeze
5
-
6
- def initialize(config, prefix: nil, hash: {})
7
- @config = config
8
- @prefix = prefix
9
- @hash = hash
10
- end
11
-
12
- def to_hash
13
- hash.to_hash
14
- end
15
- alias to_h to_hash
16
-
17
- private
18
-
19
- attr_reader :config, :prefix, :hash
20
-
21
- def method_missing(method_name, *args, &block)
22
- m = method_name.to_s
23
- if mash?(m)
24
- return Mash.new(config, prefix: key(m), hash: hash)
25
- elsif setter?(m)
26
- return hash.send(:[]=, key(m).to_sym, args[0])
27
- elsif getter?(m)
28
- return get(key(m))
29
- end
30
-
31
- super
32
- end
33
-
34
- def respond_to_missing?(method_name, include_private = false)
35
- true
36
- end
37
-
38
- def mash?(method)
39
- key = [prefix, method.to_s + '.'].compact.join('.')
40
- KEYS.any? {|k| k.start_with?(key) }
41
- end
42
-
43
- def setter?(method_name)
44
- return false unless method_name.to_s =~ /=\z/
45
- key = key(method_name)
46
- KEYS.any? {|k| k == key }
47
- end
48
-
49
- def getter?(method_name)
50
- key = key(method_name)
51
- KEYS.any? {|k| k == key }
52
- end
53
-
54
- def key(method_name)
55
- parts = [prefix, method_name.to_s.chomp('=')]
56
- parts.compact!
57
- parts.join('.')
58
- end
59
-
60
- def get(key)
61
- k = key.to_sym
62
- return hash[k] if hash.has_key?(k)
63
- config.get(k)
64
- end
65
- end
66
-
67
- class Ruby < Mash
68
- def logger=(logger)
69
- hash[:logger] = logger
70
- end
71
-
72
- def logger
73
- get(:logger) || config.logger
74
- end
75
-
76
- def backend=(backend)
77
- hash[:backend] = backend
78
- end
79
-
80
- def backend
81
- get(:backend) || config.backend
82
- end
83
-
84
- def before_notify(action = nil, &block)
85
- hooks = Array(get(:before_notify)).dup
86
-
87
- if action && validate_before_action(action)
88
- hooks << action
89
- elsif block_given? && validate_before_action(block)
90
- hooks << block
91
- end
92
-
93
- hash[:before_notify] = hooks
94
- end
95
-
96
- def backtrace_filter(&block)
97
- if block_given?
98
- logger.warn('DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter')
99
- hash[:backtrace_filter] = block if block_given?
100
- end
101
-
102
- get(:backtrace_filter)
103
- end
104
-
105
- def exception_filter(&block)
106
- if block_given?
107
- logger.warn('DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter')
108
- hash[:exception_filter] = block
109
- end
110
-
111
- get(:exception_filter)
112
- end
113
-
114
- def exception_fingerprint(&block)
115
- if block_given?
116
- logger.warn('DEPRECATED: exception_fingerprint is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_fingerprint')
117
- hash[:exception_fingerprint] = block
118
- end
119
-
120
- get(:exception_fingerprint)
121
- end
122
-
123
- private
124
-
125
- def validate_before_action(action)
126
- if !action.respond_to?(:call)
127
- logger.warn(
128
- 'You attempted to add a before notify hook that does not respond ' \
129
- 'to #call. We are discarding this hook so your intended behavior ' \
130
- 'will not occur.'
131
- )
132
- false
133
- elsif action.arity != 1
134
- logger.warn(
135
- 'You attempted to add a before notify hook that has an arity ' \
136
- 'other than one. We are discarding this hook so your intended ' \
137
- 'behavior will not occur.'
138
- )
139
- false
140
- else
141
- true
142
- end
143
- end
144
- end
145
- end
146
- end
1
+ module Honeybadger
2
+ class Config
3
+ class Mash
4
+ KEYS = DEFAULTS.keys.map(&:to_s).freeze
5
+
6
+ def initialize(config, prefix: nil, hash: {})
7
+ @config = config
8
+ @prefix = prefix
9
+ @hash = hash
10
+ end
11
+
12
+ def to_hash
13
+ hash.to_hash
14
+ end
15
+ alias to_h to_hash
16
+
17
+ private
18
+
19
+ attr_reader :config, :prefix, :hash
20
+
21
+ def method_missing(method_name, *args, &block)
22
+ m = method_name.to_s
23
+ if mash?(m)
24
+ return Mash.new(config, prefix: key(m), hash: hash)
25
+ elsif setter?(m)
26
+ return hash.send(:[]=, key(m).to_sym, args[0])
27
+ elsif getter?(m)
28
+ return get(key(m))
29
+ end
30
+
31
+ super
32
+ end
33
+
34
+ def respond_to_missing?(method_name, include_private = false)
35
+ true
36
+ end
37
+
38
+ def mash?(method)
39
+ key = [prefix, method.to_s + '.'].compact.join('.')
40
+ KEYS.any? {|k| k.start_with?(key) }
41
+ end
42
+
43
+ def setter?(method_name)
44
+ return false unless method_name.to_s =~ /=\z/
45
+ key = key(method_name)
46
+ KEYS.any? {|k| k == key }
47
+ end
48
+
49
+ def getter?(method_name)
50
+ key = key(method_name)
51
+ KEYS.any? {|k| k == key }
52
+ end
53
+
54
+ def key(method_name)
55
+ parts = [prefix, method_name.to_s.chomp('=')]
56
+ parts.compact!
57
+ parts.join('.')
58
+ end
59
+
60
+ def get(key)
61
+ k = key.to_sym
62
+ return hash[k] if hash.has_key?(k)
63
+ config.get(k)
64
+ end
65
+ end
66
+
67
+ class Ruby < Mash
68
+ def logger=(logger)
69
+ hash[:logger] = logger
70
+ end
71
+
72
+ def logger
73
+ get(:logger) || config.logger
74
+ end
75
+
76
+ def backend=(backend)
77
+ hash[:backend] = backend
78
+ end
79
+
80
+ def backend
81
+ get(:backend) || config.backend
82
+ end
83
+
84
+ def before_notify(action = nil, &block)
85
+ hooks = Array(get(:before_notify)).dup
86
+
87
+ if action && validate_before_action(action)
88
+ hooks << action
89
+ elsif block_given? && validate_before_action(block)
90
+ hooks << block
91
+ end
92
+
93
+ hash[:before_notify] = hooks
94
+ end
95
+
96
+ def backtrace_filter(&block)
97
+ if block_given?
98
+ logger.warn('DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter')
99
+ hash[:backtrace_filter] = block if block_given?
100
+ end
101
+
102
+ get(:backtrace_filter)
103
+ end
104
+
105
+ def exception_filter(&block)
106
+ if block_given?
107
+ logger.warn('DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter')
108
+ hash[:exception_filter] = block
109
+ end
110
+
111
+ get(:exception_filter)
112
+ end
113
+
114
+ def exception_fingerprint(&block)
115
+ if block_given?
116
+ logger.warn('DEPRECATED: exception_fingerprint is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_fingerprint')
117
+ hash[:exception_fingerprint] = block
118
+ end
119
+
120
+ get(:exception_fingerprint)
121
+ end
122
+
123
+ private
124
+
125
+ def validate_before_action(action)
126
+ if !action.respond_to?(:call)
127
+ logger.warn(
128
+ 'You attempted to add a before notify hook that does not respond ' \
129
+ 'to #call. We are discarding this hook so your intended behavior ' \
130
+ 'will not occur.'
131
+ )
132
+ false
133
+ elsif action.arity != 1
134
+ logger.warn(
135
+ 'You attempted to add a before notify hook that has an arity ' \
136
+ 'other than one. We are discarding this hook so your intended ' \
137
+ 'behavior will not occur.'
138
+ )
139
+ false
140
+ else
141
+ true
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -1,76 +1,76 @@
1
- require 'pathname'
2
- require 'yaml'
3
- require 'erb'
4
-
5
- module Honeybadger
6
- class Config
7
- module Yaml
8
- DISALLOWED_KEYS = [:'config.path'].freeze
9
-
10
- def self.new(path, env = 'production')
11
- path = path.kind_of?(Pathname) ? path : Pathname.new(path)
12
-
13
- if !path.exist?
14
- raise ConfigError, "The configuration file #{path} was not found."
15
- elsif !path.file?
16
- raise ConfigError, "The configuration file #{path} is not a file."
17
- elsif !path.readable?
18
- raise ConfigError, "The configuration file #{path} is not readable."
19
- end
20
-
21
- yaml = load_yaml(path)
22
- yaml.merge!(yaml[env]) if yaml[env].kind_of?(Hash)
23
-
24
- dotify_keys(yaml)
25
- end
26
-
27
- def self.load_yaml(path)
28
- begin
29
- # This uses `YAML.unsafe_load` to support loading arbitrary Ruby
30
- # classes, such as !ruby/regexp. This was the default behavior prior
31
- # to Psych 4. https://bugs.ruby-lang.org/issues/17866
32
- method = YAML.respond_to?(:unsafe_load) ? :unsafe_load : :load
33
- yaml = YAML.send(method, ERB.new(path.read).result)
34
- rescue => e
35
- config_error = ConfigError.new(e.to_s)
36
-
37
- if e.backtrace
38
- backtrace = e.backtrace.map do |line|
39
- if line.start_with?('(erb)'.freeze)
40
- line.gsub('(erb)'.freeze, path.to_s)
41
- else
42
- line
43
- end
44
- end
45
- config_error.set_backtrace(backtrace)
46
- end
47
-
48
- raise config_error
49
- end
50
-
51
- case yaml
52
- when Hash
53
- yaml
54
- when NilClass, FalseClass
55
- {}
56
- else
57
- raise ConfigError, "The configuration file #{path} is invalid."
58
- end
59
- end
60
-
61
- def self.dotify_keys(hash, key_prefix = nil)
62
- {}.tap do |new_hash|
63
- hash.each_pair do |k,v|
64
- k = [key_prefix, k].compact.join('.')
65
- if v.kind_of?(Hash)
66
- new_hash.update(dotify_keys(v, k))
67
- else
68
- next if DISALLOWED_KEYS.include?(k.to_sym)
69
- new_hash[k.to_sym] = v
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
1
+ require 'pathname'
2
+ require 'yaml'
3
+ require 'erb'
4
+
5
+ module Honeybadger
6
+ class Config
7
+ module Yaml
8
+ DISALLOWED_KEYS = [:'config.path'].freeze
9
+
10
+ def self.new(path, env = 'production')
11
+ path = path.kind_of?(Pathname) ? path : Pathname.new(path)
12
+
13
+ if !path.exist?
14
+ raise ConfigError, "The configuration file #{path} was not found."
15
+ elsif !path.file?
16
+ raise ConfigError, "The configuration file #{path} is not a file."
17
+ elsif !path.readable?
18
+ raise ConfigError, "The configuration file #{path} is not readable."
19
+ end
20
+
21
+ yaml = load_yaml(path)
22
+ yaml.merge!(yaml[env]) if yaml[env].kind_of?(Hash)
23
+
24
+ dotify_keys(yaml)
25
+ end
26
+
27
+ def self.load_yaml(path)
28
+ begin
29
+ # This uses `YAML.unsafe_load` to support loading arbitrary Ruby
30
+ # classes, such as !ruby/regexp. This was the default behavior prior
31
+ # to Psych 4. https://bugs.ruby-lang.org/issues/17866
32
+ method = YAML.respond_to?(:unsafe_load) ? :unsafe_load : :load
33
+ yaml = YAML.send(method, ERB.new(path.read).result)
34
+ rescue => e
35
+ config_error = ConfigError.new(e.to_s)
36
+
37
+ if e.backtrace
38
+ backtrace = e.backtrace.map do |line|
39
+ if line.start_with?('(erb)'.freeze)
40
+ line.gsub('(erb)'.freeze, path.to_s)
41
+ else
42
+ line
43
+ end
44
+ end
45
+ config_error.set_backtrace(backtrace)
46
+ end
47
+
48
+ raise config_error
49
+ end
50
+
51
+ case yaml
52
+ when Hash
53
+ yaml
54
+ when NilClass, FalseClass
55
+ {}
56
+ else
57
+ raise ConfigError, "The configuration file #{path} is invalid."
58
+ end
59
+ end
60
+
61
+ def self.dotify_keys(hash, key_prefix = nil)
62
+ {}.tap do |new_hash|
63
+ hash.each_pair do |k,v|
64
+ k = [key_prefix, k].compact.join('.')
65
+ if v.kind_of?(Hash)
66
+ new_hash.update(dotify_keys(v, k))
67
+ else
68
+ next if DISALLOWED_KEYS.include?(k.to_sym)
69
+ new_hash[k.to_sym] = v
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end