logstop 0.2.4 → 0.2.8

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: 5ac4acd49c15d9cc5eaaf632ab3550c3b5e148e4b4fd07c5a40375ba39ca86ff
4
- data.tar.gz: 9e3427aeb3921f9be61fbfb1d9e27f949ff1b9c9d4d023e01696397a34aeb06c
3
+ metadata.gz: 270d72c3e5f7b204ba2cacce902adf8593dc6d5cab26d4470182aa41b14f3b5b
4
+ data.tar.gz: 8d5608be8b5b507e8cd640ee0303731b0608a25affed828a0ece5e3b13424afe
5
5
  SHA512:
6
- metadata.gz: 5b9c8532cec3764daaaf4fb159db1df4c33961510984336e33f93fc3817fedd02f9082e384857e0c61b29b0f025679eee52b1d2911bca3f0b4e13f2322ffef48
7
- data.tar.gz: e6e84e9b97efba86d7b2f879522bae3289662e4fe637337b04b95d36d420e69735147185a64c6bfd305fd3368c758148fa0cdc87a06b50f613cbb8f2902f05d1
6
+ metadata.gz: c4fc28afee3a1c604bf1af432ef8563bebba765f2e1f47dd44c6d6c0b335b3be28698432b8a1ff57eb707e27f396a841f67efb7adba46cc028d9388421db4eef
7
+ data.tar.gz: 30b74692def2afe3ab7a48cc4235eafbc79660aa98ad3adf4e73ce7adf0c82873b62f42ffc196610e2f61f3acbf5c0bc03aed3c7bb428fd51744db8e2b6a33db
data/CHANGELOG.md CHANGED
@@ -1,27 +1,43 @@
1
- ## 0.2.4 [unreleased]
1
+ ## 0.2.8 (2021-11-30)
2
+
3
+ - Added support for disabling default rules
4
+
5
+ ## 0.2.7 (2021-02-08)
6
+
7
+ - Fixed filtering for URL-encoded emails with `+`
8
+
9
+ ## 0.2.6 (2020-04-10)
10
+
11
+ - Reduced allocations
12
+
13
+ ## 0.2.5 (2019-10-27)
14
+
15
+ - Fixed filtering UUIDs
16
+
17
+ ## 0.2.4 (2018-12-11)
2
18
 
3
19
  - Added `scubber` option for custom rules
4
20
  - Scrub URL-encoded data
5
21
 
6
- ## 0.2.3
22
+ ## 0.2.3 (2018-05-16)
7
23
 
8
24
  - Fixed tagged logging
9
25
 
10
- ## 0.2.2
26
+ ## 0.2.2 (2018-05-15)
11
27
 
12
28
  - Added `guard` method
13
29
 
14
- ## 0.2.1
30
+ ## 0.2.1 (2018-05-15)
15
31
 
16
32
  - Fix for log broadcaster in Rails console
17
33
  - Fix for URL password filtering
18
34
 
19
- ## 0.2.0
35
+ ## 0.2.0 (2018-04-03)
20
36
 
21
37
  - Less aggressive filtering on numbers
22
38
  - Filter passwords in URLs
23
39
  - Added `Logstop.scrub` method
24
40
 
25
- ## 0.1.0
41
+ ## 0.1.0 (2018-03-31)
26
42
 
27
43
  - First release
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Andrew Kane
3
+ Copyright (c) 2018-2021 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
@@ -15,15 +15,15 @@ By default, scrubs:
15
15
  - Social Security numbers (SSNs)
16
16
  - passwords in URLs
17
17
 
18
- Works with all types of logging - Ruby, ActiveRecord, ActiveJob, and more
18
+ Works with all types of logging - Ruby, Active Record, Active Job, and more
19
19
 
20
20
  ```
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
- [![Build Status](https://travis-ci.org/ankane/logstop.svg?branch=master)](https://travis-ci.org/ankane/logstop)
26
+ [![Build Status](https://github.com/ankane/logstop/workflows/build/badge.svg?branch=master)](https://github.com/ankane/logstop/actions)
27
27
 
28
28
  ## Installation
29
29
 
@@ -49,13 +49,13 @@ 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)
56
56
  ```
57
57
 
58
- Add custom rules with: [master]
58
+ Add custom rules with:
59
59
 
60
60
  ```ruby
61
61
  scrubber = lambda do |msg|
@@ -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
@@ -75,13 +87,15 @@ It supports the same options as `guard`.
75
87
 
76
88
  ## Notes
77
89
 
78
- This should be used in addition to `config.filtered_parameters`, not as a replacement.
90
+ This should be used in addition to `config.filter_parameters`, not as a replacement.
79
91
 
80
- To scrub existing log files, check out [scrubadub](https://github.com/datascopeanalytics/scrubadub).
92
+ Learn more about [securing sensitive data in Rails](https://ankane.org/sensitive-data-rails).
81
93
 
82
- To anonymize IP addresses, check out [IP Anonymizer](https://github.com/ankane/ip_anonymizer).
94
+ Also:
83
95
 
84
- Learn more about [securing sensitive data in Rails](https://ankane.org/sensitive-data-rails).
96
+ - To scrub existing log files, check out [scrubadub](https://github.com/datascopeanalytics/scrubadub)
97
+ - To anonymize IP addresses, check out [IP Anonymizer](https://github.com/ankane/ip_anonymizer)
98
+ - To scan for unencrypted personal data in your database, check out [pdscan](https://github.com/ankane/pdscan)
85
99
 
86
100
  ## Resources
87
101
 
@@ -100,11 +114,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
100
114
  - Write, clarify, or fix documentation
101
115
  - Suggest or add new features
102
116
 
103
- To get started with development and testing:
117
+ To get started with development:
104
118
 
105
119
  ```sh
106
120
  git clone https://github.com/ankane/logstop.git
107
121
  cd logstop
108
122
  bundle install
109
- rake test
123
+ bundle exec rake test
110
124
  ```
@@ -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(@formatter.call(severity, timestamp, progname, msg), ip: @ip, scrubber: @scrubber)
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
@@ -1,3 +1,3 @@
1
1
  module Logstop
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.8"
3
3
  end
data/lib/logstop.rb CHANGED
@@ -4,27 +4,29 @@ require "logstop/version"
4
4
 
5
5
  module Logstop
6
6
  FILTERED_STR = "[FILTERED]".freeze
7
- FILTERED_URL_STR = "\\1[FILTERED]@".freeze
7
+ FILTERED_URL_STR = "\\1[FILTERED]\\2".freeze
8
8
 
9
- CREDIT_CARD_REGEX = /\b\d{4}[\s+-]?\d{4}[\s+-]?\d{4}[\s+-]?\d{4}\b/
10
- EMAIL_REGEX = /\b[\w][\w+.-]+(@|%40)[a-z\d-]+(\.[a-z\d-]+)*\.[a-z]+\b/i
9
+ CREDIT_CARD_REGEX = /\b[3456]\d{15}\b/
10
+ CREDIT_CARD_REGEX_DELIMITERS = /\b[3456]\d{3}[\s+-]\d{4}[\s+-]\d{4}[\s+-]\d{4}\b/
11
+ EMAIL_REGEX = /\b[\w]([\w+.-]|%2B)+(?:@|%40)[a-z\d-]+(?:\.[a-z\d-]+)*\.[a-z]+\b/i
11
12
  IP_REGEX = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
12
- PHONE_REGEX = /\b(\+\d{1,2}\s)?\(?\d{3}\)?[\s+.-]\d{3}[\s+.-]\d{4}\b/
13
+ PHONE_REGEX = /\b(?:\+\d{1,2}\s)?\(?\d{3}\)?[\s+.-]\d{3}[\s+.-]\d{4}\b/
13
14
  SSN_REGEX = /\b\d{3}[\s+-]\d{2}[\s+-]\d{4}\b/
14
- URL_PASSWORD_REGEX = /((\/\/|%2F%2F)\S+(:|%3A))\S+(@|%40)/
15
+ URL_PASSWORD_REGEX = /((?:\/\/|%2F%2F)\S+(?::|%3A))\S+(@|%40)/
15
16
 
16
- def self.scrub(msg, ip: false, scrubber: nil)
17
- msg = msg.to_s
17
+ def self.scrub(msg, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
18
+ msg = msg.to_s.dup
18
19
 
19
20
  # order filters are applied is important
20
- msg = msg
21
- .gsub(URL_PASSWORD_REGEX, FILTERED_URL_STR)
22
- .gsub(EMAIL_REGEX, FILTERED_STR)
23
- .gsub(CREDIT_CARD_REGEX, FILTERED_STR)
24
- .gsub(PHONE_REGEX, FILTERED_STR)
25
- .gsub(SSN_REGEX, FILTERED_STR)
26
-
27
- msg = msg.gsub(IP_REGEX, FILTERED_STR) if ip
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
29
+ msg.gsub!(IP_REGEX, FILTERED_STR) if ip
28
30
 
29
31
  msg = scrubber.call(msg) if scrubber
30
32
 
metadata CHANGED
@@ -1,101 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: benchmark-ips
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: memory_profiler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: minitest
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- description:
98
- email: andrew@chartkick.com
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: andrew@ankane.org
99
15
  executables: []
100
16
  extensions: []
101
17
  extra_rdoc_files: []
@@ -111,7 +27,7 @@ homepage: https://github.com/ankane/logstop
111
27
  licenses:
112
28
  - MIT
113
29
  metadata: {}
114
- post_install_message:
30
+ post_install_message:
115
31
  rdoc_options: []
116
32
  require_paths:
117
33
  - lib
@@ -126,9 +42,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
42
  - !ruby/object:Gem::Version
127
43
  version: '0'
128
44
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.7.6
131
- signing_key:
45
+ rubygems_version: 3.2.32
46
+ signing_key:
132
47
  specification_version: 4
133
48
  summary: Keep personally identifiable information (PII) out of your logs
134
49
  test_files: []