ssn_obfuscater 1.01 → 1.02

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: 57f06f92e73816fa8abebae13030b93480e8f494ddcd95deecac83b463a7c357
4
- data.tar.gz: da2f658ad64f72daaeec93578f50348dbbdc65bc85deaaaa16fa3d1e635d4032
3
+ metadata.gz: 1d08a2ff3622fd25c1bc248a3987457cb1a5792a09252f45b90ceac18f37bb35
4
+ data.tar.gz: d7f14c6f60290c2bf18e5b33123754be1ea067309a5e371a46ddc282f927a1c4
5
5
  SHA512:
6
- metadata.gz: 7ed49672f2d5d60fbe77109d44908809464dbf9760debd23892e4316cb3ba8b4eb24581bccc8bfd1e9afc1dfb3ef581483f68701433f0a12f7bf972d184052e7
7
- data.tar.gz: a64e4c229a938eed5fb13d60ae63f7d22aa09013a78326165b619af8c302ef7fed21bc2b5b04a5eda963b6f1915baeb644d359e18fba32c5fac610af84ff8860
6
+ metadata.gz: 9deb0825185c8543f583767ae461a1f307063ee131371f3920f9f1bccc44ff38577113053ba83b314b93627059d29431a77a800b3418332d2b771231fd21dc6d
7
+ data.tar.gz: c3719b538afe83863844ab2c0e4fd92de57a60766178212c206a4fbacff2b1fbbadee1f4d73cb3f59b65a6cd7ad915fcb493e2bf9b49c0c7882606db4b2364b8
data/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  #### Protects client data by detecting and obfuscating social security numbers (ssn).
7
7
 
8
- Note: Currently being moved from local environment to this gem. Will be completed by 7/10/18
9
8
 
10
9
  ## Installation
11
10
 
@@ -25,7 +24,32 @@ Or install it yourself as:
25
24
 
26
25
  ## Usage
27
26
 
28
- Note: Currently being moved from local environment to this gem. Will be completed by 7/10/18
27
+ 1) Add your text to a hash with `:text` symbol key, then pass the arguments to `SsnObfuscater.parse(args)` like the example below. If you don't pass any args, and just run `SsnObfuscater.parse` it will return sample data for testing.
28
+
29
+ ***Note: Social Security Numbers beginning with 000 are not genuine, so this example does not include a real social security number. It is all fake data generated for testing purposes only.***
30
+
31
+ ```
32
+ text = "Dillan Richmond Gorczany, 8/16/1954, 000-12-3456, richmond.gorczany.dillan@jacobs.io, 405.226.5344, 2012 Erling Pass, Eagle Square, East Dwight, PA, 25733, Dynamic Manufacturing, VP of Tech"
33
+
34
+ result_hash = SsnObfuscater.parse(text: text)
35
+ ```
36
+
37
+
38
+ 2) The returned data will be in hash format like below:
39
+
40
+ Note the text below is a sample profile of an employee including phone, mailing address, email, DOB, SSN, IP address, and job position. Imagine this were a much longer text document where the SSN is more difficult to spot with the naked eye. SsnObfuscater can detect the SSN and render a safe obfuscated version of the text.
41
+
42
+ You can access the data, like so: `result_hash[:ssn_obf]` and `result_hash[:safe_text]`
43
+
44
+ ```
45
+ {:ssn_alert=>true,
46
+ :ssn=>"000-12-3456",
47
+ :ssn_obf=>"XXX-XX-3456",
48
+ :safe_text=>
49
+ "Dillan Richmond Gorczany, 8/16/1954, XXX-XX-3456, richmond.gorczany.dillan@jacobs.io, 405.226.5344, 2012 Erling Pass, Eagle Square, East Dwight, PA, 25733, Dynamic Manufacturing, VP of Tech"
50
+ }
51
+ ```
52
+
29
53
 
30
54
  ## Development
31
55
 
data/Rakefile CHANGED
@@ -18,22 +18,15 @@ task :console do
18
18
  require "active_support/all"
19
19
  ARGV.clear
20
20
 
21
- scraped_links = run_sudoku
22
- # binding.pry
21
+ result_hash = run_ssn
23
22
 
24
23
  IRB.start
25
24
  end
26
25
 
27
26
 
28
- def run_sudoku
29
- binding.pry
30
- solve = SsnObfuscater::Solver.new
31
- res = solve.start
32
- binding.pry
33
-
34
- # scraper = LinkScraper::Scrape.new({text_criteria: text_criteria, path_criteria: path_criteria})
35
- # scraped_links = scraper.start('https://en.wikipedia.org/wiki/Austin%2C_Texas')
36
- # binding.pry
27
+ def run_ssn
28
+ text = "Dillan Richmond Gorczany, 8/16/1954, 000-12-3456, richmond.gorczany.dillan@jacobs.io, 405.226.5344, 2012 Erling Pass, Eagle Square, East Dwight, PA, 25733, Dynamic Manufacturing, VP of Tech"
37
29
 
30
+ result_hash = SsnObfuscater.parse(text: text)
38
31
  # scraper = LinkScraper::Scrape.new(WebsCriteria.all_scrub_web_criteria)
39
32
  end
@@ -2,9 +2,13 @@ require "ssn_obfuscater/version"
2
2
 
3
3
  require "ssn_obfuscater/solver"
4
4
  # require 'mechanizer'
5
- # require 'scrub_db'
5
+ require 'faker'
6
6
  require 'pry'
7
7
 
8
8
  module SsnObfuscater
9
- # Your code goes here...
9
+
10
+ def self.parse(args={})
11
+ result_hash = self::Solver.new.parse(args)
12
+ end
13
+
10
14
  end
@@ -2,16 +2,75 @@
2
2
  module SsnObfuscater
3
3
  class Solver
4
4
 
5
- def initialize
6
- binding.pry
5
+ # AlgoService.new.parse
6
+ def parse(args={})
7
+ text = args.fetch(:text, nil)
8
+ text = generate_ssn_num_strings if !text.present?
9
+ result_hash = find_ssn_in_string(text)
10
+ result_hash.is_a?(::Hash) ? result_hash : nil
11
+ # safe_string_block = make_string_block_safe(result_hash, text)
12
+ result_hash
7
13
  end
8
14
 
9
- def start
10
- binding.pry
11
- "testing setup"
15
+
16
+ def parse_string_block(text)
17
+ strings = text.split(/\.\s+|!|\?/)
18
+ strings = strings.map { |str| str.squeeze(' ') }
19
+ strings = strings.map(&:strip)
20
+ end
21
+
22
+
23
+ def find_ssn_in_string(string)
24
+ if string.present?
25
+ ssn = string.scan(/\d{3}-\d{2}-\d{4}/).join(', ')
26
+ if ssn.present?
27
+ ssn_obf = obfuscate_ssn(ssn)
28
+ string.gsub!(ssn, ssn_obf)
29
+ result_hash = { ssn_alert: ssn.present?, ssn: ssn, ssn_obf: ssn_obf, safe_text: string }
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+ def make_string_block_safe(result_hashes, text)
36
+ result_hashes.map do |hsh|
37
+ ssn = hsh[:ssn]
38
+ text.gsub!(ssn, hsh[:ssn_obf])
39
+ end
40
+ text
41
+ end
42
+
43
+
44
+ # Obfuscate all Social Security Numbers. Example: XXX-XX-4430.
45
+ def obfuscate_ssn(ssn)
46
+ ssn_obf = "XXX-XX-#{ssn[-4..-1]}"
12
47
  end
13
48
 
14
49
 
50
+ # SsnTool.generate_ssn_num_strings(5)
51
+ def generate_ssn_num_strings(string_quantity)
52
+ # fk_address = Faker::Address
53
+ # fk_job = Faker::Job
54
+ # fk_name = Faker::Name
55
+ # fk_internet = Faker::Internet
56
+ # fk_phone = Faker::PhoneNumber
57
+ #
58
+ # fake_profile_strings = (0..string_quantity).map do
59
+ # fk_name.name_with_middle
60
+ # full_name = fk_name.name_with_middle
61
+ # email_address = fk_internet.email(full_name)
62
+ # sample_ssn = "#{rand(329...889)}-#{rand(29...89)}-#{rand(2109...8989)}"
63
+ # sample_dob = "#{rand(1...12)}/#{rand(1...28)}/#{rand(1950...2010)}"
64
+ # address_meth_names = %w(street_address community city state_abbr zip)
65
+ # full_address = address_meth_names.map { |part| fk_address.module_eval(part) }.join(', ')
66
+ # job_meth_names = %w(field seniority position key_skill employment_type education_level)
67
+ # job_details = job_meth_names.map { |part| fk_job.module_eval(part) }.join(', ')
68
+ # string = [full_name, sample_dob, sample_ssn, email_address, fk_phone.cell_phone, full_address, job_details].join(', ')
69
+ # end
70
+ # string = fake_profile_strings.join(', ')
71
+
72
+ "Dillan Richmond Gorczany, 8/16/1954, 000-12-3456, richmond.gorczany.dillan@jacobs.io, 405.226.5344, 2012 Erling Pass, Eagle Square, East Dwight, PA, 25733, Dynamic Manufacturing, VP of Tech"
73
+ end
15
74
 
16
75
  end
17
76
  end
@@ -1,3 +1,3 @@
1
1
  module SsnObfuscater
2
- VERSION = "1.01"
2
+ VERSION = "1.02"
3
3
  end
@@ -32,11 +32,11 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.required_ruby_version = '~> 2.5.1'
34
34
  spec.add_dependency 'activesupport', '~> 5.2'
35
- spec.add_dependency 'crm_formatter', '~> 2.64'
35
+ spec.add_dependency 'crm_formatter', '~> 2.65'
36
36
  spec.add_dependency 'mechanizer', '~> 1.12'
37
37
  spec.add_dependency 'scrub_db', '~> 2.23'
38
38
  spec.add_dependency 'url_verifier', '~> 2.12'
39
- spec.add_dependency 'utf8_sanitizer', '~> 2.16'
39
+ # spec.add_dependency 'faker', '~> 1.8', '>= 1.8.7'
40
40
 
41
41
  # spec.add_dependency "activesupport-inflector", ['~> 0.1.0']
42
42
  spec.add_development_dependency 'bundler', '~> 1.16', '>= 1.16.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssn_obfuscater
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.01'
4
+ version: '1.02'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Booth
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.64'
33
+ version: '2.65'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.64'
40
+ version: '2.65'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mechanizer
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.12'
83
- - !ruby/object:Gem::Dependency
84
- name: utf8_sanitizer
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.16'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.16'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundler
99
85
  requirement: !ruby/object:Gem::Requirement