codesake-dawn 1.0.6 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +4 -0
- data/.travis.yml +5 -3
- data/Changelog.md +70 -4
- data/README.md +129 -95
- data/Rakefile +27 -3
- data/Roadmap.md +47 -40
- data/bin/dawn +104 -86
- data/certs/paolo_at_codesake_dot_com.pem +21 -0
- data/checksum/.placeholder +0 -0
- data/codesake-dawn.gemspec +11 -3
- data/doc/codesake-dawn.yaml.sample +26 -0
- data/lib/codesake-dawn.rb +1 -0
- data/lib/codesake/dawn/core.rb +84 -51
- data/lib/codesake/dawn/engine.rb +66 -15
- data/lib/codesake/dawn/gemfile_lock.rb +2 -2
- data/lib/codesake/dawn/kb/basic_check.rb +109 -98
- data/lib/codesake/dawn/kb/combo_check.rb +4 -3
- data/lib/codesake/dawn/kb/cve_2011_2930.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2011_3187.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2011_4319.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2011_5036.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_1098.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2012_6109.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0183.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0184.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0262.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_0263.rb +1 -1
- data/lib/codesake/dawn/kb/cve_2013_1607.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_2512.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_2513.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_2516.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_4413.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_4457.rb +1 -1
- data/lib/codesake/dawn/kb/cve_2013_4489.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_4593.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_5647.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2013_5671.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_6416.rb +1 -0
- data/lib/codesake/dawn/kb/cve_2014_0080.rb +30 -0
- data/lib/codesake/dawn/kb/dependency_check.rb +37 -13
- data/lib/codesake/dawn/kb/deprecation_check.rb +40 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb +3 -1
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/command_injection.rb +2 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/csrf.rb +3 -1
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/mass_assignment_in_model.rb +2 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb +9 -7
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/sensitive_files.rb +2 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/session_stored_in_database.rb +2 -0
- data/lib/codesake/dawn/kb/pattern_match_check.rb +16 -8
- data/lib/codesake/dawn/kb/ruby_version_check.rb +11 -11
- data/lib/codesake/dawn/kb/version_check.rb +416 -0
- data/lib/codesake/dawn/knowledge_base.rb +119 -59
- data/lib/codesake/dawn/reporter.rb +272 -0
- data/lib/codesake/dawn/utils.rb +11 -0
- data/lib/codesake/dawn/version.rb +14 -12
- data/spec/lib/dawn/codesake_knowledgebase_spec.rb +253 -160
- data/spec/lib/kb/codesake_cve_2013_0175_spec.rb +1 -1
- data/spec/lib/kb/codesake_dependency_version_check_spec.rb +21 -10
- data/spec/lib/kb/codesake_deprecation_check_spec.rb +56 -0
- data/spec/lib/kb/codesake_version_check_spec.rb +165 -0
- data/spec/lib/kb/cve_2011_2930_spec.rb +5 -6
- data/spec/lib/kb/cve_2011_5036_spec.rb +95 -0
- data/spec/lib/kb/cve_2012_6109_spec.rb +112 -0
- data/spec/lib/kb/cve_2013_0183_spec.rb +54 -0
- data/spec/lib/kb/cve_2013_0184_spec.rb +115 -0
- data/spec/lib/kb/cve_2013_0256_spec.rb +1 -8
- data/spec/lib/kb/cve_2013_0262_spec.rb +44 -0
- data/spec/lib/kb/cve_2013_1607_spec.rb +15 -0
- data/spec/lib/kb/{codesake_cve_2013_1655_spec.rb → cve_2013_1655_spec.rb} +0 -0
- data/spec/lib/kb/cve_2013_2090_spec.rb +0 -5
- data/spec/lib/kb/cve_2013_2512_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_2513_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_2516_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_4413_spec.rb +16 -0
- data/spec/lib/kb/cve_2013_4489_spec.rb +63 -0
- data/spec/lib/kb/cve_2013_4593_spec.rb +16 -0
- data/spec/lib/kb/cve_2013_5671_spec.rb +27 -0
- data/spec/lib/kb/{codesake_cve_2013_6416_spec.rb → cve_2013_6416_spec.rb} +0 -0
- data/spec/lib/kb/cve_2014_0080_spec.rb +28 -0
- data/spec/spec_helper.rb +7 -3
- data/support/bootstrap.js +2027 -0
- data/support/bootstrap.min.css +9 -0
- data/support/codesake.css +63 -0
- metadata +127 -18
- metadata.gz.sig +0 -0
data/Rakefile
CHANGED
@@ -14,16 +14,18 @@ Cucumber::Rake::Task.new(:features) do |t|
|
|
14
14
|
t.fork = false
|
15
15
|
end
|
16
16
|
|
17
|
-
RSpec::Core::RakeTask.new do |t|
|
17
|
+
RSpec::Core::RakeTask.new do |t|
|
18
18
|
t.rspec_opts = ["--color"]
|
19
19
|
end
|
20
20
|
|
21
21
|
|
22
22
|
task :default => [ :spec, :features, :kb ]
|
23
23
|
task :test => :spec
|
24
|
+
task :prepare => [:build, :'checksum:calculate', :'checksum:commit']
|
25
|
+
task :release => [:prepare]
|
24
26
|
|
25
27
|
desc "Create a new CVE test"
|
26
|
-
task :cve, :name do |t,args|
|
28
|
+
task :cve, :name do |t,args|
|
27
29
|
name = args.name
|
28
30
|
SRC_DIR = "./lib/codesake/dawn/kb/"
|
29
31
|
SPEC_DIR = "./spec/lib/kb/"
|
@@ -87,7 +89,7 @@ end
|
|
87
89
|
|
88
90
|
|
89
91
|
desc "Create a new Generic security check"
|
90
|
-
task :check, :name do |t,args|
|
92
|
+
task :check, :name do |t,args|
|
91
93
|
name = args.name
|
92
94
|
SRC_DIR = "./lib/codesake/dawn/kb/"
|
93
95
|
SPEC_DIR = "./spec/lib/kb/"
|
@@ -165,3 +167,25 @@ task :kb do
|
|
165
167
|
puts "KnowledgeBase.md file successfully generated"
|
166
168
|
|
167
169
|
end
|
170
|
+
|
171
|
+
require 'digest/sha2'
|
172
|
+
namespace :checksum do
|
173
|
+
|
174
|
+
desc 'Calculate gem checksum'
|
175
|
+
task :calculate do
|
176
|
+
system 'mkdir -p checksum > /dev/null'
|
177
|
+
built_gem_path = "pkg/codesake-dawn-#{Codesake::Dawn::VERSION}.gem"
|
178
|
+
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
|
179
|
+
checksum_path = "checksum/codesake-dawn-#{Codesake::Dawn::VERSION}.gem.sha512"
|
180
|
+
File.open(checksum_path, 'w' ) {|f| f.write(checksum) }
|
181
|
+
|
182
|
+
puts "#{checksum_path}: #{checksum}"
|
183
|
+
end
|
184
|
+
|
185
|
+
desc 'Add and commit latest checksum'
|
186
|
+
task :commit do
|
187
|
+
checksum_path = "checksum/codesake-dawn-#{Codesake::Dawn::VERSION}.gem.sha512"
|
188
|
+
system "git add #{checksum_path}"
|
189
|
+
system "git commit -v #{checksum_path} -m \"Adding #{Codesake::Dawn::VERSION} checksum to repo\""
|
190
|
+
end
|
191
|
+
end
|
data/Roadmap.md
CHANGED
@@ -7,7 +7,7 @@ frameworks.
|
|
7
7
|
|
8
8
|
This is an ongoing roadmap for the Codesake::Dawn source code review tool.
|
9
9
|
|
10
|
-
_latest update:
|
10
|
+
_latest update: Thu Jan 30 08:39:13 CET 2014_
|
11
11
|
|
12
12
|
## Version 1.1.0
|
13
13
|
|
@@ -27,6 +27,29 @@ _latest update: Fri Jan 17 08:09:29 CET 2014_
|
|
27
27
|
* CVE-2012-6109
|
28
28
|
* CVE-2011-5036
|
29
29
|
* CVE-2007-6183
|
30
|
+
* adding test for RoRCheatSheet\_2
|
31
|
+
* adding test for RoRCheatSheet\_3
|
32
|
+
* adding test for RoRCheatSheet\_5
|
33
|
+
* adding test for RoRCheatSheet\_6
|
34
|
+
* adding test for RoRCheatSheet\_9
|
35
|
+
* adding test for RoRCheatSheet\_10
|
36
|
+
* adding test for RoRCheatSheet\_11
|
37
|
+
* adding test for RoRCheatSheet\_12
|
38
|
+
* adding test for RoRCheatSheet\_13
|
39
|
+
* adding test for RoRCheatSheet\_14
|
40
|
+
* adding test for RoRCheatSheet\_15
|
41
|
+
* adding test for RoRCheatSheet\_16
|
42
|
+
* add a check against deprecated ruby / gems version. I will handle MVC gems
|
43
|
+
right now.
|
44
|
+
* Better bin/dawn script output formatting using some library like PrettyPrint
|
45
|
+
(this can involve a change in codesake-commons package). We will use tables
|
46
|
+
to create ascii organized reports.
|
47
|
+
* Create a digital signature as described [here](http://rubygems.rubyforge.org/rubygems-update/Gem/Security.html)
|
48
|
+
* bin/dawn refactoring using the new Reporting class to produce json, csv, html output
|
49
|
+
* add config file with setting (css directory, report options, ...)
|
50
|
+
|
51
|
+
## Version 1.2.0
|
52
|
+
|
30
53
|
* move is\_vulnerable\_version? and is\_vulnerable\_patchlevel? to an adhoc
|
31
54
|
class handling version comparison
|
32
55
|
* add @rubysec vulnerability database integration using rake
|
@@ -34,56 +57,40 @@ _latest update: Fri Jan 17 08:09:29 CET 2014_
|
|
34
57
|
* add a language check. It will handle a ruby script as input and a
|
35
58
|
ruby\_parser line as unsafe pattern. It will compile the ruby and look for
|
36
59
|
the unsafe pattern
|
37
|
-
*
|
38
|
-
|
39
|
-
* Improving HTML output
|
60
|
+
* Add preliminary Cross Site Scripting detection for Ruby on Rails.
|
61
|
+
* Issue #40: Support for string version modifiers
|
62
|
+
* Issue #7: Improving HTML output and let the user the capability to provide a
|
63
|
+
basic layout to customize report
|
40
64
|
* Add a --github option to Codesake::Dawn to clone a remote repository, perform
|
41
65
|
a bundle install and do a code review.
|
42
66
|
* Add support for github hooks
|
43
|
-
* Add a ruby deprecation check, accordingly to
|
67
|
+
* Add a ruby deprecation check, accordingly to
|
68
|
+
https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
|
44
69
|
* Add a severity attribute to basic check. It must be calculated automatically
|
45
70
|
on the cvss_score or it may be overriden upon check creation.
|
46
|
-
* Better bin/dawn script output formatting using some library like PrettyPrint
|
47
|
-
(this can involve a change in codesake-commons package).
|
48
71
|
|
49
|
-
## Version 1.
|
72
|
+
## Version 1.3.0
|
50
73
|
|
51
|
-
*
|
52
|
-
*
|
53
|
-
* adding test for RoRCheatSheet\_5
|
54
|
-
* adding test for RoRCheatSheet\_6
|
55
|
-
* adding test for RoRCheatSheet\_9
|
56
|
-
* adding test for RoRCheatSheet\_10
|
57
|
-
* adding test for RoRCheatSheet\_11
|
58
|
-
* adding test for RoRCheatSheet\_12
|
59
|
-
* adding test for RoRCheatSheet\_13
|
60
|
-
* adding test for RoRCheatSheet\_14
|
61
|
-
* adding test for RoRCheatSheet\_15
|
62
|
-
* adding test for RoRCheatSheet\_16
|
63
|
-
* preliminary javascript support
|
74
|
+
* Add support for ERB for in detect\_views
|
75
|
+
* Add preliminary javascript support
|
64
76
|
* adding test for CVE-2011-4969 XSS in jquery < 1.6.2
|
65
|
-
|
66
|
-
## Version 1.5.0
|
67
|
-
|
68
77
|
* add support for pure Rack applications
|
69
|
-
*
|
70
|
-
|
71
|
-
|
72
|
-
*
|
73
|
-
* detect SQLi in Padrino applications
|
74
|
-
* detect sinks for XSS in Padrino applications
|
75
|
-
* detect reflected XSS in Padrino applications
|
76
|
-
* detect stored XSS in Sinatra applications
|
77
|
-
* detect stored XSS in Padrino applications
|
78
|
-
* detect insecure direct object reference in Sinatra applications
|
79
|
-
* detect insecure direct object reference in Padrino applications
|
80
|
-
* support ERB for in detect\_views (for both Sinatra and Padrino)
|
81
|
-
* detect SQLi in Rails applications
|
82
|
-
* automatic mitigation patch generation
|
78
|
+
* Cross Site Scripting detection: it must be done for all MVC frameworks
|
79
|
+
(including Rack) and it must cover either reflected than stored attack
|
80
|
+
patterns
|
81
|
+
* Add premilinary SQL injection detection for Ruby on Rails
|
83
82
|
|
83
|
+
## Version 1.5.0
|
84
84
|
|
85
|
-
|
86
|
-
*
|
85
|
+
* Add insecure direct object reference detection for all MVC frameworks (including Rack)
|
86
|
+
* SQL Injection detection: it must be done for all MVC frameworks (including Rack)
|
87
|
+
* Add automatic mitigation patch generation
|
87
88
|
* SQLite3 integration for saving data. Each project will have its own SQLite
|
88
89
|
database containing reviews, findings and all. A table with Codesake::Dawn version it
|
89
90
|
created the database will be inserted as well
|
91
|
+
* Add support for Javascript
|
92
|
+
|
93
|
+
## Version 2.0.0
|
94
|
+
|
95
|
+
* Add support for node.js
|
96
|
+
* Add support for Go
|
data/bin/dawn
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'getoptlong'
|
4
4
|
require 'json'
|
5
|
+
require 'terminal-table'
|
6
|
+
|
7
|
+
require 'justify'
|
5
8
|
|
6
9
|
require 'codesake-commons'
|
7
10
|
require 'codesake-dawn'
|
@@ -11,62 +14,123 @@ LIST_KNOWN_FRAMEWORK = %w(rails sinatra padrino)
|
|
11
14
|
VALID_OUTPUT_FORMAT = %w(console json csv html)
|
12
15
|
|
13
16
|
$logger = Codesake::Commons::Logging.instance
|
14
|
-
$logger.helo APPNAME, Codesake::Dawn::VERSION
|
15
17
|
opts = GetoptLong.new(
|
18
|
+
# report formatting options
|
19
|
+
[ '--ascii-tabular-report', '-a', GetoptLong::NO_ARGUMENT],
|
20
|
+
[ '--json', '-j', GetoptLong::NO_ARGUMENT],
|
21
|
+
[ '--html', '-H', GetoptLong::NO_ARGUMENT],
|
22
|
+
|
23
|
+
# MVC forcing
|
16
24
|
[ '--rails', '-r', GetoptLong::NO_ARGUMENT],
|
17
25
|
[ '--sinatra', '-s', GetoptLong::NO_ARGUMENT],
|
18
26
|
[ '--padrino', '-p', GetoptLong::NO_ARGUMENT],
|
19
|
-
|
20
|
-
[ '--
|
21
|
-
[ '--list-knowledgebase', '-k', GetoptLong::OPTIONAL_ARGUMENT],
|
22
|
-
[ '--output', '-o', GetoptLong::REQUIRED_ARGUMENT],
|
23
|
-
[ '--verbose', '-V', GetoptLong::NO_ARGUMENT],
|
24
|
-
[ '--debug', '-D', GetoptLong::NO_ARGUMENT],
|
27
|
+
|
28
|
+
[ '--gem-lock', '-G', GetoptLong::REQUIRED_ARGUMENT],
|
25
29
|
[ '--count-only', '-C', GetoptLong::NO_ARGUMENT],
|
26
30
|
[ '--exit-on-warn', '-z', GetoptLong::NO_ARGUMENT],
|
31
|
+
|
32
|
+
# Disable checks by family type
|
33
|
+
[ '--disable-cve-bulletins', GetoptLong::NO_ARGUMENT],
|
34
|
+
[ '--disable-code-quality', GetoptLong::NO_ARGUMENT],
|
35
|
+
[ '--disable-code-style', GetoptLong::NO_ARGUMENT],
|
36
|
+
[ '--disable-owasp-ror-cheatsheet', GetoptLong::NO_ARGUMENT],
|
37
|
+
[ '--disable-owasp-top-10', GetoptLong::NO_ARGUMENT],
|
38
|
+
|
39
|
+
# Search knowledge base
|
40
|
+
[ '--search-knowledge-base', '-S', GetoptLong::REQUIRED_ARGUMENT],
|
41
|
+
# List stuff
|
42
|
+
[ '--list-knowledge-base', GetoptLong::NO_ARGUMENT],
|
43
|
+
[ '--list-known-framework', GetoptLong::NO_ARGUMENT],
|
44
|
+
[ '--list-known-families', GetoptLong::NO_ARGUMENT],
|
45
|
+
# please save output to file
|
46
|
+
[ '--file', '-F', GetoptLong::REQUIRED_ARGUMENT],
|
47
|
+
# specify an alternate config file
|
48
|
+
[ '--config-file', '-c', GetoptLong::REQUIRED_ARGUMENT],
|
49
|
+
|
50
|
+
# service options
|
51
|
+
[ '--verbose', '-V', GetoptLong::NO_ARGUMENT],
|
52
|
+
[ '--debug', '-D', GetoptLong::NO_ARGUMENT],
|
27
53
|
[ '--version', '-v', GetoptLong::NO_ARGUMENT],
|
28
54
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT]
|
29
55
|
)
|
56
|
+
opts.quiet=true
|
57
|
+
|
30
58
|
engine = nil
|
31
|
-
options = {:verbose=>false, :output=>"console", :count_only=>false, :dump_kb=>false, :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :debug=>false, :exit_on_warn => false}
|
32
59
|
|
33
|
-
|
60
|
+
|
61
|
+
options = Codesake::Dawn::Core.read_conf(Codesake::Dawn::Core.find_conf(true))
|
34
62
|
check = ""
|
35
63
|
guess = {:name=>"", :version=>"", :connected_gems=>[]}
|
36
64
|
|
37
|
-
|
65
|
+
begin
|
38
66
|
opts.each do |opt, val|
|
39
67
|
case opt
|
40
68
|
when '--version'
|
41
69
|
puts "#{Codesake::Dawn::VERSION} [#{Codesake::Dawn::CODENAME}]"
|
42
70
|
Kernel.exit(0)
|
71
|
+
when '--config-file'
|
72
|
+
options = Codesake::Dawn::Core.read_conf(val)
|
73
|
+
when '--disable-cve-bulletins'
|
74
|
+
options[:enabled_checks].delete(:cve_bulletin)
|
75
|
+
when '--disable-code-quality'
|
76
|
+
options[:enabled_checks].delete(:code_quality)
|
77
|
+
when '--disable-code-style'
|
78
|
+
options[:enabled_checks].delete(:code_style)
|
79
|
+
when '--disable-owasp-ror-cheatsheet'
|
80
|
+
options[:enabled_checks].delete(:owasp_ror_cheatsheet)
|
81
|
+
when '--disable-owasp-top-10'
|
82
|
+
options[:enabled_checks].delete(:owasp_top_10_1)
|
83
|
+
options[:enabled_checks].delete(:owasp_top_10_2)
|
84
|
+
options[:enabled_checks].delete(:owasp_top_10_3)
|
85
|
+
options[:enabled_checks].delete(:owasp_top_10_4)
|
86
|
+
options[:enabled_checks].delete(:owasp_top_10_5)
|
87
|
+
options[:enabled_checks].delete(:owasp_top_10_6)
|
88
|
+
options[:enabled_checks].delete(:owasp_top_10_7)
|
89
|
+
options[:enabled_checks].delete(:owasp_top_10_8)
|
90
|
+
options[:enabled_checks].delete(:owasp_top_10_9)
|
91
|
+
options[:enabled_checks].delete(:owasp_top_10_10)
|
92
|
+
when '--list-known-families'
|
93
|
+
printf "Codesake::Dawn supports following check families:\n\n"
|
94
|
+
puts Codesake::Dawn::Kb::BasicCheck.families
|
95
|
+
Kernel.exit(0)
|
96
|
+
when '--json'
|
97
|
+
options[:output] = "json"
|
98
|
+
when '--ascii-tabular-report'
|
99
|
+
options[:output] = "tabular"
|
100
|
+
when '--html'
|
101
|
+
options[:output] = "html"
|
43
102
|
when '--rails'
|
44
103
|
options[:mvc]=:rails
|
45
104
|
when '--sinatra'
|
46
105
|
options[:mvc]=:sinatra
|
47
106
|
when '--padrino'
|
48
107
|
options[:mvc]=:padrino
|
108
|
+
when '--file'
|
109
|
+
options[:filename] = val
|
49
110
|
when '--gem-lock'
|
50
111
|
options[:gemfile_scan] = true
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
112
|
+
unless val.empty?
|
113
|
+
options[:gemfile_name] = val
|
114
|
+
guess = Codesake::Dawn::Core.guess_mvc(val)
|
115
|
+
end
|
55
116
|
when '--verbose'
|
56
117
|
options[:verbose]=true
|
57
|
-
when '--output'
|
58
|
-
options[:output] = val unless VALID_OUTPUT_FORMAT.find_index(val).nil?
|
59
118
|
when '--count-only'
|
60
|
-
options[:
|
119
|
+
options[:output] = "count"
|
61
120
|
when '--debug'
|
62
121
|
options[:debug] = true
|
63
122
|
when '--exit-on-warn'
|
64
123
|
options[:exit_on_warn] = true
|
65
124
|
|
66
|
-
when '--
|
67
|
-
|
68
|
-
|
69
|
-
|
125
|
+
when '--search-knowledge-base'
|
126
|
+
found = Codesake::Dawn::KnowledgeBase.find(nil, val)
|
127
|
+
puts "#{val} found in knowledgebase." if found
|
128
|
+
puts "#{val} not found in knowledgebase" if ! found
|
129
|
+
Kernel.exit(0)
|
130
|
+
|
131
|
+
when '--list-knowledge-base'
|
132
|
+
puts Codesake::Dawn::Core.dump_knowledge_base(options[:verbose])
|
133
|
+
Kernel.exit(0)
|
70
134
|
when '--list-known-framework'
|
71
135
|
puts "Ruby MVC framework supported by #{APPNAME}:"
|
72
136
|
LIST_KNOWN_FRAMEWORK.each do |mvc|
|
@@ -77,23 +141,21 @@ opts.each do |opt, val|
|
|
77
141
|
Kernel.exit(Codesake::Dawn::Core.help)
|
78
142
|
end
|
79
143
|
end
|
144
|
+
rescue GetoptLong::InvalidOption => e
|
80
145
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
found = Codesake::Dawn::KnowledgeBase.find(nil, check)
|
85
|
-
puts "#{check} found in knowledgebase." if found
|
86
|
-
puts "#{check} not found in knowledgebase" if ! found
|
87
|
-
end
|
88
|
-
|
89
|
-
Kernel.exit(0)
|
146
|
+
$logger.helo APPNAME, Codesake::Dawn::VERSION
|
147
|
+
$logger.err e.message
|
148
|
+
Kernel.exit(Codesake::Dawn::Core.help)
|
90
149
|
end
|
91
150
|
|
92
151
|
target=ARGV.shift
|
93
152
|
|
153
|
+
$logger.helo APPNAME, Codesake::Dawn::VERSION
|
154
|
+
trap("INT") { $logger.die('[INTERRUPTED]') }
|
94
155
|
$logger.die("missing target") if target.nil? && options[:gemfile_name].nil?
|
95
156
|
$logger.die("invalid directory (#{target})") if options[:gemfile_name].nil? &&! Codesake::Dawn::Core.is_good_target?(target)
|
96
157
|
$logger.die("if scanning Gemfile.lock file you must not force target MVC using one from -r, -s or -p flag") if ! options[:mvc].empty? && options[:gemfile_scan]
|
158
|
+
$logger.log("security check enabled: #{options[:enabled_checks]}") if options[:debug]
|
97
159
|
|
98
160
|
|
99
161
|
## MVC auto detect.
|
@@ -105,13 +167,13 @@ unless options[:gemfile_scan]
|
|
105
167
|
rescue ArgumentError => e
|
106
168
|
$logger.die(e.message)
|
107
169
|
end
|
170
|
+
else
|
171
|
+
engine = Codesake::Dawn::GemfileLock.new(target, options[:gemfile_name], guess) # if options[:gemfile_scan]
|
108
172
|
end
|
109
173
|
|
110
|
-
|
111
174
|
engine = Codesake::Dawn::Rails.new(target) if options[:mvc] == :rails && options[:gemfile_scan].nil?
|
112
175
|
engine = Codesake::Dawn::Sinatra.new(target) if options[:mvc] == :sinatra && options[:gemfile_scan].nil?
|
113
176
|
engine = Codesake::Dawn::Padrino.new(target) if options[:mvc] == :padrino && options[:gemfile_scan].nil?
|
114
|
-
engine = Codesake::Dawn::GemfileLock.new(target, options[:gemfile_name], options[:debug], guess) if options[:gemfile_scan]
|
115
177
|
|
116
178
|
$logger.die("ruby framework auto detect failed. Please force if rails, sinatra or padrino with -r, -s or -p flags") if engine.nil?
|
117
179
|
|
@@ -123,67 +185,23 @@ if options[:exit_on_warn]
|
|
123
185
|
end
|
124
186
|
end
|
125
187
|
|
126
|
-
if options[:
|
127
|
-
|
128
|
-
|
129
|
-
puts (ret)? engine.vulnerabilities.count : "-1" unless options[:output] == "json"
|
130
|
-
puts (ret)? {:status=>"OK", :vulnerabilities_count=>engine.count_vulnerabilities}.to_json : {:status=>"KO", :vulnerabilities_count=>-1}.to_json
|
131
|
-
Kernel.exit(0)
|
132
|
-
end
|
133
|
-
|
134
|
-
if options[:output] == "json"
|
135
|
-
puts Codesake::Dawn::Core.output_json_run(target, engine)
|
136
|
-
Kernel.exit(0)
|
188
|
+
if options[:debug]
|
189
|
+
$logger.warn "putting engine in debug mode"
|
190
|
+
engine.debug = true
|
137
191
|
end
|
138
192
|
|
139
193
|
$logger.die "missing target framework option" if engine.nil?
|
140
|
-
|
141
|
-
engine.load_knowledge_base
|
142
194
|
$logger.warn "this is a development Codesake::Dawn version" if Codesake::Dawn::RELEASE == "(development)"
|
143
|
-
|
144
195
|
$logger.die "nothing to do on #{target}" if ! options[:gemfile_scan] && ! engine.can_apply?
|
145
196
|
|
146
|
-
|
147
|
-
|
148
|
-
$logger.log "#{engine.force} v#{engine.get_mvc_version} detected" if engine.name == "Gemfile.lock"
|
149
|
-
$logger.log "applying all security checks"
|
150
|
-
if engine.apply_all
|
151
|
-
$logger.log "#{engine.applied_checks} security checks applied - #{engine.skipped_checks} security checks skipped"
|
152
|
-
else
|
153
|
-
$logger.err "no security checks in the knowledge base"
|
154
|
-
end
|
155
|
-
|
156
|
-
if engine.count_vulnerabilities != 0
|
157
|
-
$logger.log "#{engine.count_vulnerabilities} vulnerabilities found"
|
158
|
-
engine.vulnerabilities.each do |vuln|
|
159
|
-
$logger.err "#{vuln[:name]} check failed"
|
160
|
-
$logger.log "Description: #{vuln[:message]}"
|
161
|
-
$logger.log "Solution: #{vuln[:remediation]}"
|
162
|
-
$logger.log "Evidence:"
|
163
|
-
vuln[:evidences].each do |evidence|
|
164
|
-
$logger.log "\t#{evidence}"
|
165
|
-
end
|
166
|
-
end
|
167
|
-
if engine.has_reflected_xss?
|
168
|
-
$logger.log "#{engine.reflected_xss.count} reflected XSS found"
|
169
|
-
engine.reflected_xss.each do |vuln|
|
170
|
-
$logger.log "request parameter \"#{vuln[:sink_source]}\" is used without escaping in #{vuln[:sink_view]}. It was read here: #{vuln[:sink_file]}@#{vuln[:sink_line]}"
|
171
|
-
$logger.err "evidence: #{vuln[:sink_evidence]}"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
else
|
176
|
-
$logger.ok "no vulnerabilities found."
|
177
|
-
end
|
197
|
+
engine.load_knowledge_base(options[:enabled_checks])
|
198
|
+
ret = engine.apply_all
|
178
199
|
|
179
|
-
if
|
180
|
-
|
181
|
-
engine.
|
182
|
-
|
183
|
-
vuln[:evidences].each do |evidence|
|
184
|
-
$logger.err evidence
|
185
|
-
end
|
186
|
-
end
|
200
|
+
if options[:output] == "count"
|
201
|
+
puts (ret)? engine.vulnerabilities.count : "-1" unless options[:output] == "json"
|
202
|
+
puts (ret)? {:status=>"OK", :vulnerabilities_count=>engine.count_vulnerabilities}.to_json : {:status=>"KO", :vulnerabilities_count=>-1}.to_json
|
203
|
+
Kernel.exit(0)
|
187
204
|
end
|
188
205
|
|
206
|
+
Codesake::Dawn::Reporter.new({:engine=>engine, :apply_all_code=>ret, :format=>options[:output].to_sym, :filename=>options[:filename]}).report
|
189
207
|
$logger.bye
|