mini_defender 0.5.2 → 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/hash.rb +4 -0
- data/lib/mini_defender/rules/string.rb +17 -1
- 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: 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
|
@@ -34,6 +34,10 @@ class MiniDefender::Rules::Hash < MiniDefender::Rule
|
|
34
34
|
def passes?(attribute, value, validator)
|
35
35
|
passes = value.is_a?(Hash)
|
36
36
|
|
37
|
+
unless passes
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
37
41
|
if @key_type == 'string'
|
38
42
|
passes &= value.all? { |k, _| k.is_a?(String) }
|
39
43
|
end
|
@@ -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)
|
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.4
|
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-01-
|
11
|
+
date: 2024-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|