notable 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/notable.rb +13 -0
- data/lib/notable/middleware.rb +6 -1
- data/lib/notable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 388cbc24d5dae49059d56fdc1eb0151b88413642696510648be056498258e5b0
|
4
|
+
data.tar.gz: f0dab808379c2b143ca41b443ce5b07930e8f87e6d83caf4a369f81ea644590b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7774c7eec961cbda78bd0652dc640e283f32907375fb344ad5098bafba794f7539562d8fc6808cf2b101f340b706a6b55a2be83c7c25ca90fdc7372b6a7b2b
|
7
|
+
data.tar.gz: 54fbe03343496f1d8b87b115458bae361db725f66b2996ce32f4fd00f5b43a4784bbd631bb346523abf8caa6d1b7b4d5a4762b24ef8bdb3451b978a5a5e422a6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/notable.rb
CHANGED
@@ -25,6 +25,7 @@ module Notable
|
|
25
25
|
attr_accessor :track_request_method
|
26
26
|
attr_accessor :user_method
|
27
27
|
attr_accessor :slow_request_threshold
|
28
|
+
attr_accessor :mask_ips
|
28
29
|
|
29
30
|
# jobs
|
30
31
|
attr_accessor :track_job_method
|
@@ -33,6 +34,7 @@ module Notable
|
|
33
34
|
self.enabled = true
|
34
35
|
self.requests_enabled = true
|
35
36
|
self.jobs_enabled = true
|
37
|
+
self.mask_ips = false
|
36
38
|
|
37
39
|
def self.requests_enabled?
|
38
40
|
enabled && requests_enabled
|
@@ -103,6 +105,17 @@ module Notable
|
|
103
105
|
|
104
106
|
raise exception if exception
|
105
107
|
end
|
108
|
+
|
109
|
+
def self.mask_ip(ip)
|
110
|
+
addr = IPAddr.new(ip)
|
111
|
+
if addr.ipv4?
|
112
|
+
# set last octet to 0
|
113
|
+
addr.mask(24).to_s
|
114
|
+
else
|
115
|
+
# set last 80 bits to zeros
|
116
|
+
addr.mask(48).to_s
|
117
|
+
end
|
118
|
+
end
|
106
119
|
end
|
107
120
|
|
108
121
|
ActiveSupport.on_load(:active_job) do
|
data/lib/notable/middleware.rb
CHANGED
@@ -44,6 +44,11 @@ module Notable
|
|
44
44
|
user = Notable.user_method.call(env)
|
45
45
|
|
46
46
|
notes.each do |note|
|
47
|
+
ip = request.remote_ip
|
48
|
+
if ip && Notable.mask_ips
|
49
|
+
ip = Notable.mask_ip(ip)
|
50
|
+
end
|
51
|
+
|
47
52
|
data = {
|
48
53
|
note_type: note[:note_type],
|
49
54
|
note: note[:note],
|
@@ -52,7 +57,7 @@ module Notable
|
|
52
57
|
status: status,
|
53
58
|
params: params,
|
54
59
|
request_id: request.uuid,
|
55
|
-
ip:
|
60
|
+
ip: ip,
|
56
61
|
user_agent: request.user_agent,
|
57
62
|
url: url,
|
58
63
|
referrer: request.referer,
|
data/lib/notable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: request_store
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.6
|
119
|
+
rubygems_version: 2.7.6
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Track notable requests and background jobs
|