sensitive_data_filter 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 0a727bd4717ff795773bc06f5c9095ac86fa6deb
4
- data.tar.gz: af91b7050220d8899957e9f1014710d4a0bbc374
3
+ metadata.gz: 56e62db2ae324d2f014758fa93278724c2ecc203
4
+ data.tar.gz: de772fa896eaeb9c8537fb6ccf7bc0a153917712
5
5
  SHA512:
6
- metadata.gz: 817f86816d181448c51edce12b6b43c4a341ed805e03523254c76cc7da8680af14fdfb7c3c5ef05b1ca0800337231af24c06699e6f1ebbf3070cf926eedf79d1
7
- data.tar.gz: e8863e690284d3e479069bf9e0730448bf437c234d8e6e0ceb79e4f12e464f631e5468d596d158b810c28a408177c2ffde72cbcccd4c0785f779c28600bfd9d6
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 = SEPARATORS.source + '*'
9
- CARD_16_DIGITS = /\d{4} #{SEPRS} \d{4} #{SEPRS} \d{4} #{SEPRS} \d{4}/
10
- CARD_13_DIGITS = /\d{3} #{SEPRS} \d{3} #{SEPRS} \d{3} #{SEPRS} \d #{SEPRS} \d{3}/
11
- CARD_14_DIGITS = /\d{4} #{SEPRS} \d{6} #{SEPRS} \d{4}/
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SensitiveDataFilter
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
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.1
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-19 00:00:00.000000000 Z
12
+ date: 2016-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack