ip_anonymizer 0.1.1 → 0.3.0

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: 4cb80464583a7c13916477c6fa46fee62c33619face6e13daf75f174ab795db4
4
- data.tar.gz: e3b71d92e2f819f697f16bac77f5c07cfdf87b17d77770f71368ca6c32dae6ef
3
+ metadata.gz: 8fca3d0e40cc438ec8f6ed699b844f7d6e731f8b3604963afedd62a3aeb8d635
4
+ data.tar.gz: 90057058cce03ec1c9fa647891f699ed22cac1caa9b9af3f84aa664760c64294
5
5
  SHA512:
6
- metadata.gz: 7522dd1c6fe7c87b24c943964507177c1426ec0b4668b86f754b1f0b7e99afa05bfe4983ffcedc71cdaf990ded12d0b456f8e2b0446e6f77515d87ebc1aa20ff
7
- data.tar.gz: 5629b162d83e5d2af257660d1135062e70d63224c14ac781ed60bd9e9738b5716f0aece034d268a523535a4d3f373fdc921649b93443a178e501c17d54867ef1
6
+ metadata.gz: ef7802170105a8e1d56074b3463b898dc44e585feb9c9d0e10199fc7e22e1489e779be3a928321228762af92ff9c0513350f99b39ddb76af49ed9031ee27fca7
7
+ data.tar.gz: 4fb6532abee3a955048982759c822dca5c3408354965cbccc7d8b320197c17d2993c07d75221c2d55cda2dc0d5747218349f2f64b5c0dd3f530a9080ba1ac7d5
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
- ## 0.1.1
1
+ ## 0.3.0 (2024-06-24)
2
+
3
+ - Dropped support for Ruby < 3.1
4
+
5
+ ## 0.2.0 (2022-10-09)
6
+
7
+ - Dropped support for Ruby < 2.7
8
+
9
+ ## 0.1.1 (2018-05-11)
2
10
 
3
11
  - Better performance when IP not needed
4
12
 
5
- ## 0.1.0
13
+ ## 0.1.0 (2018-05-05)
6
14
 
7
15
  - 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-2024 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
@@ -6,14 +6,14 @@ Works with IPv4 and IPv6
6
6
 
7
7
  Designed to help with [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) compliance
8
8
 
9
- [![Build Status](https://travis-ci.org/ankane/ip_anonymizer.svg?branch=master)](https://travis-ci.org/ankane/ip_anonymizer)
9
+ [![Build Status](https://github.com/ankane/ip_anonymizer/workflows/build/badge.svg?branch=master)](https://github.com/ankane/ip_anonymizer/actions)
10
10
 
11
11
  ## Getting Started
12
12
 
13
13
  Add these lines to your application’s Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'ip_anonymizer'
16
+ gem "ip_anonymizer"
17
17
  ```
18
18
 
19
19
  There are two strategies for anonymizing IPs.
@@ -47,12 +47,12 @@ IpAnonymizer.hash_ip("2001:4860:4860:0:0:0:0:8844", key: "secret")
47
47
  # => "f6e4:a4fe:32dc:2f39:3e47:84cc:e85e:865c"
48
48
  ```
49
49
 
50
- An advantage of this approach is different IPs will have different hashes.
50
+ An advantage of this approach is different IPs will have different hashes (with the exception of collisions).
51
51
 
52
- Make sure the key is kept secret and at least 30 random characters. Otherwise, a rainbow table can be constructed. In Rails, you can generate a good key with:
52
+ Make sure the key is kept secret and at least 30 random characters. Otherwise, a rainbow table can be constructed. You can generate a good key with:
53
53
 
54
- ```sh
55
- rails secret
54
+ ```ruby
55
+ SecureRandom.hex(32)
56
56
  ```
57
57
 
58
58
  ## Rails
@@ -88,11 +88,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
88
88
  - Write, clarify, or fix documentation
89
89
  - Suggest or add new features
90
90
 
91
- To get started with development and testing:
91
+ To get started with development:
92
92
 
93
93
  ```sh
94
94
  git clone https://github.com/ankane/ip_anonymizer.git
95
95
  cd ip_anonymizer
96
96
  bundle install
97
- rake test
97
+ bundle exec rake test
98
98
  ```
@@ -1,3 +1,3 @@
1
1
  module IpAnonymizer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/ip_anonymizer.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # stdlib
1
2
  require "ipaddr"
2
3
  require "openssl"
3
4
 
4
- require "ip_anonymizer/hash_ip"
5
- require "ip_anonymizer/mask_ip"
6
- require "ip_anonymizer/version"
5
+ # modules
6
+ require_relative "ip_anonymizer/hash_ip"
7
+ require_relative "ip_anonymizer/mask_ip"
8
+ require_relative "ip_anonymizer/version"
7
9
 
8
10
  module IpAnonymizer
9
11
  def self.mask_ip(ip)
@@ -22,7 +24,7 @@ module IpAnonymizer
22
24
  key_len = addr.ipv4? ? 4 : 16
23
25
  family = addr.ipv4? ? Socket::AF_INET : Socket::AF_INET6
24
26
 
25
- keyed_hash = OpenSSL::PKCS5.pbkdf2_hmac(addr.to_s, key, iterations, key_len, "sha256")
26
- IPAddr.new(keyed_hash.bytes.inject {|a, b| (a << 8) + b }, family).to_s
27
+ keyed_hash = OpenSSL::KDF.pbkdf2_hmac(addr.to_s, salt: key, iterations: iterations, length: key_len, hash: "sha256")
28
+ IPAddr.new(keyed_hash.bytes.inject { |a, b| (a << 8) + b }, family).to_s
27
29
  end
28
30
  end
metadata CHANGED
@@ -1,86 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip_anonymizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-11 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: benchmark-ips
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: bundler
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: minitest
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: rake
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
- description:
70
- email:
71
- - andrew@chartkick.com
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: andrew@ankane.org
72
15
  executables: []
73
16
  extensions: []
74
17
  extra_rdoc_files: []
75
18
  files:
76
- - ".gitignore"
77
- - ".travis.yml"
78
19
  - CHANGELOG.md
79
- - Gemfile
80
20
  - LICENSE.txt
81
21
  - README.md
82
- - Rakefile
83
- - ip_anonymizer.gemspec
84
22
  - lib/ip_anonymizer.rb
85
23
  - lib/ip_anonymizer/hash_ip.rb
86
24
  - lib/ip_anonymizer/mask_ip.rb
@@ -89,7 +27,7 @@ homepage: https://github.com/ankane/ip_anonymizer
89
27
  licenses:
90
28
  - MIT
91
29
  metadata: {}
92
- post_install_message:
30
+ post_install_message:
93
31
  rdoc_options: []
94
32
  require_paths:
95
33
  - lib
@@ -97,16 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
35
  requirements:
98
36
  - - ">="
99
37
  - !ruby/object:Gem::Version
100
- version: 2.2.0
38
+ version: '3.1'
101
39
  required_rubygems_version: !ruby/object:Gem::Requirement
102
40
  requirements:
103
41
  - - ">="
104
42
  - !ruby/object:Gem::Version
105
43
  version: '0'
106
44
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.7.6
109
- signing_key:
45
+ rubygems_version: 3.5.11
46
+ signing_key:
110
47
  specification_version: 4
111
48
  summary: IP address anonymizer for Ruby and Rails
112
49
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm: 2.5.1
3
- gemfile:
4
- - Gemfile
5
- sudo: false
6
- before_install: gem install bundler
7
- script: bundle exec rake test
8
- notifications:
9
- email:
10
- on_success: never
11
- on_failure: change
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in ip_anonymizer.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
- require "benchmark/ips"
4
-
5
- Rake::TestTask.new(:test) do |t|
6
- t.libs << "test"
7
- t.libs << "lib"
8
- t.test_files = FileList["test/**/*_test.rb"]
9
- end
10
-
11
- task default: :test
12
-
13
- task :benchmark do
14
- require "ip_anonymizer"
15
- Benchmark.ips do |x|
16
- x.report("mask_ip") { IpAnonymizer.mask_ip("8.8.4.4") }
17
- x.report("hash_ip") { IpAnonymizer.hash_ip("8.8.4.4", key: "secret") }
18
- end
19
- end
@@ -1,29 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ip_anonymizer/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "ip_anonymizer"
8
- spec.version = IpAnonymizer::VERSION
9
- spec.authors = ["Andrew Kane"]
10
- spec.email = ["andrew@chartkick.com"]
11
-
12
- spec.summary = "IP address anonymizer for Ruby and Rails"
13
- spec.homepage = "https://github.com/ankane/ip_anonymizer"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
-
23
- spec.required_ruby_version = ">= 2.2.0"
24
-
25
- spec.add_development_dependency "benchmark-ips"
26
- spec.add_development_dependency "bundler"
27
- spec.add_development_dependency "minitest"
28
- spec.add_development_dependency "rake"
29
- end