effective_obfuscation 1.2.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/app/models/concerns/acts_as_obfuscated.rb +7 -6
- data/lib/effective_obfuscation.rb +13 -0
- data/lib/effective_obfuscation/version.rb +1 -1
- metadata +10 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c6e7de8d7952b1908c410cb22eac9d30fcde46d61cba65afa8261c684d6386e
|
4
|
+
data.tar.gz: 25556589bebd12bd7c1986ee5ce4d5e46afc359be6911e2b331252bebcb19315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33293e400fab0e47d49ec08d3b53e5b7a47029689ecc9a5dcfeb52876259424abad7abf99f4c8b9a715e999c69a969a502ac221b81f99159cb952a8bd7233332
|
7
|
+
data.tar.gz: 3d3815196f2a571b47e267bb8455b21fe775fb944d1226efa03419f131c6545802af3cf4c57e003abc8f7a091e1224f3b62737a9fdf6b5e9a649ad1e35889eed
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ This is a Rails 4 compatible version of obfuscate_id (https://github.com/namick/
|
|
33
33
|
Add to Gemfile:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
gem 'effective_obfuscation'
|
36
|
+
gem 'effective_obfuscation'
|
37
37
|
```
|
38
38
|
|
39
39
|
Run the bundle command to install it:
|
@@ -50,10 +50,10 @@ module ActsAsObfuscated
|
|
50
50
|
ransacker :id, :formatter => Proc.new { |original|
|
51
51
|
obfuscated_id = original.to_s.delete('^0-9').first(10)
|
52
52
|
obfuscated_id.length == 10 ? deobfuscate(original) : 0
|
53
|
-
}
|
53
|
+
} do |parent| parent.table[:id] end
|
54
54
|
end
|
55
55
|
|
56
|
-
extend FinderMethods if
|
56
|
+
extend FinderMethods if EffectiveObfuscation.extend_klass?
|
57
57
|
end
|
58
58
|
|
59
59
|
module ClassMethods
|
@@ -111,7 +111,7 @@ module ActsAsObfuscated
|
|
111
111
|
acts_as_obfuscated_opts[:max_id] ||= (self.unscoped.maximum(:id) rescue 2147483647)
|
112
112
|
end
|
113
113
|
|
114
|
-
if
|
114
|
+
if EffectiveObfuscation.extend_relation?
|
115
115
|
def relation
|
116
116
|
super.tap { |relation| relation.extend(FinderMethods) }
|
117
117
|
end
|
@@ -120,7 +120,9 @@ module ActsAsObfuscated
|
|
120
120
|
|
121
121
|
module FinderMethods
|
122
122
|
def find(*args)
|
123
|
-
|
123
|
+
if @_effective_obfuscation_reloading || (respond_to?(:klass) && klass.try(:instance_variable_get, :@_effective_obfuscation_reloading))
|
124
|
+
return find_by_id(args.first)
|
125
|
+
end
|
124
126
|
|
125
127
|
super(deobfuscate(args.first, false))
|
126
128
|
end
|
@@ -150,7 +152,7 @@ module ActsAsObfuscated
|
|
150
152
|
next unless (d = deobfuscator(left))
|
151
153
|
args.first[left] = d.call(right)
|
152
154
|
end
|
153
|
-
elsif args.first.
|
155
|
+
elsif args.first.kind_of?(String) == false
|
154
156
|
deobfuscate_arel!(args.first)
|
155
157
|
end
|
156
158
|
|
@@ -185,4 +187,3 @@ module ActsAsObfuscated
|
|
185
187
|
end
|
186
188
|
|
187
189
|
end
|
188
|
-
|
@@ -10,4 +10,17 @@ module EffectiveObfuscation
|
|
10
10
|
def self.show(id, spin)
|
11
11
|
::ScatterSwap.reverse_hash(id, spin).to_i
|
12
12
|
end
|
13
|
+
|
14
|
+
def self.extend_klass?
|
15
|
+
return false if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
|
16
|
+
return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.extend_relation?
|
21
|
+
return true if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
|
22
|
+
return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
13
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_obfuscation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,9 +38,8 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.3
|
41
|
-
description: Display unique 10-digit numbers instead of ActiveRecord IDs.
|
42
|
-
ID param so curious website visitors are unable to determine your
|
43
|
-
count.
|
41
|
+
description: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the
|
42
|
+
ID param so curious website visitors are unable to determine your resource count.
|
44
43
|
email:
|
45
44
|
- info@codeandeffect.com
|
46
45
|
executables: []
|
@@ -57,7 +56,7 @@ homepage: https://github.com/code-and-effect/effective_obfuscation
|
|
57
56
|
licenses:
|
58
57
|
- MIT
|
59
58
|
metadata: {}
|
60
|
-
post_install_message:
|
59
|
+
post_install_message:
|
61
60
|
rdoc_options: []
|
62
61
|
require_paths:
|
63
62
|
- lib
|
@@ -72,10 +71,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
71
|
- !ruby/object:Gem::Version
|
73
72
|
version: '0'
|
74
73
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
74
|
+
rubygems_version: 3.1.2
|
75
|
+
signing_key:
|
78
76
|
specification_version: 4
|
79
|
-
summary: Display unique 10-digit numbers instead of ActiveRecord IDs.
|
80
|
-
param so curious website visitors are unable to determine your
|
77
|
+
summary: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the ID
|
78
|
+
param so curious website visitors are unable to determine your resource count.
|
81
79
|
test_files: []
|