dawnscanner 2.0.0.rc3 → 2.0.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Changelog.md +10 -3
- data/LICENSE.txt +1 -1
- data/README.md +3 -5
- data/Rakefile +4 -7
- data/Roadmap.md +15 -23
- data/VERSION +3 -15
- data/bin/dawn +2 -1
- data/checksum/dawnscanner-2.0.0.rc3.gem.sha1 +1 -0
- data/dawnscanner.gemspec +3 -4
- data/doc/kickstart_kb.tar.gz +0 -0
- data/docs/.placeholder +0 -0
- data/docs/CNAME +1 -0
- data/docs/_config.yml +1 -0
- data/lib/dawn/cli/dawn_cli.rb +40 -24
- data/lib/dawn/core.rb +2 -2
- data/lib/dawn/engine.rb +26 -21
- data/lib/dawn/kb/operating_system_check.rb +1 -1
- data/lib/dawn/kb/pattern_match_check.rb +10 -9
- data/lib/dawn/kb/unsafe_depedency_check.rb +44 -0
- data/lib/dawn/knowledge_base.rb +75 -21
- data/lib/dawn/reporter.rb +4 -1
- data/lib/dawn/version.rb +4 -5
- data/spec/lib/kb/codesake_dependency_version_check_spec.rb +18 -15
- data/spec/lib/kb/codesake_ruby_version_check_spec.rb +7 -17
- data/spec/lib/kb/codesake_unsafe_dependency_check_spec.rb +29 -0
- data/spec/lib/kb/dependency_check.yml +29 -0
- metadata +16 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72a87bbf8ef2496a0afd46d528d72e054f5dae05ebd931c7def8f99be76961da
|
4
|
+
data.tar.gz: 67625dd36903d067ecf28c8581b130d1b2c612a3b26ded963e2868bb95efb853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6621edd0430c27a88d8813e5ca57475466ff8ea6d262cc7f324890d521a10d1f24f055004fdfa4ccb36e9131d1ea6f6d8957e17d26a54846194706279e617a2
|
7
|
+
data.tar.gz: ec14c1e7804f38e5bcb6f87ea7d05afedc83206db846eaec197d4e5be5b48f9ee1059fb87d21ddbab52e023fb2f0a7cc74bc90517be9e62a0e81d9810b93137e
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3
|
data/Changelog.md
CHANGED
@@ -5,9 +5,9 @@ It supports [Sinatra](http://www.sinatrarb.com),
|
|
5
5
|
[Padrino](http://www.padrinorb.com) and [Ruby on Rails](http://rubyonrails.org)
|
6
6
|
frameworks.
|
7
7
|
|
8
|
-
_latest update: mer
|
8
|
+
_latest update: mer 29 mar 2023, 18:32:56, CEST_
|
9
9
|
|
10
|
-
## Version 2.0.0
|
10
|
+
## Version 2.0.0
|
11
11
|
|
12
12
|
* New knowledge base, YAML based and distributed separately from the ruby gem.
|
13
13
|
* New CLI based on Thor library. Please read README.md file to know how to
|
@@ -16,9 +16,16 @@ _latest update: mer 28 nov 2018, 11.03.53, CET_
|
|
16
16
|
* Removed rake osvdb[name] and rake cve[name] tasks
|
17
17
|
* Adding telemetry
|
18
18
|
* Dawn::Utils include refactory. Now it's available application wide
|
19
|
-
* debug information refactory.
|
19
|
+
* debug information refactory.
|
20
20
|
* engine class, apply_all method now accepts an optional parameter containing a
|
21
21
|
list of security checks to be excluded (issue #230).
|
22
|
+
* Fix issue #244. Now the KB path is no more hardcoded but it is relative to
|
23
|
+
$HOME and 'dawnscanner' folder where results are stored.
|
24
|
+
* Fix issue #245. Pattern matching check is skipped on empty files.
|
25
|
+
* Fix issue #250. Require missing fileutils, thanks to @lukaszsliwa
|
26
|
+
* Fix issue #252. File.exists was removed in newer interpreter versions
|
27
|
+
* Dropping codenames
|
28
|
+
* Class names must be declared before loading YAML files
|
22
29
|
|
23
30
|
## Version 1.6.9 - codename: Tow Mater (2018-11-28)
|
24
31
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
# Dawnscanner - The raising security scanner for ruby web applications
|
2
2
|
|
3
|
-
dawnscanner is a source code scanner designed to review your
|
3
|
+
dawnscanner is a source code scanner designed to review your web applications for
|
4
4
|
security issues.
|
5
5
|
|
6
|
-
dawnscanner is able to scan
|
7
|
-
|
8
|
-
dawnscanner is able to scan major MVC (Model View Controller) frameworks, out of the
|
9
|
-
box:
|
6
|
+
dawnscanner is able to scan web applications written in Ruby and it supports all
|
7
|
+
major MVC (Model View Controller) frameworks, out of the box:
|
10
8
|
|
11
9
|
* [Ruby on Rails](http://rubyonrails.org)
|
12
10
|
* [Sinatra](http://www.sinatrarb.com)
|
data/Rakefile
CHANGED
@@ -37,22 +37,18 @@ namespace :version do
|
|
37
37
|
a = f.readlines
|
38
38
|
end
|
39
39
|
version = a[a.length - 1].split('-')[0]# .chomp
|
40
|
-
codename = a[a.length - 1].split('-')[1]
|
41
40
|
|
42
41
|
File.open("./lib/dawn/version.rb", "w") do |f|
|
43
42
|
|
44
43
|
f.puts("module Dawn")
|
45
44
|
|
46
45
|
puts "#{branch_name}|"
|
47
|
-
if branch_name != "
|
46
|
+
if branch_name != "main"
|
48
47
|
av = version.split('.')
|
49
48
|
f.puts " VERSION = \"#{av[0]}.#{av[1]}.#{commit_hash.chop}\""
|
50
|
-
f.puts " CODENAME = \"#{codename.lstrip!.chop}\""
|
51
49
|
f.puts " RELEASE = \"(development)\""
|
52
50
|
else
|
53
|
-
puts "here"
|
54
51
|
f.puts " VERSION = \"#{version.rstrip!}\""
|
55
|
-
f.puts " CODENAME = \"#{codename.lstrip!.chop}\""
|
56
52
|
f.puts " RELEASE = \"#{release}\""
|
57
53
|
end
|
58
54
|
f.puts " BUILD = \"#{build_number.chop}\""
|
@@ -74,7 +70,8 @@ namespace :kb do
|
|
74
70
|
desc 'Pack the library for shipping'
|
75
71
|
|
76
72
|
task :pack do
|
77
|
-
YAML_KB = File.join(Dir.
|
73
|
+
YAML_KB = File.join(Dir.home, "dawnscanner", 'db')
|
74
|
+
FileUtils.mkdir_p(YAML_KB)
|
78
75
|
__kb_pack
|
79
76
|
end
|
80
77
|
|
@@ -199,7 +196,7 @@ def __kb_pack
|
|
199
196
|
|
200
197
|
|
201
198
|
open(File.join(YAML_KB, "kb.yaml"), 'w') do |f|
|
202
|
-
f.puts(Dawn::
|
199
|
+
f.puts(Dawn::KnowledgeBase.kb_descriptor)
|
203
200
|
end
|
204
201
|
puts "kb.yaml created"
|
205
202
|
system "shasum -a 256 #{YAML_KB}/kb.yaml > #{YAML_KB}/kb.yaml.sig"
|
data/Roadmap.md
CHANGED
@@ -11,12 +11,24 @@ The document is _dynamic_ and feature schedule may vary. If you do need a
|
|
11
11
|
feature to be included sooner, please open an [issue on
|
12
12
|
github](https://github.com/thesp0nge/dawnscanner/issues/new)
|
13
13
|
|
14
|
-
_latest update:
|
14
|
+
_latest update: mar 7 mag 2019, 17:48:53, CEST_
|
15
15
|
|
16
16
|
|
17
|
-
|
17
|
+
* Add Hanami support
|
18
|
+
* Add node.js support
|
19
|
+
|
20
|
+
* Add Maven support (this will lead of creating the skeleton of a
|
21
|
+
dawnscanner-java gem. I will decide later if it will stay with the core or if
|
22
|
+
it will be a separted gem plugging into dawnscanner as plugin).
|
23
|
+
* Add support for pure Rack applications
|
24
|
+
* Add basic support for Javascript. At the beginning, it will be a signature
|
25
|
+
based support. dawnscanner will try to detect the js library version by using
|
26
|
+
SHA hashing functions, comparing it with fingerprint of vulnerable libraies.
|
27
|
+
Of course, this will lead to false negatives if a user tamper the original
|
28
|
+
JS. We must consider also minified versions and we're not able to deal with
|
29
|
+
obfuscated code.
|
30
|
+
|
18
31
|
|
19
|
-
* close all issues on github markedsfor milestone 1.5.5
|
20
32
|
* Issue #131 - Adding a check for OSVDB 119927 : http Gem for Ruby SSL Certificate Validation MitM Spoofing
|
21
33
|
* Issue #119 - Adding a check for OSVDB 114641 : Ruby lib/rexml/entity.rb NULL String Handling Recursive XML External Entity (XXE) Expansion Resource Consumption Remote DoS
|
22
34
|
* Issue #118 - Adding a check for OSVDB 113965 : Sprockets Gem for Ruby Unspecified Request Handling File Enumeration
|
@@ -39,24 +51,6 @@ _latest update: Thu Dec 3 18:29:11 CET 2015_
|
|
39
51
|
* adding test for CVE-2011-4969 XSS in jquery < 1.6.2
|
40
52
|
|
41
53
|
|
42
|
-
## Version 2.0.0 (est. June 2016)
|
43
|
-
|
44
|
-
### New supported frameworks
|
45
|
-
|
46
|
-
* Add Lotus support
|
47
|
-
* Add Maven support (this will lead of creating the skeleton of a
|
48
|
-
dawnscanner-java gem. I will decide later if it will stay with the core or if
|
49
|
-
it will be a separted gem plugging into dawnscanner as plugin).
|
50
|
-
* Add support for pure Rack applications
|
51
|
-
* Add basic support for Javascript. At the beginning, it will be a signature
|
52
|
-
based support. dawnscanner will try to detect the js library version by using
|
53
|
-
SHA hashing functions, comparing it with fingerprint of vulnerable libraies.
|
54
|
-
Of course, this will lead to false negatives if a user tamper the original
|
55
|
-
JS. We must consider also minified versions and we're not able to deal with
|
56
|
-
obfuscated code.
|
57
|
-
|
58
|
-
### New checks
|
59
|
-
|
60
54
|
* Add a language check. It will handle a ruby script as input and a
|
61
55
|
ruby\_parser line as unsafe pattern. It will compile the ruby and look for
|
62
56
|
the unsafe pattern
|
@@ -67,7 +61,6 @@ _latest update: Thu Dec 3 18:29:11 CET 2015_
|
|
67
61
|
dawnscanner the proper way. This is a dynamic tests that it must be run in a
|
68
62
|
static way, looking for the public directory for old and backup files
|
69
63
|
pattern.
|
70
|
-
* Security checks for vulnerabilities out until 31 May 2016.
|
71
64
|
|
72
65
|
### New features
|
73
66
|
|
@@ -115,7 +108,6 @@ _latest update: Thu Dec 3 18:29:11 CET 2015_
|
|
115
108
|
## Version 2.5.0 (est. December 2016)
|
116
109
|
|
117
110
|
* Add automatic mitigation patch generation for Ruby
|
118
|
-
* Add node.js support
|
119
111
|
* Add Opal support
|
120
112
|
|
121
113
|
## Long term Roadmap
|
data/VERSION
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
#
|
5
|
-
# Future releases
|
6
|
-
#
|
7
|
-
# | Character | Release |
|
8
|
-
# |-----------------|---------|
|
9
|
-
# | "Finn McMissile"| 2.0.0 |
|
10
|
-
# | "Fillmore" | x.x.0 |
|
11
|
-
# |"Holly Shiftwell"| x.x.0 |
|
12
|
-
# | "Guido" | x.x.0 |
|
13
|
-
# | "Luigi" | x.x.0 |
|
14
|
-
# | "Doc Hudson" | x.x.0 |
|
15
|
-
2.0.0.rc3 - Finn McMissile
|
1
|
+
# I removed codenames :-)
|
2
|
+
# Code review is fun
|
3
|
+
2.0.0.rc5
|
data/bin/dawn
CHANGED
@@ -8,6 +8,7 @@ require 'justify'
|
|
8
8
|
require 'dawnscanner'
|
9
9
|
|
10
10
|
APPNAME = File.basename($0)
|
11
|
+
|
11
12
|
LIST_KNOWN_FRAMEWORK = %w(rails sinatra padrino)
|
12
13
|
VALID_OUTPUT_FORMAT = %w(console json csv html)
|
13
14
|
|
@@ -23,7 +24,7 @@ $logger.formatter = proc do |severity, datetime, progname, msg|
|
|
23
24
|
date_format = datetime.strftime("%Y-%m-%d %H:%M:%S")
|
24
25
|
if severity == "INFO" or severity == "WARN"
|
25
26
|
"[#{date_format}] #{severity} (dawn): #{msg}\n"
|
26
|
-
else
|
27
|
+
else
|
27
28
|
"[#{date_format}] #{severity} (dawn): #{msg}\n"
|
28
29
|
end
|
29
30
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
55641656f0a1979b283c10ac526f00f5fc449d89
|
data/dawnscanner.gemspec
CHANGED
@@ -52,10 +52,9 @@ Gem::Specification.new do |gem|
|
|
52
52
|
# Marked to be unused right now
|
53
53
|
# gem.add_dependency 'parser'
|
54
54
|
|
55
|
-
gem.add_development_dependency
|
56
|
-
gem.add_development_dependency
|
57
|
-
gem.add_development_dependency
|
55
|
+
gem.add_development_dependency('coveralls')
|
56
|
+
gem.add_development_dependency('rake')
|
57
|
+
gem.add_development_dependency('rspec')
|
58
58
|
gem.add_development_dependency('tomdoc')
|
59
59
|
gem.add_development_dependency('aruba')
|
60
|
-
gem.add_development_dependency('simplecov')
|
61
60
|
end
|
Binary file
|
data/docs/.placeholder
ADDED
File without changes
|
data/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
www.dawnscanner.org
|
data/docs/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-cayman
|
data/lib/dawn/cli/dawn_cli.rb
CHANGED
@@ -3,31 +3,43 @@ require 'dawn/utils'
|
|
3
3
|
|
4
4
|
module Dawn
|
5
5
|
module Cli
|
6
|
-
|
7
6
|
# This class is responsible for the "dawn kb" command and related
|
8
7
|
# subcommands.
|
9
8
|
class Kb < Thor
|
10
9
|
package_name "dawnscanner"
|
11
|
-
desc "
|
12
|
-
def
|
10
|
+
desc "find", "Searches the knowledge base for a given security test"
|
11
|
+
def find(string)
|
13
12
|
kb = Dawn::KnowledgeBase.instance
|
14
13
|
kb.find(string)
|
15
14
|
end
|
16
15
|
|
16
|
+
desc "lint", "Checks knowledge base content for correcteness"
|
17
|
+
def lint
|
18
|
+
kb = Dawn::KnowledgeBase.instance
|
19
|
+
kb.load(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "unpack", "Unpacks security checks in KB library path"
|
23
|
+
def unpack
|
24
|
+
$logger.helo APPNAME, Dawn::VERSION
|
25
|
+
kb = Dawn::KnowledgeBase.instance
|
26
|
+
kb.unpack
|
27
|
+
$logger.bye
|
28
|
+
Kernel.exit(0)
|
29
|
+
end
|
30
|
+
|
17
31
|
desc "status", "Checks the status of the knowledge base"
|
18
32
|
def status
|
19
33
|
$logger.helo APPNAME, Dawn::VERSION
|
20
|
-
Dawn::KnowledgeBase.path="/home/thesp0nge/src/hacking/dawnscanner/db"
|
21
34
|
Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
|
22
35
|
kb = Dawn::KnowledgeBase.instance
|
23
36
|
kb.load
|
24
37
|
if kb.security_checks.empty?
|
25
38
|
$logger.error(kb.error)
|
26
39
|
end
|
27
|
-
|
28
40
|
$logger.info("" + kb.security_checks.count.to_s + " security checks loaded")
|
29
41
|
if kb.is_packed?
|
30
|
-
$logger.error "The knowledge base is packed. It must be unpacked with the 'unpack' command before it can be used"
|
42
|
+
$logger.error "The knowledge base is packed. It must be unpacked with the 'unpack' command before it can be used"
|
31
43
|
end
|
32
44
|
$logger.bye
|
33
45
|
Kernel.exit(0)
|
@@ -50,14 +62,15 @@ module Dawn
|
|
50
62
|
desc "kb SUBCOMMAND ... ARGS", "Interacts with the knowledge base"
|
51
63
|
subcommand "kb", Dawn::Cli::Kb
|
52
64
|
|
53
|
-
desc "scan", "scans a ruby written application for security issues"
|
54
|
-
|
55
|
-
method_option :gemfile,
|
56
|
-
method_option :skip,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
65
|
+
desc "scan", "scans a ruby written web application for security issues"
|
66
|
+
method_option :config_file, :type=>:string, :default=>"", :aliases => "-c", :desc=>"tells dawn to load configuration from filename"
|
67
|
+
method_option :gemfile, :type=>:boolean, :default=>true, :aliases => "-G", :desc => "uses Gemfile.lock to detect MVC"
|
68
|
+
method_option :skip, :type=>:array, :aliases => "-S", :desc => "specify a list of security checks to be skipped"
|
69
|
+
method_option :report_format, :type=>:string, :aliases => "-F", :desc=>"specify the report format (text, html, json). Default is plain text files."
|
70
|
+
method_option :exit_on_warn, :type=>:boolean, :default=>false, :aliases => "-z", :desc =>"return number of found vulnerabilities as exit code"
|
71
|
+
method_option :count, :type=>:boolean, :default=>false, :aliases => "-C", :desc=>"count vulnerabilities (useful for scripts)"
|
72
|
+
method_option :output, :type=>:string, :aliases => "-O", :desc=>"write output to a file with the name specified by the parameter"
|
73
|
+
method_option :dependencies, :type=>:boolean, :default=>false, :aliases => "-d", :desc=>"scan only for vulnerabilities affecting dependencies in Gemfile.lock"
|
61
74
|
|
62
75
|
def scan(target)
|
63
76
|
$logger.helo APPNAME, Dawn::VERSION
|
@@ -70,21 +83,21 @@ module Dawn
|
|
70
83
|
checks_to_be_skipped = []
|
71
84
|
checks_to_be_skipped = options[:skip] unless options[:skip].nil?
|
72
85
|
|
73
|
-
$logger.error("#{options[:skip]}")
|
74
|
-
|
75
86
|
debug_me("scanning #{target}")
|
76
87
|
|
77
88
|
$config_file= Dawn::Core.find_conf(true) if options[:config_file].nil?
|
78
89
|
$config = Dawn::Core.read_conf($config_file)
|
79
90
|
|
91
|
+
debug_me($config)
|
92
|
+
|
80
93
|
$telemetry_url = $config[:telemetry][:endpoint] if $config[:telemetry][:enabled]
|
81
94
|
debug_me("telemetry url is " + $telemetry_url) unless @telemetry_url.nil?
|
82
|
-
|
95
|
+
|
83
96
|
$telemetry_id = $config[:telemetry][:id] if $config[:telemetry][:enabled]
|
84
97
|
debug_me("telemetry id is " + $telemetry_id) unless @telemetry_id.nil?
|
85
98
|
|
86
|
-
|
87
|
-
|
99
|
+
debug_me("telemetry is disabled in config file") unless $config[:telemetry][:enabled]
|
100
|
+
|
88
101
|
engine = Dawn::Core.detect_mvc(target) unless options[:gemfile]
|
89
102
|
engine = Dawn::GemfileLock.new(target) if options[:gemfile]
|
90
103
|
|
@@ -101,17 +114,20 @@ module Dawn
|
|
101
114
|
end
|
102
115
|
end
|
103
116
|
|
104
|
-
|
117
|
+
|
105
118
|
engine.load_knowledge_base
|
106
|
-
|
119
|
+
|
107
120
|
ret = engine.apply_all(checks_to_be_skipped)
|
108
|
-
|
109
|
-
|
110
|
-
|
121
|
+
|
122
|
+
|
123
|
+
if options[:report_format] and options[:report_format].eql? "json"
|
124
|
+
STDERR.puts (ret)? {:status=>"OK", :vulnerabilities_count=>engine.count_vulnerabilities}.to_json : {:status=>"KO", :vulnerabilities_count=>-1}.to_json
|
111
125
|
$logger.bye
|
112
126
|
Kernel.exit(0)
|
113
127
|
end
|
114
128
|
|
129
|
+
$logger.info("#{engine.count_vulnerabilities} issues found")
|
130
|
+
|
115
131
|
Dawn::Reporter.new({:engine=>engine, :apply_all_code=>ret}).report
|
116
132
|
$logger.bye
|
117
133
|
|
data/lib/dawn/core.rb
CHANGED
@@ -123,7 +123,7 @@ module Dawn
|
|
123
123
|
|
124
124
|
# If create_if_none flag is set to true, than I'll create a config file
|
125
125
|
# on the current directory with the default configuration.
|
126
|
-
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES}
|
126
|
+
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES, :telemetry=>{:enabled=>false, :endpoint=>"", :id=>""}}
|
127
127
|
|
128
128
|
# Calculate the conf file path
|
129
129
|
conf_path = File.expand_path('~') +'/.'+conf_name
|
@@ -138,7 +138,7 @@ module Dawn
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def self.read_conf(file=nil)
|
141
|
-
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES}
|
141
|
+
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES, :telemetry=>{:enabled=>false, :endpoint=>"", :id=>""}}
|
142
142
|
begin
|
143
143
|
debug_me("returning a default config") if file.nil? or ! File.exist?(file)
|
144
144
|
return conf if file.nil?
|
data/lib/dawn/engine.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
3
|
require 'socket'
|
4
|
+
require 'fileutils'
|
4
5
|
# Statistics stuff
|
5
6
|
# require 'code_metrics/statistics'
|
6
7
|
|
@@ -39,7 +40,7 @@ module Dawn
|
|
39
40
|
attr_reader :controllers
|
40
41
|
|
41
42
|
# Models I don't know right now. Let them initialized as Array... we
|
42
|
-
# will see later
|
43
|
+
# will see later
|
43
44
|
attr_reader :models
|
44
45
|
|
45
46
|
attr_accessor :debug
|
@@ -69,10 +70,10 @@ module Dawn
|
|
69
70
|
|
70
71
|
set_target(dir) unless dir.nil?
|
71
72
|
|
72
|
-
|
73
|
+
|
73
74
|
|
74
75
|
@ruby_version = get_ruby_version if dir.nil?
|
75
|
-
@gemfile_lock = options[:gemfile_name] unless options[:gemfile_name].nil?
|
76
|
+
@gemfile_lock = options[:gemfile_name] unless options[:gemfile_name].nil?
|
76
77
|
|
77
78
|
# @stats = gather_statistics
|
78
79
|
|
@@ -89,12 +90,12 @@ module Dawn
|
|
89
90
|
end
|
90
91
|
$logger.warn "pattern matching security checks are disabled for Gemfile.lock scan" if @name == "Gemfile.lock"
|
91
92
|
$logger.warn "combo security checks are disabled for Gemfile.lock scan" if @name == "Gemfile.lock"
|
92
|
-
debug_me "engine is in debug mode"
|
93
|
+
debug_me "engine is in debug mode"
|
93
94
|
|
94
95
|
if @name == "Gemfile.lock" && ! options[:guessed_mvc].nil?
|
95
96
|
# since all checks relies on @name a Gemfile.lock engine must
|
96
97
|
# impersonificate the engine for the mvc it was detected
|
97
|
-
debug_me "now I'm switching my name from #{@name} to #{options[:guessed_mvc][:name]}"
|
98
|
+
debug_me "now I'm switching my name from #{@name} to #{options[:guessed_mvc][:name]}"
|
98
99
|
$logger.err "there are no connected gems... it seems Gemfile.lock parsing failed" if options[:guessed_mvc][:connected_gems].empty?
|
99
100
|
@name = options[:guessed_mvc][:name]
|
100
101
|
@mvc_version = options[:guessed_mvc][:version]
|
@@ -111,7 +112,7 @@ module Dawn
|
|
111
112
|
# load_knowledge_base
|
112
113
|
end
|
113
114
|
|
114
|
-
|
115
|
+
|
115
116
|
|
116
117
|
def detect_views
|
117
118
|
[]
|
@@ -125,10 +126,10 @@ module Dawn
|
|
125
126
|
|
126
127
|
def build_view_array(dir)
|
127
128
|
|
128
|
-
return [] unless File.exist?(dir) and File.directory?(dir)
|
129
|
+
return [] unless File.exist?(dir) and File.directory?(dir)
|
129
130
|
|
130
131
|
ret = []
|
131
|
-
Dir.glob(File.join("#{dir}", "*")).each do |filename|
|
132
|
+
Dir.glob(File.join("#{dir}", "*")).each do |filename|
|
132
133
|
ret << {:filename=>filename, :language=>:haml} if File.extname(filename) == ".haml"
|
133
134
|
end
|
134
135
|
|
@@ -151,9 +152,9 @@ module Dawn
|
|
151
152
|
# does the target use rvm?
|
152
153
|
ver = get_rvm_ruby_ver if ver[:version].empty? && ver[:patchlevel].empty?
|
153
154
|
# take the running ruby otherwise
|
154
|
-
ver = {:engine=>RUBY_ENGINE, :version=>RUBY_VERSION, :patchlevel=>"p#{RUBY_PATCHLEVEL}"} if ver[:version].empty? && ver[:patchlevel].empty?
|
155
|
+
ver = {:engine=>RUBY_ENGINE, :version=>RUBY_VERSION, :patchlevel=>"p#{RUBY_PATCHLEVEL}"} if ver[:version].empty? && ver[:patchlevel].empty?
|
155
156
|
else
|
156
|
-
ver = {:engine=>RUBY_ENGINE, :version=>RUBY_VERSION, :patchlevel=>"p#{RUBY_PATCHLEVEL}"}
|
157
|
+
ver = {:engine=>RUBY_ENGINE, :version=>RUBY_VERSION, :patchlevel=>"p#{RUBY_PATCHLEVEL}"}
|
157
158
|
|
158
159
|
end
|
159
160
|
|
@@ -174,10 +175,8 @@ module Dawn
|
|
174
175
|
def load_knowledge_base(enabled_checks=[])
|
175
176
|
debug_me("load_knowledge_base called. Enabled checks are: #{enabled_checks}")
|
176
177
|
|
177
|
-
Dawn::KnowledgeBase.path="/home/thesp0nge/src/hacking/dawnscanner/db"
|
178
178
|
Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
|
179
179
|
kb = Dawn::KnowledgeBase.instance
|
180
|
-
$logger.warn "KB path is forced @ /home/thesp0nge/src/hacking/dawnscanner/db"
|
181
180
|
|
182
181
|
@checks=kb.load
|
183
182
|
debug_me("#{@checks.count} checks loaded")
|
@@ -192,13 +191,13 @@ module Dawn
|
|
192
191
|
return ver unless has_gemfile_lock?
|
193
192
|
|
194
193
|
my_dir = Dir.pwd
|
195
|
-
Dir.chdir(@target)
|
194
|
+
Dir.chdir(@target)
|
196
195
|
lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
|
197
196
|
lockfile.specs.each do |s|
|
198
197
|
# detecting MVC version using @name in case of sinatra, padrino or rails engine
|
199
|
-
ver= s.version.to_s if s.name == @name && @name != "Gemfile.lock"
|
198
|
+
ver= s.version.to_s if s.name == @name && @name != "Gemfile.lock"
|
200
199
|
# detecting MVC version using @force in case of Gemfile.lock engine
|
201
|
-
ver= s.version.to_s if s.name == @force.to_s && @name == "Gemfile.lock"
|
200
|
+
ver= s.version.to_s if s.name == @force.to_s && @name == "Gemfile.lock"
|
202
201
|
@connected_gems << {:name=>s.name, :version=>s.version.to_s}
|
203
202
|
end
|
204
203
|
Dir.chdir(my_dir)
|
@@ -297,7 +296,7 @@ module Dawn
|
|
297
296
|
def have_a_telemetry_id?
|
298
297
|
debug_me ($telemetry_id != "" and ! $telemetry_id.nil?)
|
299
298
|
return ($telemetry_id != "" and ! $telemetry_id.nil?)
|
300
|
-
|
299
|
+
|
301
300
|
end
|
302
301
|
|
303
302
|
def get_a_telemetry_id
|
@@ -312,6 +311,11 @@ module Dawn
|
|
312
311
|
end
|
313
312
|
|
314
313
|
def telemetry
|
314
|
+
unless $config[:telemetry][:enabled]
|
315
|
+
debug_me("telemetry is disabled")
|
316
|
+
return false
|
317
|
+
end
|
318
|
+
|
315
319
|
unless have_a_telemetry_id?
|
316
320
|
$telemetry_id = get_a_telemetry_id
|
317
321
|
$config[:telemetry][:id] = $telemetry_id
|
@@ -321,11 +325,11 @@ module Dawn
|
|
321
325
|
end
|
322
326
|
|
323
327
|
debug_me("Telemetry ID is: " + $telemetry_id)
|
324
|
-
|
328
|
+
|
325
329
|
uri=URI.parse($telemetry_url+"/"+$telemetry_id)
|
326
330
|
header = {'Content-Type': 'text/json'}
|
327
|
-
tele = { "kb_version" => Dawn::KnowledgeBase::VERSION ,
|
328
|
-
"ip" => Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address,
|
331
|
+
tele = { "kb_version" => Dawn::KnowledgeBase::VERSION ,
|
332
|
+
"ip" => Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address,
|
329
333
|
"message"=> Dawn::KnowledgeBase
|
330
334
|
}
|
331
335
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -363,7 +367,7 @@ module Dawn
|
|
363
367
|
end
|
364
368
|
|
365
369
|
@checks.each do |check|
|
366
|
-
if checks_to_be_skipped.include?(check.name)
|
370
|
+
if checks_to_be_skipped.include?(check.name)
|
367
371
|
$logger.info("skipping security check #{check.name}")
|
368
372
|
else
|
369
373
|
_do_apply(check)
|
@@ -439,7 +443,8 @@ module Dawn
|
|
439
443
|
|
440
444
|
check.ruby_version = @ruby_version[:version]
|
441
445
|
check.detected_ruby = @ruby_version if check.kind == Dawn::KnowledgeBase::RUBY_VERSION_CHECK
|
442
|
-
check.dependencies = self.connected_gems if check.kind == Dawn::KnowledgeBase::DEPENDENCY_CHECK
|
446
|
+
check.dependencies = self.connected_gems if check.kind == Dawn::KnowledgeBase::DEPENDENCY_CHECK or
|
447
|
+
check.kind == Dawn::KnowledgeBase::UNSAFE_DEPENDENCY_CHECK
|
443
448
|
check.root_dir = self.target if check.kind == Dawn::KnowledgeBase::PATTERN_MATCH_CHECK
|
444
449
|
check.options = {:detected_ruby => self.ruby_version,
|
445
450
|
:dependencies => self.connected_gems,
|
@@ -25,7 +25,7 @@ module Dawn
|
|
25
25
|
|
26
26
|
EXCLUSION_LIST = [
|
27
27
|
"tags",
|
28
|
-
"vendor/bundle",
|
28
|
+
"vendor/bundle",
|
29
29
|
"features",
|
30
30
|
"specs",
|
31
31
|
"test"
|
@@ -38,10 +38,10 @@ module Dawn
|
|
38
38
|
@attack_pattern_is_regex = false
|
39
39
|
@glob = "**"
|
40
40
|
@attack_pattern = options[:attack_pattern] unless options[:attack_pattern].nil?
|
41
|
-
@negative_search = options[:negative_search] unless options[:negative_search].nil?
|
42
|
-
@avoid_comments = options[:avoid_comments] unless options[:avoid_comments].nil?
|
43
|
-
@evidences = options[:evidences] unless options[:evidences].nil?
|
44
|
-
@attack_pattern_is_regex = options[:attack_pattern_is_regex] unless options[:attack_pattern_is_regex].nil?
|
41
|
+
@negative_search = options[:negative_search] unless options[:negative_search].nil?
|
42
|
+
@avoid_comments = options[:avoid_comments] unless options[:avoid_comments].nil?
|
43
|
+
@evidences = options[:evidences] unless options[:evidences].nil?
|
44
|
+
@attack_pattern_is_regex = options[:attack_pattern_is_regex] unless options[:attack_pattern_is_regex].nil?
|
45
45
|
@glob = File.join(@glob, options[:glob]) unless options[:glob].nil?
|
46
46
|
debug_me("EVIDENCES ARE #{@evidences.inspect}")
|
47
47
|
end
|
@@ -60,8 +60,9 @@ module Dawn
|
|
60
60
|
Dir.glob(File.join("#{root_dir}", @glob)).each do |filename|
|
61
61
|
debug_me("#{File.basename(__FILE__)}@#{__LINE__}: analyzing #{filename}: search is #{@negative_search}")
|
62
62
|
matches = []
|
63
|
+
raise ArgumentError.new("skipping empty file") if File.zero?(filename)
|
63
64
|
begin
|
64
|
-
matches = run(load_file(filename)) if File.
|
65
|
+
matches = run(load_file(filename)) if File.exist?(filename) && File.file?(filename) && ! File.binary?(filename) && ! must_exclude?(filename)
|
65
66
|
found = ! matches.empty?
|
66
67
|
rescue ArgumentError => e
|
67
68
|
puts "Skipping pattern match check for #{filename}: #{e.message}"
|
@@ -84,17 +85,17 @@ module Dawn
|
|
84
85
|
return ret_value
|
85
86
|
end
|
86
87
|
|
87
|
-
private
|
88
|
+
private
|
88
89
|
def string_to_array(par)
|
89
90
|
return par if par.class == Array
|
90
|
-
%w(par)
|
91
|
+
%w(par)
|
91
92
|
end
|
92
93
|
|
93
94
|
def load_file(filename)
|
94
95
|
|
95
96
|
f = File.open(filename)
|
96
97
|
lines = f.readlines
|
97
|
-
f.close
|
98
|
+
f.close
|
98
99
|
|
99
100
|
lines
|
100
101
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Dawn
|
2
|
+
module Kb
|
3
|
+
# While working on the KB rebase, fetching data from NVD API, I suddenly
|
4
|
+
# realize I must change the way a vulnerable dependency must be handled.
|
5
|
+
# Instead of changing what is working right now, I'll add a new dependency
|
6
|
+
# check ruby class
|
7
|
+
# NVD bulletins lists versions that are vulnerable and it would break
|
8
|
+
# automatism adding a post data fetching step to realize which is the first
|
9
|
+
# safe version.
|
10
|
+
#
|
11
|
+
# This class will handle a dependency name, the version found in
|
12
|
+
# Gemfile.lock and an array of vulnerable versions. If the version found is
|
13
|
+
# in the array, than the vuln? method returns true.
|
14
|
+
# This is an approach far more easy rathern than the one chosen in the past.
|
15
|
+
class UnsafeDependencyCheck
|
16
|
+
include BasicCheck
|
17
|
+
|
18
|
+
attr_accessor :dependencies
|
19
|
+
attr_accessor :vulnerable_version_array
|
20
|
+
|
21
|
+
def initialize(options)
|
22
|
+
super(options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def vuln?
|
26
|
+
ret = false
|
27
|
+
|
28
|
+
# 20210325: I know... a single check handles a single dependency so,
|
29
|
+
# this should not be an array. This involves too many underlying
|
30
|
+
# changes one day I'll make.
|
31
|
+
@dependencies.each do |dep|
|
32
|
+
unless @vulnerable_version_array.nil? or @vulnerable_version_array.empty?
|
33
|
+
if dep[:name] == @vulnerable_version_array[0][:name]
|
34
|
+
return false if @vulnerable_version_array[0][:version].nil? or @vulnerable_version_array[0][:version].empty?
|
35
|
+
return true if @vulnerable_version_array[0][:version].include? dep[:version]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/dawn/knowledge_base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
|
3
|
+
require 'rubygems/package'
|
4
|
+
|
3
5
|
# For HTTPS communication to check for KB updates and to fetch them
|
4
6
|
require 'net/http'
|
5
7
|
require 'uri'
|
@@ -9,6 +11,8 @@ require 'digest'
|
|
9
11
|
|
10
12
|
require 'date'
|
11
13
|
|
14
|
+
require 'fileutils'
|
15
|
+
|
12
16
|
# Core KB
|
13
17
|
require "dawn/kb/basic_check"
|
14
18
|
require "dawn/kb/pattern_match_check"
|
@@ -19,12 +23,10 @@ require "dawn/kb/combo_check"
|
|
19
23
|
require "dawn/kb/version_check"
|
20
24
|
require "dawn/kb/deprecation_check"
|
21
25
|
require "dawn/kb/rubygem_check"
|
26
|
+
require "dawn/kb/unsafe_depedency_check"
|
22
27
|
|
23
28
|
module Dawn
|
24
|
-
# This is the YAML powered
|
25
|
-
#
|
26
|
-
# When the old KB format, using Ruby classes will be marked as deprecated,
|
27
|
-
# than this one will be the official.
|
29
|
+
# This is the YAML powered knowledge base
|
28
30
|
#
|
29
31
|
# Dawnscanner KB will be a bunch of YAML file, stored in a hierachy of
|
30
32
|
# directories resembling security checks family. A digital signature will be
|
@@ -46,7 +48,7 @@ module Dawn
|
|
46
48
|
#
|
47
49
|
# Example
|
48
50
|
#
|
49
|
-
# require "dawn/
|
51
|
+
# require "dawn/knowledge_base"
|
50
52
|
#
|
51
53
|
# ...
|
52
54
|
#
|
@@ -54,22 +56,22 @@ module Dawn
|
|
54
56
|
# d.update if d.update?
|
55
57
|
# d.load
|
56
58
|
#
|
57
|
-
# Last update:
|
59
|
+
# Last update: Mon Mar 22 05:08:55 PM CET 2021
|
58
60
|
class KnowledgeBase
|
59
61
|
include Singleton
|
60
62
|
|
61
|
-
@@path = ""
|
62
63
|
@error = ""
|
63
64
|
@@enabled_checks = [:generic_check, :code_quality, :bulletin, :code_style, :owasp_top_10]
|
64
65
|
|
65
66
|
|
66
|
-
GEM_CHECK
|
67
|
-
DEPENDENCY_CHECK
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
GEM_CHECK = :rubygem_check
|
68
|
+
DEPENDENCY_CHECK = :dependency_check
|
69
|
+
UNSAFE_DEPENDENCY_CHECK = :unsafe_dependency_check
|
70
|
+
PATTERN_MATCH_CHECK = :pattern_match_check
|
71
|
+
RUBY_VERSION_CHECK = :ruby_version_check
|
72
|
+
OS_CHECK = :os_check
|
73
|
+
COMBO_CHECK = :combo_check
|
74
|
+
CUSTOM_CHECK = :custom_check
|
73
75
|
|
74
76
|
REMOTE_KB_URL_PREFIX = "https://dawnscanner.org/data/"
|
75
77
|
FILES = %w(kb.yaml bulletin.tar.gz generic_check.tar.gz owasp_ror_cheatsheet.tar.gz code_style.tar.gz code_quality.tar.gz owasp_top_10.tar.gz signatures.tar.gz)
|
@@ -87,7 +89,10 @@ module Dawn
|
|
87
89
|
$logger = Logger.new(STDOUT)
|
88
90
|
$logger.helo "knowledge-base-experimental", Dawn::VERSION
|
89
91
|
end
|
90
|
-
@path
|
92
|
+
@path = default_path
|
93
|
+
@path = options[:path] if options[:path]
|
94
|
+
FileUtils.mkdir_p(@path)
|
95
|
+
|
91
96
|
@enabled_checks = @@enabled_checks
|
92
97
|
|
93
98
|
debug_me "KB root path is #{@path}"
|
@@ -97,9 +102,13 @@ module Dawn
|
|
97
102
|
@@enabled_checks=checks
|
98
103
|
end
|
99
104
|
|
105
|
+
def default_path
|
106
|
+
@path = File.join(Dir.home, 'dawnscanner', 'kb')
|
107
|
+
return @path
|
108
|
+
end
|
100
109
|
|
101
110
|
def self.path= path_name
|
102
|
-
|
111
|
+
@path=path_name
|
103
112
|
end
|
104
113
|
|
105
114
|
def is_packed?
|
@@ -116,8 +125,29 @@ module Dawn
|
|
116
125
|
end
|
117
126
|
|
118
127
|
def unpack
|
119
|
-
|
120
|
-
|
128
|
+
# https://weblog.jamisbuck.org/2015/7/23/tar-gz-in-ruby.html
|
129
|
+
FILES.each do |f|
|
130
|
+
full_name = File.join(path,f)
|
131
|
+
if File.file?(full_name) and File.extname(full_name).eql?('.gz')
|
132
|
+
File.open(full_name, "rb") do |file|
|
133
|
+
Zlib::GzipReader.wrap(file) do |gz|
|
134
|
+
Gem::Package::TarReader.new(gz) do |tar|
|
135
|
+
tar.each do |entry|
|
136
|
+
if entry.file?
|
137
|
+
FileUtils.mkdir_p(File.dirname(File.join(path, entry.full_name)))
|
138
|
+
File.open(File.join(path, entry.full_name), "wb") do |f|
|
139
|
+
f.write(entry.read)
|
140
|
+
end
|
141
|
+
File.chmod(entry.header.mode, File.join(path,entry.full_name))
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else
|
148
|
+
$logger.warn("can't open " + f)
|
149
|
+
end
|
150
|
+
end
|
121
151
|
end
|
122
152
|
|
123
153
|
def self.kb_descriptor
|
@@ -153,7 +183,10 @@ module Dawn
|
|
153
183
|
#
|
154
184
|
# Returns an array of security checks, matching the mvc to be reviewed and
|
155
185
|
# the enabled check list or an empty array if an error occured.
|
156
|
-
def load
|
186
|
+
def load(lint=false)
|
187
|
+
good =0
|
188
|
+
invalid =0
|
189
|
+
|
157
190
|
@security_checks = []
|
158
191
|
# $path = File.join(Dir.pwd, "db")
|
159
192
|
|
@@ -178,10 +211,31 @@ module Dawn
|
|
178
211
|
$logger.warn "Missing check directory #{dir}"
|
179
212
|
else
|
180
213
|
Dir.glob(dir+"/**/*.yml").each do |f|
|
181
|
-
|
182
|
-
|
214
|
+
begin
|
215
|
+
data = YAML.load_file(f, permitted_classes: [Dawn::Kb::UnsafeDependencyCheck,
|
216
|
+
Dawn::Kb::BasicCheck,
|
217
|
+
Dawn::Kb::ComboCheck,
|
218
|
+
Dawn::Kb::DependencyCheck,
|
219
|
+
Dawn::Kb::DeprecationCheck,
|
220
|
+
Dawn::Kb::OperatingSystemCheck,
|
221
|
+
Dawn::Kb::PatternMatchCheck,
|
222
|
+
Dawn::Kb::RubygemCheck,
|
223
|
+
Dawn::Kb::RubyVersionCheck,
|
224
|
+
Dawn::Kb::VersionCheck,
|
225
|
+
Date,
|
226
|
+
Symbol])
|
227
|
+
@security_checks << data
|
228
|
+
good+=1
|
229
|
+
$logger.info("#{File.basename(f)} loaded") if lint
|
230
|
+
rescue Exception => e
|
231
|
+
$logger.error(e.message)
|
232
|
+
invalid+=1
|
233
|
+
end
|
183
234
|
end
|
235
|
+
end
|
184
236
|
|
237
|
+
if lint
|
238
|
+
$logger.info("#{invalid} invalid checks out of #{good+invalid}")
|
185
239
|
end
|
186
240
|
|
187
241
|
|
data/lib/dawn/reporter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Dawn
|
2
4
|
class Reporter
|
3
5
|
|
@@ -199,7 +201,8 @@ module Dawn
|
|
199
201
|
# 1_a) Third party gem vulnerabilities
|
200
202
|
rows = []
|
201
203
|
@engine.vulnerabilities.each do |vuln|
|
202
|
-
|
204
|
+
$logger.error(vuln)
|
205
|
+
rows << [vuln[:name]&.justify(10), vuln[:severity], vuln[:message]&.justify(30), vuln[:remediation]&.justify(15), vuln[:evidences].join&.justify(15)]
|
203
206
|
rows << :separator
|
204
207
|
end
|
205
208
|
table = Terminal::Table.new :title=>"Vulnerabilities", :headings=>['Issue', 'Severity', 'Description', 'Solution', 'Evidences'], :rows=>rows
|
data/lib/dawn/version.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class DependencyMockup
|
4
|
-
|
3
|
+
# class DependencyMockup
|
4
|
+
# include Dawn::Kb::DependencyCheck
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
# def initialize
|
7
|
+
# message = "This is a mock"
|
8
|
+
# super(
|
9
|
+
# :kind=>Dawn::KnowledgeBase::DEPENDENCY_CHECK,
|
10
|
+
# :applies=>['sinatra', 'padrino', 'rails'],
|
11
|
+
# :message=> message
|
12
|
+
# )
|
13
|
+
# # self.debug = true
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
15
|
+
# self.safe_dependencies = [{:name=>'this_gem', :version=>['0.3.0', '1.3.3', '2.3.3', '2.4.2', '9.4.31.2']}]
|
16
|
+
# self.save_major = true
|
17
|
+
# end
|
18
|
+
# end
|
19
19
|
|
20
20
|
|
21
21
|
describe "The security check for gem dependency should" do
|
22
22
|
before(:all) do
|
23
|
-
@check =
|
23
|
+
@check = Dawn::Kb::DependencyCheck.new
|
24
|
+
@check.kind=Dawn::KnowledgeBase::DEPENDENCY_CHECK
|
25
|
+
@check.applies = ['sinatra', 'padrino', 'rails']
|
26
|
+
@check.message = "This is a mock"
|
24
27
|
end
|
25
28
|
# let (:check) {Mockup.new}
|
26
29
|
|
@@ -1,23 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class Mockup
|
4
|
-
include Dawn::Kb::RubyVersionCheck
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
message = "This is a mock"
|
8
|
-
super(
|
9
|
-
:kind=>Dawn::KnowledgeBase::RUBY_VERSION_CHECK,
|
10
|
-
:applies=>['sinatra', 'padrino', 'rails'],
|
11
|
-
:message=> message
|
12
|
-
)
|
13
|
-
# self.debug = true
|
14
|
-
|
15
|
-
self.safe_rubies = [{:version=>"1.9.3", :patchlevel=>"p392"}, {:version=>"2.0.0", :patchlevel=>"p0"}]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
3
|
describe "The security check for Ruby interpreter version" do
|
20
|
-
|
4
|
+
before(:all) do
|
5
|
+
@check = Dawn::Kb::RubyVersionCheck.new
|
6
|
+
@check.message = "This is a mock"
|
7
|
+
@check.kind=Dawn::KnowledgeBase::RUBY_VERSION_CHECK
|
8
|
+
@check.applies=['sinatra', 'padrino', 'rails']
|
9
|
+
@check.safe_rubies = [{:version=>"1.9.3", :patchlevel=>"p392"}, {:version=>"2.0.0", :patchlevel=>"p0"}]
|
10
|
+
end
|
21
11
|
|
22
12
|
it "fires if ruby version is vulnerable" do
|
23
13
|
check.detected_ruby = {:version=>"1.9.2", :patchlevel=>"p10000"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "The security check for gem unsafe dependency should" do
|
5
|
+
before(:all) do
|
6
|
+
@check = YAML.load_file("./spec/lib/kb/dependency_check.yml")
|
7
|
+
@check.debug=true
|
8
|
+
puts @check.vulnerable_version_array
|
9
|
+
end
|
10
|
+
|
11
|
+
it "fires if vulnerable 0.5.0 version is detected" do
|
12
|
+
@check.dependencies = [{:name=>"acme-gem", :version=>'0.5.0'}]
|
13
|
+
expect(@check.vuln?).to eq(true)
|
14
|
+
end
|
15
|
+
it "fires if vulnerable 1.3.2 version is found" do
|
16
|
+
@check.dependencies = [{:name=>"acme-gem", :version=>'1.3.2'}]
|
17
|
+
expect(@check.vuln?).to eq(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "fires if vulnerable 3.4.0 version is found" do
|
21
|
+
@check.dependencies = [{:name=>"acme-gem", :version=>'3.4.0'}]
|
22
|
+
expect(@check.vuln?).to eq(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "doesn't fire if not vulnerable 3.0.0 version is found" do
|
26
|
+
@check.dependencies = [{:name=>"acme-gem", :version=>'3.0.0'}]
|
27
|
+
expect(@check.vuln?).to eq(false)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
--- !ruby/object:Dawn::Kb::UnsafeDependencyCheck
|
2
|
+
applies:
|
3
|
+
- rails
|
4
|
+
- sinatra
|
5
|
+
- padrino
|
6
|
+
title: A test here
|
7
|
+
cvss: '(AV:L/AC:L/Au:S/C:N/I:C/A:C)'
|
8
|
+
cve: 'CVE-2021-99999'
|
9
|
+
owasp: A9
|
10
|
+
release_date: '25/03/2021'
|
11
|
+
kind: :unsafe_dependency_check
|
12
|
+
message: |-
|
13
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nisi turpis, tincidunt rhoncus leo sed, euismod sollicitudin nisl. In a arcu accumsan, fermentum quam vel, auctor risus. Nulla non sollicitudin libero. Cras hendrerit consectetur pulvinar. Vivamus ligula quam, vulputate eget justo in, varius rhoncus lorem. Nulla vel volutpat enim. Nulla hendrerit posuere tempor. Nulla in metus eget lacus tempor sollicitudin sed et dolor. Ut interdum volutpat felis, ac bibendum mauris volutpat ut. Etiam posuere justo ex, nec faucibus orci suscipit sit amet. Vivamus rutrum massa fermentum mi pellentesque vehicula. Nullam elementum urna mauris, nec cursus risus convallis vel. Nulla consectetur enim ut magna rutrum, et mollis ante auctor. Etiam accumsan in lacus et ultricies. Morbi ullamcorper velit a ipsum egestas, quis laoreet lectus placerat. Maecenas nunc augue, pulvinar non ligula ac, maximus venenatis mi.
|
14
|
+
|
15
|
+
remediation: |-
|
16
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et metus blandit, viverra ante a, auctor urna. Integer eget est ac nisl bibendum pharetra. Vivamus rhoncus neque vitae felis congue luctus. Praesent vitae lobortis mi. Nulla malesuada elit dictum tincidunt volutpat. Quisque tincidunt lorem nec eros ullamcorper lobortis. Nunc in felis sit amet purus sollicitudin tincidunt. Sed semper sapien nisi, non rutrum orci ultricies eget. Integer neque mauris, gravida ac varius nec, tincidunt consequat turpis. Fusce nisi metus, iaculis a eros eget, interdum sodales lectus. Pellentesque purus nisi, venenatis ut quam vitae, lacinia tristique turpis. Morbi sed maximus odio, et interdum risus. Duis nec congue lacus. Nunc sed elit a leo fermentum feugiat a aliquam arcu.
|
17
|
+
|
18
|
+
severity: :critical
|
19
|
+
priority: :high
|
20
|
+
check_family: :bulletin
|
21
|
+
vulnerable_version_array:
|
22
|
+
- :name: 'acme-gem'
|
23
|
+
:version:
|
24
|
+
- '0.5.0'
|
25
|
+
- '0.9.0'
|
26
|
+
- '0.9.2'
|
27
|
+
- '1.3.2'
|
28
|
+
- '2.9.0'
|
29
|
+
- '3.4.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dawnscanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Perego
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cvss
|
@@ -220,20 +220,6 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: simplecov
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
223
|
description: Dawnscanner is a security source code scanner for ruby powered code.
|
238
224
|
It is especially designed for web applications, but it works also with general purpose
|
239
225
|
ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino
|
@@ -289,6 +275,7 @@ files:
|
|
289
275
|
- checksum/dawnscanner-1.6.8.gem.sha1
|
290
276
|
- checksum/dawnscanner-2.0.0.rc1.gem.sha1
|
291
277
|
- checksum/dawnscanner-2.0.0.rc2.gem.sha1
|
278
|
+
- checksum/dawnscanner-2.0.0.rc3.gem.sha1
|
292
279
|
- code_of_conduct.md
|
293
280
|
- dawnscanner.gemspec
|
294
281
|
- doc/change.sh
|
@@ -297,8 +284,12 @@ files:
|
|
297
284
|
- doc/dawn_1_2_announcement.md
|
298
285
|
- doc/dawn_1_5_announcement.md
|
299
286
|
- doc/dawnscanner.yml.sample
|
287
|
+
- doc/kickstart_kb.tar.gz
|
300
288
|
- doc/knowledge_base.rb
|
301
289
|
- doc/new_knowledge_base_v1.0.md
|
290
|
+
- docs/.placeholder
|
291
|
+
- docs/CNAME
|
292
|
+
- docs/_config.yml
|
302
293
|
- features/dawn_complains_about_an_incorrect_command_line.feature.disabled
|
303
294
|
- features/dawn_scan_a_secure_sinatra_app.feature.disabled
|
304
295
|
- features/dawn_scan_a_vulnerable_sinatra_app.feature.disabled
|
@@ -316,6 +307,7 @@ files:
|
|
316
307
|
- lib/dawn/kb/pattern_match_check.rb
|
317
308
|
- lib/dawn/kb/ruby_version_check.rb
|
318
309
|
- lib/dawn/kb/rubygem_check.rb
|
310
|
+
- lib/dawn/kb/unsafe_depedency_check.rb
|
319
311
|
- lib/dawn/kb/version_check.rb
|
320
312
|
- lib/dawn/knowledge_base.rb
|
321
313
|
- lib/dawn/logger.rb
|
@@ -340,7 +332,9 @@ files:
|
|
340
332
|
- spec/lib/kb/codesake_dependency_version_check_spec.rb
|
341
333
|
- spec/lib/kb/codesake_deprecation_check_spec.rb
|
342
334
|
- spec/lib/kb/codesake_ruby_version_check_spec.rb
|
335
|
+
- spec/lib/kb/codesake_unsafe_dependency_check_spec.rb
|
343
336
|
- spec/lib/kb/codesake_version_check_spec.rb
|
337
|
+
- spec/lib/kb/dependency_check.yml
|
344
338
|
- spec/lib/kb/owasp_ror_cheatsheet_disabled.rb
|
345
339
|
- spec/lib/kb/yamilize_kb_spec.rb
|
346
340
|
- spec/spec_helper.rb
|
@@ -351,7 +345,7 @@ homepage: https://dawnscanner.org
|
|
351
345
|
licenses:
|
352
346
|
- MIT
|
353
347
|
metadata: {}
|
354
|
-
post_install_message:
|
348
|
+
post_install_message:
|
355
349
|
rdoc_options: []
|
356
350
|
require_paths:
|
357
351
|
- lib
|
@@ -366,9 +360,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
366
360
|
- !ruby/object:Gem::Version
|
367
361
|
version: 1.3.1
|
368
362
|
requirements: []
|
369
|
-
|
370
|
-
|
371
|
-
signing_key:
|
363
|
+
rubygems_version: 3.3.26
|
364
|
+
signing_key:
|
372
365
|
specification_version: 4
|
373
366
|
summary: Dawnscanner is a security source code scanner for ruby powered code. It is
|
374
367
|
crafted with love to make your sinatra, padrino and ruby on rails web applications
|
@@ -389,7 +382,9 @@ test_files:
|
|
389
382
|
- spec/lib/kb/codesake_dependency_version_check_spec.rb
|
390
383
|
- spec/lib/kb/codesake_deprecation_check_spec.rb
|
391
384
|
- spec/lib/kb/codesake_ruby_version_check_spec.rb
|
385
|
+
- spec/lib/kb/codesake_unsafe_dependency_check_spec.rb
|
392
386
|
- spec/lib/kb/codesake_version_check_spec.rb
|
387
|
+
- spec/lib/kb/dependency_check.yml
|
393
388
|
- spec/lib/kb/owasp_ror_cheatsheet_disabled.rb
|
394
389
|
- spec/lib/kb/yamilize_kb_spec.rb
|
395
390
|
- spec/spec_helper.rb
|