logstop 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +14 -2
- data/lib/logstop/formatter.rb +16 -2
- data/lib/logstop/version.rb +1 -1
- data/lib/logstop.rb +9 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 270d72c3e5f7b204ba2cacce902adf8593dc6d5cab26d4470182aa41b14f3b5b
|
4
|
+
data.tar.gz: 8d5608be8b5b507e8cd640ee0303731b0608a25affed828a0ece5e3b13424afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4fc28afee3a1c604bf1af432ef8563bebba765f2e1f47dd44c6d6c0b335b3be28698432b8a1ff57eb707e27f396a841f67efb7adba46cc028d9388421db4eef
|
7
|
+
data.tar.gz: 30b74692def2afe3ab7a48cc4235eafbc79660aa98ad3adf4e73ce7adf0c82873b62f42ffc196610e2f61f3acbf5c0bc03aed3c7bb428fd51744db8e2b6a33db
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Works with all types of logging - Ruby, Active Record, Active Job, and more
|
|
21
21
|
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? [["email", "[FILTERED]"]]
|
22
22
|
```
|
23
23
|
|
24
|
-
Works even when sensitive data is URL-encoded
|
24
|
+
Works even when sensitive data is URL-encoded with plus encoding
|
25
25
|
|
26
26
|
[![Build Status](https://github.com/ankane/logstop/workflows/build/badge.svg?branch=master)](https://github.com/ankane/logstop/actions)
|
27
27
|
|
@@ -49,7 +49,7 @@ Logstop.guard(Rails.logger)
|
|
49
49
|
|
50
50
|
## Options
|
51
51
|
|
52
|
-
To scrub IP addresses, use:
|
52
|
+
To scrub IP addresses (IPv4), use:
|
53
53
|
|
54
54
|
```ruby
|
55
55
|
Logstop.guard(logger, ip: true)
|
@@ -65,6 +65,18 @@ end
|
|
65
65
|
Logstop.guard(logger, scrubber: scrubber)
|
66
66
|
```
|
67
67
|
|
68
|
+
Disable default rules with:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
Logstop.guard(logger,
|
72
|
+
email: false,
|
73
|
+
phone: false,
|
74
|
+
credit_card: false,
|
75
|
+
ssn: false,
|
76
|
+
url_password: false
|
77
|
+
)
|
78
|
+
```
|
79
|
+
|
68
80
|
To scrub outside of logging, use:
|
69
81
|
|
70
82
|
```ruby
|
data/lib/logstop/formatter.rb
CHANGED
@@ -2,14 +2,28 @@ require "logger"
|
|
2
2
|
|
3
3
|
module Logstop
|
4
4
|
class Formatter < ::Logger::Formatter
|
5
|
-
def initialize(formatter = nil, ip: false, scrubber: nil)
|
5
|
+
def initialize(formatter = nil, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
|
6
6
|
@formatter = formatter || ::Logger::Formatter.new
|
7
|
+
@url_password = url_password
|
8
|
+
@email = email
|
9
|
+
@credit_card = credit_card
|
10
|
+
@phone = phone
|
11
|
+
@ssn = ssn
|
7
12
|
@ip = ip
|
8
13
|
@scrubber = scrubber
|
9
14
|
end
|
10
15
|
|
11
16
|
def call(severity, timestamp, progname, msg)
|
12
|
-
Logstop.scrub(
|
17
|
+
Logstop.scrub(
|
18
|
+
@formatter.call(severity, timestamp, progname, msg),
|
19
|
+
url_password: @url_password,
|
20
|
+
email: @email,
|
21
|
+
credit_card: @credit_card,
|
22
|
+
phone: @phone,
|
23
|
+
ssn: @ssn,
|
24
|
+
ip: @ip,
|
25
|
+
scrubber: @scrubber
|
26
|
+
)
|
13
27
|
end
|
14
28
|
|
15
29
|
# for tagged logging
|
data/lib/logstop/version.rb
CHANGED
data/lib/logstop.rb
CHANGED
@@ -14,17 +14,18 @@ module Logstop
|
|
14
14
|
SSN_REGEX = /\b\d{3}[\s+-]\d{2}[\s+-]\d{4}\b/
|
15
15
|
URL_PASSWORD_REGEX = /((?:\/\/|%2F%2F)\S+(?::|%3A))\S+(@|%40)/
|
16
16
|
|
17
|
-
def self.scrub(msg, ip: false, scrubber: nil)
|
17
|
+
def self.scrub(msg, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
|
18
18
|
msg = msg.to_s.dup
|
19
19
|
|
20
20
|
# order filters are applied is important
|
21
|
-
msg.gsub!(URL_PASSWORD_REGEX, FILTERED_URL_STR)
|
22
|
-
msg.gsub!(EMAIL_REGEX, FILTERED_STR)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
msg.gsub!(URL_PASSWORD_REGEX, FILTERED_URL_STR) if url_password
|
22
|
+
msg.gsub!(EMAIL_REGEX, FILTERED_STR) if email
|
23
|
+
if credit_card
|
24
|
+
msg.gsub!(CREDIT_CARD_REGEX, FILTERED_STR)
|
25
|
+
msg.gsub!(CREDIT_CARD_REGEX_DELIMITERS, FILTERED_STR)
|
26
|
+
end
|
27
|
+
msg.gsub!(PHONE_REGEX, FILTERED_STR) if phone
|
28
|
+
msg.gsub!(SSN_REGEX, FILTERED_STR) if ssn
|
28
29
|
msg.gsub!(IP_REGEX, FILTERED_STR) if ip
|
29
30
|
|
30
31
|
msg = scrubber.call(msg) if scrubber
|
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.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.2.
|
45
|
+
rubygems_version: 3.2.32
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Keep personally identifiable information (PII) out of your logs
|