spektr 0.5.5 → 1.0.0
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 +10 -0
- data/README.md +14 -1
- data/lib/spektr/checks/base.rb +1 -0
- data/lib/spektr/checks/file_access.rb +1 -1
- data/lib/spektr/checks/send.rb +2 -2
- data/lib/spektr/targets/base.rb +13 -0
- data/lib/spektr/version.rb +1 -1
- data/lib/spektr.rb +0 -1
- data/spektr.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddcc5f8096643294db83930d7df5cace71619eca037464d68e109ff6f3c9f190
|
|
4
|
+
data.tar.gz: d2a32908dbe7f10b1ee680a62c3442f44e0529b6ea50e3c352451086c5eb7a97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0d7a1db5105c0abc1413b81098cb76895b20bf42e94b33087e9c7a87860cbebaa78efd31fa2e569dacbe3c6df71007cc59dfbae7aa755c4ea049a1ce8890bed
|
|
7
|
+
data.tar.gz: d93c5cf94158219882efd1f6c9c756b2324e87d42a4dbd768479ea0ad1580e70a36e9fc74a249cab34e8cf06e20588cf7f4516a605192ec3da7a52dc25994add
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
* Add support for ignoring findings from specific checks with a `# spektr:ignore CHECK_NAME` source comment
|
|
8
|
+
* Add File.binread to check
|
|
9
|
+
|
|
10
|
+
## 0.5.6
|
|
11
|
+
|
|
12
|
+
* fix nil handling positives
|
|
13
|
+
* remove herb from dependencies
|
|
14
|
+
|
|
5
15
|
## 0.5.5
|
|
6
16
|
|
|
7
17
|
* fix false positives
|
data/README.md
CHANGED
|
@@ -36,8 +36,21 @@ spektr path/to/app
|
|
|
36
36
|
|
|
37
37
|
To see the available options, you can run `spektr --help`.
|
|
38
38
|
|
|
39
|
-
To ignore
|
|
39
|
+
To ignore findings from the command line, use the `--ignore` flag with a comma-separated list of fingerprints from the report.
|
|
40
40
|
|
|
41
|
+
Findings can also be ignored in source code by placing `# spektr:ignore`, followed by one or more comma-separated check names, on the line immediately above them:
|
|
42
|
+
|
|
43
|
+
Use the check names shown in the report:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
# spektr:ignore Arbitrary code execution -- input is validated before this method is called
|
|
47
|
+
eval(params[:code])
|
|
48
|
+
|
|
49
|
+
# spektr:ignore Arbitrary code execution, Dangerous send -- both uses are safe
|
|
50
|
+
eval(send(params[:method]))
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The directive only applies to the named checks on the next line; a directive without a check name has no effect. Keeping a reason after `--` is recommended.
|
|
41
54
|
|
|
42
55
|
### Railsgoat Example output
|
|
43
56
|
|
data/lib/spektr/checks/base.rb
CHANGED
|
@@ -28,6 +28,7 @@ module Spektr
|
|
|
28
28
|
def warn!(target, check, location, message, confidence = :high)
|
|
29
29
|
full_path = target.is_a?(String) ? target : target.path
|
|
30
30
|
path = full_path.gsub(@app.root, "")
|
|
31
|
+
return if target.respond_to?(:ignored_at?) && target.ignored_at?(location&.start_line, check)
|
|
31
32
|
return if dupe?(path, location, message)
|
|
32
33
|
|
|
33
34
|
@app.warnings << Warning.new(path, full_path, check, location, message, confidence)
|
|
@@ -16,7 +16,7 @@ module Spektr
|
|
|
16
16
|
def run
|
|
17
17
|
return unless super
|
|
18
18
|
targets = ["Dir", "File", "IO", "Kernel", "Net::FTP", "Net::HTTP", "PStore", "Pathname", "Shell"]
|
|
19
|
-
methods = [:[], :chdir, :chroot, :delete, :entries, :foreach, :glob, :install, :lchmod, :lchown, :link, :load, :load_file, :makedirs, :move, :new, :open, :read, :readlines, :rename, :rmdir, :safe_unlink, :symlink, :syscopy, :sysopen, :truncate, :unlink]
|
|
19
|
+
methods = [:[], :binread, :chdir, :chroot, :delete, :entries, :foreach, :glob, :install, :lchmod, :lchown, :link, :load, :load_file, :makedirs, :move, :new, :open, :read, :readlines, :rename, :rmdir, :safe_unlink, :symlink, :syscopy, :sysopen, :truncate, :unlink]
|
|
20
20
|
targets.each do |target|
|
|
21
21
|
methods.each do |method|
|
|
22
22
|
check_calls_for_user_input(@target.find_calls(method, target.to_sym))
|
data/lib/spektr/checks/send.rb
CHANGED
|
@@ -12,8 +12,8 @@ module Spektr
|
|
|
12
12
|
return unless super
|
|
13
13
|
[:send, :try, :__send__, :public_send].each do |method|
|
|
14
14
|
@target.find_calls(method).each do |call|
|
|
15
|
-
argument = call.arguments
|
|
16
|
-
if user_input?(argument)
|
|
15
|
+
argument = call.arguments&.arguments&.first
|
|
16
|
+
if argument && user_input?(argument)
|
|
17
17
|
warn! @target, self, call.location, "User supplied value in send"
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/spektr/targets/base.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
module Spektr
|
|
2
2
|
module Targets
|
|
3
3
|
class Base < Prism::Visitor
|
|
4
|
+
IGNORE_DIRECTIVE = /^\s*#\s*spektr:ignore\s+(.+)$/i
|
|
5
|
+
|
|
4
6
|
attr_accessor :path, :name, :options, :ast, :parent, :parent_modules, :methods, :calls, :interpolated_xstrings, :lvars
|
|
5
7
|
|
|
6
8
|
def initialize(path, content)
|
|
7
9
|
Spektr.logger.debug "loading #{path}"
|
|
10
|
+
@source_lines = content.lines
|
|
8
11
|
@ast = Prism.parse(content)
|
|
9
12
|
@path = path
|
|
10
13
|
return unless @ast
|
|
@@ -20,6 +23,16 @@ module Spektr
|
|
|
20
23
|
@name = @name.prepend("#{@parent_modules.map(&:name).join('::')}::") if @name && @parent_modules.any?
|
|
21
24
|
end
|
|
22
25
|
|
|
26
|
+
def ignored_at?(line_number, check)
|
|
27
|
+
return false unless line_number && line_number > 1
|
|
28
|
+
|
|
29
|
+
directive = @source_lines[line_number - 2]&.match(IGNORE_DIRECTIVE)
|
|
30
|
+
return false unless directive
|
|
31
|
+
|
|
32
|
+
ignored_checks = directive[1].split(/\s+--\s+/, 2).first.split(',').map(&:strip)
|
|
33
|
+
ignored_checks.include?(check.name)
|
|
34
|
+
end
|
|
35
|
+
|
|
23
36
|
def method_definitions
|
|
24
37
|
@method_definitions ||= find_methods(node: @ast)
|
|
25
38
|
end
|
data/lib/spektr/version.rb
CHANGED
data/lib/spektr.rb
CHANGED
data/spektr.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spektr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Molnar
|
|
@@ -23,20 +23,6 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: herb
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0'
|
|
33
|
-
type: :runtime
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - ">="
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0'
|
|
40
26
|
- !ruby/object:Gem::Dependency
|
|
41
27
|
name: haml
|
|
42
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -348,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
348
334
|
- !ruby/object:Gem::Version
|
|
349
335
|
version: '0'
|
|
350
336
|
requirements: []
|
|
351
|
-
rubygems_version:
|
|
337
|
+
rubygems_version: 4.0.3
|
|
352
338
|
specification_version: 4
|
|
353
339
|
summary: Rails static code analyzer for security issues
|
|
354
340
|
test_files: []
|