mini_defender 0.5.6 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mini_defender/rules/iban.rb +11 -9
- data/lib/mini_defender/rules_expander.rb +16 -3
- data/lib/mini_defender/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b22d2146228e92dfadf457e5643cf302660d0270ca7d7bdb5c234d6f77c8c26
|
4
|
+
data.tar.gz: 6fb0563b3e8ca27291823e57b36d0e80721c72623580c2ddbb81c529ab414ad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 788accd406dee38de6fc5fb0150eee0760400eb1afa1ab5f0f4f8480384f77aa5f9d2b0737fece159c2c361c2f1c375a691b8e008e6bca7a259cb3557db3cc38
|
7
|
+
data.tar.gz: df80d251d07fd941fe6711ce275b2a5b599548b8b9e31efab1d7893da1f631dbe15dd4768b45683814f7fff4ceaa2ff645e6b0cf2568b22fc7f69ee17ea2b798
|
@@ -5,6 +5,14 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
|
|
5
5
|
'SA' => 24
|
6
6
|
}
|
7
7
|
|
8
|
+
REPLACEMENTS = {
|
9
|
+
'A' => '10', 'B' => '11', 'C' => '12', 'D' => '13', 'E' => '14', 'F' => '15',
|
10
|
+
'G' => '16', 'H' => '17', 'I' => '18', 'J' => '19', 'K' => '20', 'L' => '21',
|
11
|
+
'M' => '22', 'N' => '23', 'O' => '24', 'P' => '25', 'Q' => '26', 'R' => '27',
|
12
|
+
'S' => '28', 'T' => '29', 'U' => '30', 'V' => '31', 'W' => '32', 'X' => '33',
|
13
|
+
'Y' => '34', 'Z' => '35'
|
14
|
+
}
|
15
|
+
|
8
16
|
def self.signature
|
9
17
|
'iban'
|
10
18
|
end
|
@@ -19,8 +27,9 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
|
|
19
27
|
end
|
20
28
|
|
21
29
|
def valid_checksum?(iban)
|
22
|
-
iban = "#{iban[4..]}#{
|
23
|
-
iban
|
30
|
+
iban = "#{iban[4..]}#{iban[0..1]}#{iban[2..3]}"
|
31
|
+
iban = iban.gsub(Regexp.union(REPLACEMENTS.keys), REPLACEMENTS)
|
32
|
+
iban.to_i % 97 === 1
|
24
33
|
end
|
25
34
|
|
26
35
|
def valid_length?(iban)
|
@@ -30,11 +39,4 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
|
|
30
39
|
def message(attribute, value, validator)
|
31
40
|
"The value should be a valid IBAN."
|
32
41
|
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def letter_code(letter)
|
37
|
-
# letter is assumed to be an upcase ASCII alphabet letter (A-Z)
|
38
|
-
letter.ord - 55
|
39
|
-
end
|
40
42
|
end
|
@@ -33,9 +33,22 @@ module MiniDefender
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def array_patterns(rules)
|
36
|
-
rules
|
37
|
-
|
38
|
-
|
36
|
+
unless rules.is_a?(Hash)
|
37
|
+
raise ArgumentError, 'Rules must be a Hash'
|
38
|
+
end
|
39
|
+
|
40
|
+
result = rules.keys.filter { |key| key.include?('*') }
|
41
|
+
|
42
|
+
# If the user hasn't add a rule for each of the array elements, add it manually
|
43
|
+
rules.keys.each do |key|
|
44
|
+
current = []
|
45
|
+
key.split('.').each do |section|
|
46
|
+
current << section
|
47
|
+
result << current.join('.') if section == '*'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
result.sort.uniq.map { |key| Regexp.compile('\A' + key.gsub(/\*/, '\d+') + '\Z') }
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_defender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Alhoshaiyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|