mini_defender 0.5.3 → 0.5.4
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/string.rb +17 -1
- data/lib/mini_defender/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73ce456e0b23735581871619b744d40814619b39012ebb8b1cd50367ee0e7af4
|
4
|
+
data.tar.gz: d5e71ffdebfb17149e631ad9464482209685a17b97b04b16a498a8fd0933d656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae9ec903aa13fbc773146154ce692e2fb6d66c5ea6cd8a4c00597479d1811142d25c802015d7da738a79c41fd3550754e92b77ae6dd1dc85103f0ae0a8e6b9d3
|
7
|
+
data.tar.gz: 55638c4ad883417564d6f1596eb3670b01ce7b8fe85f9462f7d54b4579ed9195c0d0b787c0efeae9e81ce764df66346fbd64e7fbd6318d609044a57c0818b799
|
@@ -1,12 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class MiniDefender::Rules::String < MiniDefender::Rule
|
4
|
+
def initialize(mode = 'strict')
|
5
|
+
@mode = mode
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.signature
|
5
9
|
'string'
|
6
10
|
end
|
7
11
|
|
12
|
+
def coerce(value)
|
13
|
+
value.to_s
|
14
|
+
end
|
15
|
+
|
8
16
|
def passes?(attribute, value, validator)
|
9
|
-
|
17
|
+
if @mode == 'relaxed'
|
18
|
+
value.is_a?(String) ||
|
19
|
+
value.is_a?(Integer) ||
|
20
|
+
value.is_a?(Float) ||
|
21
|
+
value.is_a?(FalseClass) ||
|
22
|
+
value.is_a?(TrueClass)
|
23
|
+
else
|
24
|
+
value.is_a?(String)
|
25
|
+
end
|
10
26
|
end
|
11
27
|
|
12
28
|
def message(attribute, value, validator)
|