logstop 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +12 -0
- data/lib/logstop.rb +4 -3
- data/lib/logstop/railtie.rb +11 -0
- data/lib/logstop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1045e35e2d837c1e66abd3916e08357b9cf98bfe4b37e5d0c4b8427901c6bb4
|
4
|
+
data.tar.gz: 61aecefd1d8b68f4bb48f1819eb9c0aea22b3440a4ebc9958ec2877c2be00d1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 610269d02743729383a41c45832f8849988928d998969569dc5013b9dbffde9428a914ec9411a96c883a7ca31aa2866d6534d1a6ef75b038fbb81e064a2fe12e
|
7
|
+
data.tar.gz: 60eacadc8d8027cc88b88558d05e216dad0f053f1f83c5c0198f934f888f15c01f34335925b13b5b4a0e1714ef8a82c0bb38c3b6bf3021aaadf50d932524a3b6
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,16 @@ And add it to your logger:
|
|
37
37
|
logger.formatter = Logstop::Formatter.new(logger.formatter)
|
38
38
|
```
|
39
39
|
|
40
|
+
### Rails
|
41
|
+
|
42
|
+
Create `config/initializers/logstop.rb` with:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Rails.logger.formatter = Logstop::Formatter.new(Rails.logger.formatter)
|
46
|
+
```
|
47
|
+
|
48
|
+
**Note:** In the Rails console with the default logger, logs show up unfiltered in STDOUT, but filtered in the log file. This is fixed on master.
|
49
|
+
|
40
50
|
## Options
|
41
51
|
|
42
52
|
To scrub IP addresses, use:
|
@@ -57,6 +67,8 @@ This should be used in addition to `config.filtered_parameters`, not as a replac
|
|
57
67
|
|
58
68
|
To scrub existing log files, check out [scrubadub](https://github.com/datascopeanalytics/scrubadub).
|
59
69
|
|
70
|
+
To anonymize IP addresses, check out [IP Anonymizer](https://github.com/ankane/ip_anonymizer).
|
71
|
+
|
60
72
|
## Resources
|
61
73
|
|
62
74
|
- [List of PII, as defined by NIST](https://en.wikipedia.org/wiki/Personally_identifiable_information#NIST_definition)
|
data/lib/logstop.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "logstop/formatter"
|
2
|
+
require "logstop/railtie" if defined?(Rails)
|
2
3
|
require "logstop/version"
|
3
4
|
|
4
5
|
module Logstop
|
@@ -8,8 +9,8 @@ module Logstop
|
|
8
9
|
CREDIT_CARD_REGEX = /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/
|
9
10
|
EMAIL_REGEX = /\b[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\b/i
|
10
11
|
IP_REGEX = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
|
11
|
-
PHONE_REGEX = /\b(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}\b/
|
12
|
-
SSN_REGEX = /\b\d{3}[\s-]\d{2}[\s-]\d{4}\b/
|
12
|
+
PHONE_REGEX = /\b(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}\b/
|
13
|
+
SSN_REGEX = /\b\d{3}[\s-]\d{2}[\s-]\d{4}\b/
|
13
14
|
URL_PASSWORD_REGEX = /(\/\/\S+:)\S+@/
|
14
15
|
|
15
16
|
def self.scrub(msg, ip: false)
|
@@ -22,7 +23,7 @@ module Logstop
|
|
22
23
|
.gsub(CREDIT_CARD_REGEX, FILTERED_STR)
|
23
24
|
.gsub(PHONE_REGEX, FILTERED_STR)
|
24
25
|
.gsub(SSN_REGEX, FILTERED_STR)
|
25
|
-
.gsub(EMAIL_REGEX, FILTERED_STR)
|
26
26
|
.gsub(URL_PASSWORD_REGEX, FILTERED_URL_STR)
|
27
|
+
.gsub(EMAIL_REGEX, FILTERED_STR)
|
27
28
|
end
|
28
29
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Logstop
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
console do
|
4
|
+
# make broadcaster inherit formatter
|
5
|
+
if Rails.logger && Rails.logger.formatter.is_a?(Logstop::Formatter)
|
6
|
+
# yes, these are the same, but it works
|
7
|
+
Rails.logger.formatter = Rails.logger.formatter
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/logstop/version.rb
CHANGED
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- lib/logstop.rb
|
84
84
|
- lib/logstop/formatter.rb
|
85
|
+
- lib/logstop/railtie.rb
|
85
86
|
- lib/logstop/version.rb
|
86
87
|
- logstop.gemspec
|
87
88
|
homepage: https://github.com/ankane/logstop
|