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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 40acf54eb3ab7d88b666fdb100c1622f68194b69
4
- data.tar.gz: 0f32edf2c850262c7a389910a3b2f325b50630ff
2
+ SHA256:
3
+ metadata.gz: 388cbc24d5dae49059d56fdc1eb0151b88413642696510648be056498258e5b0
4
+ data.tar.gz: f0dab808379c2b143ca41b443ce5b07930e8f87e6d83caf4a369f81ea644590b
5
5
  SHA512:
6
- metadata.gz: d7949e50b20a7998073e72fc0066f5e1f238f5cd7af5ca248907c6b60a1d0c6eeade4639b0c4fbdc3fd798f4470eb04c160ff000380af7e9e1c39eeab2decee6
7
- data.tar.gz: 39c8bfc89301550d8bee600fa788605ccb28b1bc541cf7c034f5a834fae09486211d4352e8ce37e6ba7532f9c63a5a500382e182cb50733d18bee8d5176ea5ac
6
+ metadata.gz: 1f7774c7eec961cbda78bd0652dc640e283f32907375fb344ad5098bafba794f7539562d8fc6808cf2b101f340b706a6b55a2be83c7c25ca90fdc7372b6a7b2b
7
+ data.tar.gz: 54fbe03343496f1d8b87b115458bae361db725f66b2996ce32f4fd00f5b43a4784bbd631bb346523abf8caa6d1b7b4d5a4762b24ef8bdb3451b978a5a5e422a6
@@ -1,3 +1,7 @@
1
+ ## 0.2.2
2
+
3
+ - Added `mask_ips` option
4
+
1
5
  ## 0.2.1
2
6
 
3
7
  - Added support for Rails 5.1
data/README.md CHANGED
@@ -118,6 +118,12 @@ Skip tracking CSRF failures
118
118
  skip_before_action :track_unverified_request
119
119
  ```
120
120
 
121
+ Anonymize IP addresses
122
+
123
+ ```ruby
124
+ Notable.mask_ips = true
125
+ ```
126
+
121
127
  ### Jobs
122
128
 
123
129
  Set slow threshold
@@ -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
@@ -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: request.remote_ip,
60
+ ip: ip,
56
61
  user_agent: request.user_agent,
57
62
  url: url,
58
63
  referrer: request.referer,
@@ -1,3 +1,3 @@
1
1
  module Notable
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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: 2017-05-01 00:00:00.000000000 Z
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.11
119
+ rubygems_version: 2.7.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Track notable requests and background jobs