logstop 0.2.0 → 0.2.1

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
2
  SHA256:
3
- metadata.gz: 25fa65a53db09bbdaf79bc3328b362ba4916a6c053a6509d09c0954bad16630f
4
- data.tar.gz: 63a35fc75f233f0111c74283aa26e97cfe9e3788d29cb07a896fa87819dd923b
3
+ metadata.gz: d1045e35e2d837c1e66abd3916e08357b9cf98bfe4b37e5d0c4b8427901c6bb4
4
+ data.tar.gz: 61aecefd1d8b68f4bb48f1819eb9c0aea22b3440a4ebc9958ec2877c2be00d1a
5
5
  SHA512:
6
- metadata.gz: 124774d6a4f51314d3104712cb8096d4a16cdb1996bda58bd2de38d253ebb0811293e4513b010cb92ca275d13f73471e1ba0542b6f14b7b455fa7119870b399b
7
- data.tar.gz: da752afaef25ad882edbd5a8ea081c04470d11783ed6e4023498c63dc1308fb59164f79b766e39d690bf92dd7ceb5a2e83426ec22b7d417065cb53fc89a10ef6
6
+ metadata.gz: 610269d02743729383a41c45832f8849988928d998969569dc5013b9dbffde9428a914ec9411a96c883a7ca31aa2866d6534d1a6ef75b038fbb81e064a2fe12e
7
+ data.tar.gz: 60eacadc8d8027cc88b88558d05e216dad0f053f1f83c5c0198f934f888f15c01f34335925b13b5b4a0e1714ef8a82c0bb38c3b6bf3021aaadf50d932524a3b6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.1
2
+
3
+ - Fix for log broadcaster in Rails console
4
+ - Fix for url password filtering
5
+
1
6
  ## 0.2.0
2
7
 
3
8
  - Less aggressive filtering on numbers
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Andrew
3
+ Copyright (c) 2018 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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/i
12
- SSN_REGEX = /\b\d{3}[\s-]\d{2}[\s-]\d{4}\b/i
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
@@ -1,3 +1,3 @@
1
1
  module Logstop
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-04-03 00:00:00.000000000 Z
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