logstop 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -2
- data/lib/logstop/formatter.rb +3 -1
- data/lib/logstop/version.rb +1 -1
- data/lib/logstop.rb +8 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53f7c35dc4fa281960cb1d890c9bfc2f884b2624ecd9939946d000b5cedac7f
|
4
|
+
data.tar.gz: 2efd9b35e4d069224e8093d54c78101e40265191b8d588a6ac79694e41638da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee9bd48289258b6678492aa84da9777c8ee579416736dddf91b86f5cb57bdd0db64ba7402e1b83b4d4992437f87be467714ba1d397a5e4a7e656bf1746b731b
|
7
|
+
data.tar.gz: cf5c437b6bdb8819b9a717f307b53cdf0225ae86df78c270c919993deb36afd3493dc2b9734508a99eebafd28797ac5c3abfd7c08e979384f3d3559c00206ce6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Logstop
|
2
2
|
|
3
|
-
:fire: Keep
|
3
|
+
:fire: Keep personal data out of your logs
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
logger.info "Hi test@example.org!"
|
@@ -30,7 +30,7 @@ Works even when sensitive data is URL-encoded with plus encoding
|
|
30
30
|
Add this line to your application’s Gemfile:
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
gem
|
33
|
+
gem "logstop"
|
34
34
|
```
|
35
35
|
|
36
36
|
And add it to your logger:
|
@@ -55,6 +55,12 @@ To scrub IP addresses (IPv4), use:
|
|
55
55
|
Logstop.guard(logger, ip: true)
|
56
56
|
```
|
57
57
|
|
58
|
+
To scrub MAC addresses, use: [unreleased]
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
Logstop.guard(logger, mac: true)
|
62
|
+
```
|
63
|
+
|
58
64
|
Add custom rules with:
|
59
65
|
|
60
66
|
```ruby
|
data/lib/logstop/formatter.rb
CHANGED
@@ -2,7 +2,7 @@ require "logger"
|
|
2
2
|
|
3
3
|
module Logstop
|
4
4
|
class Formatter < ::Logger::Formatter
|
5
|
-
def initialize(formatter = nil, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
|
5
|
+
def initialize(formatter = nil, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, mac: false, scrubber: nil)
|
6
6
|
@formatter = formatter || ::Logger::Formatter.new
|
7
7
|
@url_password = url_password
|
8
8
|
@email = email
|
@@ -10,6 +10,7 @@ module Logstop
|
|
10
10
|
@phone = phone
|
11
11
|
@ssn = ssn
|
12
12
|
@ip = ip
|
13
|
+
@mac = mac
|
13
14
|
@scrubber = scrubber
|
14
15
|
end
|
15
16
|
|
@@ -22,6 +23,7 @@ module Logstop
|
|
22
23
|
phone: @phone,
|
23
24
|
ssn: @ssn,
|
24
25
|
ip: @ip,
|
26
|
+
mac: @mac,
|
25
27
|
scrubber: @scrubber
|
26
28
|
)
|
27
29
|
end
|
data/lib/logstop/version.rb
CHANGED
data/lib/logstop.rb
CHANGED
@@ -11,10 +11,12 @@ module Logstop
|
|
11
11
|
EMAIL_REGEX = /\b[\w]([\w+.-]|%2B)+(?:@|%40)[a-z\d-]+(?:\.[a-z\d-]+)*\.[a-z]+\b/i
|
12
12
|
IP_REGEX = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
|
13
13
|
PHONE_REGEX = /\b(?:\+\d{1,2}\s)?\(?\d{3}\)?[\s+.-]\d{3}[\s+.-]\d{4}\b/
|
14
|
+
E164_PHONE_REGEX = /(?:\+|%2B)[1-9]\d{6,14}\b/
|
14
15
|
SSN_REGEX = /\b\d{3}[\s+-]\d{2}[\s+-]\d{4}\b/
|
15
16
|
URL_PASSWORD_REGEX = /((?:\/\/|%2F%2F)\S+(?::|%3A))\S+(@|%40)/
|
17
|
+
MAC_REGEX = /\b[0-9a-f]{2}(?:(?::|%3A)[0-9a-f]{2}){5}\b/i
|
16
18
|
|
17
|
-
def self.scrub(msg, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
|
19
|
+
def self.scrub(msg, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, mac: false, scrubber: nil)
|
18
20
|
msg = msg.to_s.dup
|
19
21
|
|
20
22
|
# order filters are applied is important
|
@@ -24,9 +26,13 @@ module Logstop
|
|
24
26
|
msg.gsub!(CREDIT_CARD_REGEX, FILTERED_STR)
|
25
27
|
msg.gsub!(CREDIT_CARD_REGEX_DELIMITERS, FILTERED_STR)
|
26
28
|
end
|
27
|
-
|
29
|
+
if phone
|
30
|
+
msg.gsub!(E164_PHONE_REGEX, FILTERED_STR)
|
31
|
+
msg.gsub!(PHONE_REGEX, FILTERED_STR)
|
32
|
+
end
|
28
33
|
msg.gsub!(SSN_REGEX, FILTERED_STR) if ssn
|
29
34
|
msg.gsub!(IP_REGEX, FILTERED_STR) if ip
|
35
|
+
msg.gsub!(MAC_REGEX, FILTERED_STR) if mac
|
30
36
|
|
31
37
|
msg = scrubber.call(msg) if scrubber
|
32
38
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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: 2022-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|
@@ -35,15 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: '2.
|
38
|
+
version: '2.7'
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
45
|
+
rubygems_version: 3.3.7
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
|
-
summary: Keep
|
48
|
+
summary: Keep personal data out of your logs
|
49
49
|
test_files: []
|