slack_500 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 563b520c7aa9866295b2d884c47490a26096c87f5301b6a2d33d0f9d0998a664
4
- data.tar.gz: d076c0cf542b9dc1b6e89e95b4f8e08ad4dd7a0302c64ff5f645d4b4c7009110
3
+ metadata.gz: cf51440f0ff4a45dc0bc36864fd1a89aaf52d92986d7ebcb5ccae8828e81c892
4
+ data.tar.gz: 758993a70ff1e51e5d843a0c56e61bae41a2bc607a46d92d67d7bf5784fceeb1
5
5
  SHA512:
6
- metadata.gz: 53730ab5b02f003a0b59c4247daf8752d81e160e246ce34a469de344a187baa39d232abeef9b07a3d5c09e763c7f3706afffa92d8fc2b1b7fd3acc9bf41f8731
7
- data.tar.gz: fed8ba552921d46969aac3d23fc2808384049948cb7576668f268f0a8915a652043d96595f9a2a99fef24d660078fdcb8fc642b5e50ee6548bc8efb92c303cf4
6
+ metadata.gz: 05cb0dc736b454453980c53df548907a82fb87d7bec6f8454e483d0be4281f141e6ac56edfe711f1d088415d16604713a3298f56fe99cf3e80405b4a42011125
7
+ data.tar.gz: 0ead63383d654a527988c2ae2d82b2d7a5f0b57cc998b2ec0de53e18068080ff29a53a3b091e877290e40848d24c2bff05e0bb56f4cabb3bb4d720b3386e8fc7
data/README.md CHANGED
@@ -6,12 +6,13 @@ The following items are displayed in the Slack message.
6
6
 
7
7
  - http method
8
8
  - Controller and Action
9
- - Parameters
9
+ - Query Parameters
10
+ - Remote IP
10
11
  - User Agent
11
12
  - Error Message
12
13
  - Backtrace
13
14
 
14
- <img src="https://user-images.githubusercontent.com/2704723/60082808-7ca71700-976f-11e9-91fd-9dc235b18850.png" width="60%"/>
15
+ <img src="https://user-images.githubusercontent.com/2704723/60161177-ee479980-9831-11e9-9861-360ce28ffdef.png" width="70%"/>
15
16
 
16
17
 
17
18
  ## Installation
@@ -1,3 +1,3 @@
1
1
  module Slack500
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
data/lib/slack_500.rb CHANGED
@@ -47,8 +47,45 @@ module Slack500
47
47
  return
48
48
  end
49
49
 
50
- text = "\n\n:black_small_square:*Request*\n*#{request.method}* #{request.url}\n\n:black_small_square:*User Agent*\n#{request.user_agent}\n\n:black_small_square:*IP*\n#{request.remote_ip}\n\n:black_small_square:*Query*\n#{request.query_parameters}\n\n:black_small_square:*Message*\n#{exception.message}\n\n:black_small_square:*Backtrace*\n#{exception.backtrace.map {|s| "`#{s.gsub('`','').gsub("'",'').gsub(Rails.root.to_s, '')}`"}.join("\n")}"
50
+ bullet = ':black_small_square:'
51
+ text = "#{exception.message}\n\n"
51
52
 
53
+ text += "#{bullet}*Request*\n*#{request.method}* #{request.url}\n\n"
54
+ text += "#{bullet}*User Agent*\n#{request.user_agent}\n\n"
55
+ text += "#{bullet}*IP*\n#{request.remote_ip}\n\n"
56
+ text += "#{bullet}*Query*\n#{request.query_parameters}\n\n" unless request.query_parameters.empty?
57
+
58
+ request.body.rewind
59
+ body_text = request.body.read
60
+
61
+ begin
62
+ if body_text.present?
63
+ body = JSON.parse(body_text)
64
+ end
65
+ rescue => e
66
+ if body_text.present?
67
+ body_params = {}
68
+ body_text.split('&').each do |param|
69
+ kv = param.split("=")
70
+ if kv.length == 2
71
+ if kv[0].downcase.index('token').present? || kv[0].downcase.index('password').present?
72
+ body_params[URI.decode(kv[0])] = '[** FILTERED **]'
73
+ elsif kv[0] != 'utf8'
74
+ body_params[URI.decode(kv[0])] = truncate(URI.decode(kv[1]).force_encoding('UTF-8'),100)
75
+ end
76
+ end
77
+ end
78
+ if body_params.empty?
79
+ body = body_text
80
+ else
81
+ body = body_params
82
+ end
83
+ end
84
+ end
85
+
86
+ text += "#{bullet}*Body*\n#{body}\n\n" unless body.nil?
87
+ text += "#{bullet}:*Backtrace*\n#{exception.backtrace.map {|s| "`#{s.gsub('`', '').gsub("'", '').gsub(Rails.root.to_s, '')}`"}.join("\n")}"
88
+ text = text.force_encoding('UTF-8')
52
89
  default_params = {
53
90
  pretext: self.pretext,
54
91
  title: self.title,
@@ -76,4 +113,10 @@ module Slack500
76
113
  Rails.logger.error "** Slack500:: #{e.full_message}."
77
114
  end
78
115
  end
116
+
117
+ private
118
+ def self.truncate(string, max)
119
+ string.length > max ? "#{string[0...max]}..." : string
120
+ end
121
+
79
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_500
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuo Matsunaga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-26 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler