spektr 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/lib/spektr/checks/base.rb +5 -4
- data/lib/spektr/checks/command_injection.rb +1 -5
- data/lib/spektr/checks/content_tag_xss.rb +1 -1
- data/lib/spektr/checks/evaluation.rb +1 -0
- data/lib/spektr/targets/base.rb +5 -4
- data/lib/spektr/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: 8a830f6b6b9be5ac380e1cbf4a755b9171b77f9835d9e3f62c5f62c411ba529e
|
|
4
|
+
data.tar.gz: 97a48a8cdaf9d5ab568dcc7d201daf1433b07c1a6043901c300147185ef99dec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 162e450e6584062cf616d010401090d8e367041042aca79b3b1a6268948e3a99185bbe08ee4fa1928a13a3a45b9cdd5a05f165a282c4abec47f52e23c059b363
|
|
7
|
+
data.tar.gz: d61db3f6438d1ddcd64564815096beb67007539a543c90a0768423d41ede3bf571ea8acd7d167339ee4dde5074677d49719d0fb14fcebabe9fe9d22bc30b2ac9
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
data/lib/spektr/checks/base.rb
CHANGED
|
@@ -65,7 +65,7 @@ module Spektr
|
|
|
65
65
|
end
|
|
66
66
|
when :keyword_hash_node, :hash_node
|
|
67
67
|
node.elements.each do |element|
|
|
68
|
-
return true if user_input?(element.key)
|
|
68
|
+
return true if element.respond_to?(:key) && user_input?(element.key)
|
|
69
69
|
return true if user_input?(element.value)
|
|
70
70
|
end
|
|
71
71
|
when :array_node
|
|
@@ -85,7 +85,7 @@ module Spektr
|
|
|
85
85
|
actions.each do |action|
|
|
86
86
|
next unless action.body
|
|
87
87
|
action.body.each do |exp|
|
|
88
|
-
return true if exp.name == node.name && user_input?(exp)
|
|
88
|
+
return true if exp.respond_to?(:name) && exp.name == node.name && user_input?(exp)
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
when :local_variable_read_node
|
|
@@ -137,7 +137,7 @@ module Spektr
|
|
|
137
137
|
end
|
|
138
138
|
when :keyword_hash_node, :hash_node
|
|
139
139
|
node.elements.each do |element|
|
|
140
|
-
return true if model_attribute?(element.key)
|
|
140
|
+
return true if element.respond_to?(:key) && model_attribute?(element.key)
|
|
141
141
|
return true if model_attribute?(element.value)
|
|
142
142
|
end
|
|
143
143
|
when :array_node
|
|
@@ -176,8 +176,9 @@ module Spektr
|
|
|
176
176
|
}
|
|
177
177
|
end
|
|
178
178
|
actions.each do |action|
|
|
179
|
+
next unless action.body
|
|
179
180
|
action.body.each do |exp|
|
|
180
|
-
next unless node.respond_to?(:name)
|
|
181
|
+
next unless exp.respond_to?(:name) && node.respond_to?(:name)
|
|
181
182
|
return model_attribute?(exp.value) if exp.is_a?(Prism::InstanceVariableWriteNode) && exp.name == node.name
|
|
182
183
|
end
|
|
183
184
|
end
|
|
@@ -34,11 +34,7 @@ module Spektr
|
|
|
34
34
|
# TODO: might need to exclude tempfile and ActiveStorage::Filename
|
|
35
35
|
return if calls.empty?
|
|
36
36
|
calls.each do |call|
|
|
37
|
-
if call.arguments.is_a?(Prism::ArgumentsNode)
|
|
38
|
-
argument = call.arguments.arguments.first
|
|
39
|
-
else
|
|
40
|
-
argument = call.arguments.first
|
|
41
|
-
end
|
|
37
|
+
argument = call.arguments.arguments.first if call.arguments.is_a?(Prism::ArgumentsNode)
|
|
42
38
|
next unless argument
|
|
43
39
|
if user_input?(argument) || model_attribute?(argument)
|
|
44
40
|
warn! @target, self, call.location, "Command injection in #{call.name}"
|
|
@@ -36,7 +36,7 @@ module Spektr
|
|
|
36
36
|
end
|
|
37
37
|
if argument.is_a?(Prism::KeywordHashNode)
|
|
38
38
|
argument.elements.each do |element|
|
|
39
|
-
if user_input?(element.key)
|
|
39
|
+
if element.respond_to?(:key) && user_input?(element.key)
|
|
40
40
|
warn! @target, self, call.location, "Unescaped parameter in content_tag at #{element.key.name}"
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -12,6 +12,7 @@ module Spektr
|
|
|
12
12
|
return unless super
|
|
13
13
|
[:eval, :instance_eval, :class_eval, :module_eval].each do |name|
|
|
14
14
|
@target.find_calls(name).each do |call|
|
|
15
|
+
next unless call.arguments
|
|
15
16
|
call.arguments.arguments.each do |argument|
|
|
16
17
|
if user_input?(argument)
|
|
17
18
|
warn! @target, self, call.location, "User input in eval"
|
data/lib/spektr/targets/base.rb
CHANGED
|
@@ -11,6 +11,7 @@ module Spektr
|
|
|
11
11
|
@ast = Prism.parse(content)
|
|
12
12
|
@path = path
|
|
13
13
|
return unless @ast
|
|
14
|
+
@name = ""
|
|
14
15
|
@parent = ""
|
|
15
16
|
@parent_modules = []
|
|
16
17
|
@methods = []
|
|
@@ -89,12 +90,12 @@ module Spektr
|
|
|
89
90
|
@parent = node.superclass.receiver.name.to_s
|
|
90
91
|
when Prism::ConstantPathNode, Prism::ConstantReadNode
|
|
91
92
|
@parent = node.superclass.name.to_s
|
|
92
|
-
@parent.prepend("#{node.superclass.parent.name}::") if node.superclass.respond_to?(:parent)
|
|
93
|
-
if node.superclass.respond_to?(:parent) && node.superclass.parent.respond_to?(:parent)
|
|
93
|
+
@parent.prepend("#{node.superclass.parent.name}::") if node.superclass.respond_to?(:parent) && node.superclass.parent
|
|
94
|
+
if node.superclass.respond_to?(:parent) && node.superclass.parent.respond_to?(:parent) && node.superclass.parent&.parent
|
|
94
95
|
@parent.prepend("#{node.superclass.parent.parent.name}::")
|
|
95
96
|
end
|
|
96
97
|
end
|
|
97
|
-
if node.is_a?(Prism::ClassNode) && node.constant_path && node.constant_path.respond_to?(:parent)
|
|
98
|
+
if node.is_a?(Prism::ClassNode) && node.constant_path && node.constant_path.respond_to?(:parent) && node.constant_path.parent
|
|
98
99
|
@parent = node.constant_path.parent.name.to_s
|
|
99
100
|
end
|
|
100
101
|
@parent = @parent.prepend("#{@parent_modules.map(&:name).join('::')}::") if @parent_modules.any?
|
|
@@ -102,7 +103,7 @@ module Spektr
|
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
def visit_module_node(node)
|
|
105
|
-
@parent_modules << node.constant_path.parent.name if node.constant_path && node.constant_path.respond_to?(:parent)
|
|
106
|
+
@parent_modules << node.constant_path.parent.name if node.constant_path && node.constant_path.respond_to?(:parent) && node.constant_path.parent
|
|
106
107
|
@parent_modules << node
|
|
107
108
|
super
|
|
108
109
|
end
|
data/lib/spektr/version.rb
CHANGED