credit_card_sanitizer 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/credit_card_sanitizer.rb +9 -2
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02f8c28ce67104a4f9a5940e8c6d75bab341b39f
|
4
|
+
data.tar.gz: 0a4b62db35f275a631ea1d693ef4670d4fa120b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39232c703a7dfcd173420a10fda77002a37d8a8d38d3cb1e0a1ce1d43e44972e43ec1487815f5cec5a0e16c8c92caedb423cbc8b03af48d73119d676bb901d81
|
7
|
+
data.tar.gz: 37b6f130aaf04e5cbc0def0563fdcfdf7214f062987e1d078ba0d447241b0f8f0045bdd340843ab575f35b000656c3de5435f933c63ffc4643e2e21db04de748
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'luhn_checksum'
|
4
4
|
require 'securerandom'
|
5
5
|
require 'scrub_rb'
|
6
|
+
require 'tracking_number'
|
6
7
|
|
7
8
|
class CreditCardSanitizer
|
8
9
|
|
@@ -49,7 +50,8 @@ class CreditCardSanitizer
|
|
49
50
|
replacement_token: '▇',
|
50
51
|
expose_first: 6,
|
51
52
|
expose_last: 4,
|
52
|
-
use_groupings: false
|
53
|
+
use_groupings: false,
|
54
|
+
exclude_tracking_numbers: false
|
53
55
|
}
|
54
56
|
|
55
57
|
attr_reader :settings
|
@@ -64,6 +66,7 @@ class CreditCardSanitizer
|
|
64
66
|
# :expose_first - the number of leading digits that will not be redacted.
|
65
67
|
# :expose_last - the number of ending digits that will not be redacted.
|
66
68
|
# :use_groupings - require card number groupings to match to redact.
|
69
|
+
# :exclude_tracking_numbers - do not redact valid shipping company tracking numbers.
|
67
70
|
#
|
68
71
|
def initialize(options = {})
|
69
72
|
@settings = DEFAULT_OPTIONS.merge(options)
|
@@ -161,8 +164,12 @@ class CreditCardSanitizer
|
|
161
164
|
end
|
162
165
|
end
|
163
166
|
|
167
|
+
def is_tracking?(candidate, options)
|
168
|
+
options[:exclude_tracking_numbers] && TrackingNumber.new(candidate.numbers).valid?
|
169
|
+
end
|
170
|
+
|
164
171
|
def valid_numbers?(candidate, options)
|
165
|
-
LuhnChecksum.valid?(candidate.numbers) && valid_prefix?(candidate.numbers) && valid_grouping?(candidate, options)
|
172
|
+
LuhnChecksum.valid?(candidate.numbers) && valid_prefix?(candidate.numbers) && valid_grouping?(candidate, options) && !is_tracking?(candidate, options)
|
166
173
|
end
|
167
174
|
|
168
175
|
def redact_numbers(candidate, options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Chapweske
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: appraisal
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: luhnacy
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: luhn_checksum
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +82,20 @@ dependencies:
|
|
68
82
|
- - "~>"
|
69
83
|
- !ruby/object:Gem::Version
|
70
84
|
version: '0.1'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: tracking_number
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.10.2
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.10.2
|
71
99
|
- !ruby/object:Gem::Dependency
|
72
100
|
name: scrub_rb
|
73
101
|
requirement: !ruby/object:Gem::Requirement
|