sensitive_data_filter 0.2.1 → 0.2.2
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 +6 -0
- data/lib/sensitive_data_filter/types/credit_card.rb +6 -17
- data/lib/sensitive_data_filter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e62db2ae324d2f014758fa93278724c2ecc203
|
4
|
+
data.tar.gz: de772fa896eaeb9c8537fb6ccf7bc0a153917712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e177c853cbeb02023a3d4086161aec4acf3059656fe02a9187bb224abbaae3f637aa8bc31c66eb624cd848e3f8fb35c4658d14ef5240101ea65a134215b05e0c
|
7
|
+
data.tar.gz: 4f61f54a8e31fc36deb96317de80c2e2780558cfb593ea22eda231e761c002c01f1a8989b51d31899b7f926ca82b35e8bbee438c3a512fb3fcb13a18540eaa71
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
5
|
|
6
|
+
## [0.2.2] - 2016-12-21
|
7
|
+
### Fixed
|
8
|
+
- Implements stricter credit cards pattern matching
|
9
|
+
- Matches unconventionally formatted credit cards
|
10
|
+
- Scans every sub string for credit cards
|
11
|
+
|
6
12
|
## [0.2.1] - 2016-12-19
|
7
13
|
### Changed
|
8
14
|
- Updates README for usage with Rails
|
@@ -4,31 +4,20 @@ require 'credit_card_validations'
|
|
4
4
|
module SensitiveDataFilter
|
5
5
|
module Types
|
6
6
|
module CreditCard
|
7
|
-
SEPARATORS
|
8
|
-
SEPRS
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
CARD_15_DIGITS = /\d{4} #{SEPRS} \d{6} #{SEPRS} \d{5}/
|
13
|
-
CARD = /
|
14
|
-
(?<!\d)(?:
|
15
|
-
#{CARD_16_DIGITS.source}
|
16
|
-
| #{CARD_13_DIGITS.source}
|
17
|
-
| #{CARD_14_DIGITS.source}
|
18
|
-
| #{CARD_15_DIGITS.source}
|
19
|
-
)(?!\d)
|
20
|
-
/x
|
21
|
-
FILTERED = '[FILTERED]'
|
7
|
+
SEPARATORS = /[\s-]/
|
8
|
+
SEPRS = SEPARATORS.source + '*'
|
9
|
+
LENGTHS = (11..19)
|
10
|
+
CARD = Regexp.new(LENGTHS.map { |l| /(?=((?:\d#{SEPRS}){#{l - 1}}\d)?)/.source }.join)
|
11
|
+
FILTERED = '[FILTERED]'
|
22
12
|
|
23
13
|
module_function def valid?(number)
|
24
14
|
return false unless number.is_a? String
|
25
|
-
return false unless number.match CARD
|
26
15
|
CreditCardValidations::Detector.new(number.gsub(SEPARATORS, '')).brand.present?
|
27
16
|
end
|
28
17
|
|
29
18
|
module_function def scan(value)
|
30
19
|
return [] unless value.is_a? String
|
31
|
-
value.scan(CARD).select { |card| valid?(card) }
|
20
|
+
value.scan(CARD).flatten.compact.select { |card| valid?(card) }
|
32
21
|
end
|
33
22
|
|
34
23
|
module_function def mask(value)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensitive_data_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Berardi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-12-
|
12
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|