dawnscanner 2.0.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd4bbcfe33df2cf77a454baf00629653a49480c6606e8ed20c06ded4313c3dfb
4
- data.tar.gz: 0a0e41109d47d2f634f2ecafc1b68c1b2596156054594c6221a9ddabd04dbc23
3
+ metadata.gz: fbb231ba7ae0542ffa5a4df93bf1957ca989e4073129f8c57894b2f6d5813973
4
+ data.tar.gz: 833442b38e833db16ee550a56e26ce67b69cc77ee4ff2b69389bd1dab7ff16b3
5
5
  SHA512:
6
- metadata.gz: 40fb06e99f9cd958a0b5e1c95b52593d250a7aabb6cfd6623cb82561a88b250f1815a7ac6b81a1c4a9a1c2c3b5781d59225070adb0a776b31d0377efd33e7cc7
7
- data.tar.gz: d1a37d012779435d7d8ef91161911126bdf3e0fcccb28ad113276a3036bf2cb6590d32757cccb240a845979e7667f2f8045f24a261bd8dcacabef6a81dbe0534
6
+ metadata.gz: 157a7aaf188e55b35027cae52ae7f7a71146d2b490ab5d31b8eaf3dcfc29a10de0dc3ef646e0d9b8f30330ec3b73412df62bdb4467233046b92a98f2ba4bb81a
7
+ data.tar.gz: 012e8a07b7d8bdde1947b8c0ccd6fee4bd31336c72481934ec74d4f252847fb26a0bcbab60550c2221d9716d2e51bdefeff140425c99a82e7af4df5e15a7b074
data/Changelog.md CHANGED
@@ -5,9 +5,21 @@ 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 29 mar 2023, 18:32:56, CEST_
8
+ _latest update: fri 14 apr 2023, 16:36:56, CEST_
9
9
 
10
- ## Version 2.0.0
10
+ ## Version 2.1.1 (2023-04-14)
11
+
12
+ * Issue #252 fix was uncomplete.
13
+
14
+ ## Version 2.1.0 (2023-04-13)
15
+
16
+ * BasicCheck: added an attribute do flag as vulnerable a dependency gem only if
17
+ it matches the name, overriding the version. It will be used in dawn kb list
18
+ command, when the user won't enter the version information.
19
+ * Added the "list" subcommand to "kb". It can be used to fetch from the
20
+ knowledge base all CVEs affecting a particular gem.
21
+
22
+ ## Version 2.0.0 (2023-04-13)
11
23
 
12
24
  * New knowledge base, YAML based and distributed separately from the ruby gem.
13
25
  * New CLI based on Thor library. Please read README.md file to know how to
@@ -308,7 +320,7 @@ _latest update: mer 29 mar 2023, 18:32:56, CEST_
308
320
 
309
321
  * Adding a check for OSVDB-108569: information disclosure in backup_checksum
310
322
  gem (issue #69)
311
- * Fix issue #74. Now BasicChack has its own cve, osvdb attributes and a rake
323
+ * Fix issue #74. Now BasicCheck has its own cve, osvdb attributes and a rake
312
324
  task will perform a sanity check if those values have been initialized
313
325
  * Fix issue #62 about codesake-dawn config filename
314
326
  * Adding a check for CVE-2013-2105: HTML injection in show_in_browser rubygem
data/README.md CHANGED
@@ -100,11 +100,12 @@ being analyzed.
100
100
  Is it possible, with the kb subcommand, to query the knowledge base.
101
101
 
102
102
  ```
103
- dawn kb find # Searches the knowledge base for a given security test
104
- dawn kb help [COMMAND] # Describe subcommands or one specific subcommand
105
- dawn kb lint # Checks knowledge base content for correcteness
106
- dawn kb status # Checks the status of the knowledge base
107
- dawn kb unpack # Unpacks security checks in KB library path
103
+ dawn kb find # Searches the knowledge base for a given vulnerability
104
+ dawn kb help [COMMAND] # Describe subcommands or one specific subcommand
105
+ dawn kb lint # Checks knowledge base content for correcteness
106
+ dawn kb list gem_name[gem_version] # List all security issues affecting a gem passed as argument (the version string is optional).
107
+ dawn kb status # Checks the status of the knowledge base
108
+ dawn kb unpack # Unpacks security checks in KB library path
108
109
  ```
109
110
 
110
111
  ## Useful links
data/Rakefile CHANGED
@@ -160,35 +160,35 @@ namespace :rubysec do
160
160
  end
161
161
 
162
162
  def __kb_pack
163
- if Dir.exists? "#{YAML_KB}/bulletin"
163
+ if Dir.exist? "#{YAML_KB}/bulletin"
164
164
  system "tar cfvz #{YAML_KB}/bulletin.tar.gz -C #{YAML_KB} bulletin"
165
165
  system "rm -rf #{YAML_KB}/bulletin"
166
166
  system "shasum -a 256 #{YAML_KB}/bulletin.tar.gz > #{YAML_KB}/bulletin.tar.gz.sig"
167
167
  end
168
168
 
169
- if Dir.exists? "#{YAML_KB}/generic_check"
169
+ if Dir.exist? "#{YAML_KB}/generic_check"
170
170
  system "tar cfvz #{YAML_KB}/generic_check.tar.gz -C #{YAML_KB} generic_check"
171
171
  system "rm -rf #{YAML_KB}/generic_check"
172
172
  system "shasum -a 256 #{YAML_KB}/generic_check.tar.gz > #{YAML_KB}/generic_check.tar.gz.sig"
173
173
  end
174
174
 
175
- if Dir.exists? "#{YAML_KB}/owasp_ror_cheatsheet"
175
+ if Dir.exist? "#{YAML_KB}/owasp_ror_cheatsheet"
176
176
  system "tar cfvz #{YAML_KB}/owasp_ror_cheatsheet.tar.gz -C #{YAML_KB} owasp_ror_cheatsheet"
177
177
  system "rm -rf #{YAML_KB}/owasp_ror_cheatsheet"
178
178
  system "shasum -a 256 #{YAML_KB}/owasp_ror_cheatsheet.tar.gz > #{YAML_KB}/owasp_ror_cheatsheet.tar.gz.sig"
179
179
  end
180
180
 
181
- if Dir.exists? "#{YAML_KB}/code_style"
181
+ if Dir.exist? "#{YAML_KB}/code_style"
182
182
  system "tar cfvz #{YAML_KB}/code_style.tar.gz -C #{YAML_KB} code_style"
183
183
  system "rm -rf #{YAML_KB}/code_style"
184
184
  system "shasum -a 256 #{YAML_KB}/code_style.tar.gz > #{YAML_KB}/code_style.tar.gz.sig"
185
185
  end
186
- if Dir.exists? "#{YAML_KB}/code_quality"
186
+ if Dir.exist? "#{YAML_KB}/code_quality"
187
187
  system "tar cfvz #{YAML_KB}/code_quality.tar.gz -C #{YAML_KB} code_quality"
188
188
  system "rm -rf #{YAML_KB}/code_quality"
189
189
  system "shasum -a 256 #{YAML_KB}/code_quality.tar.gz > #{YAML_KB}/code_quality.tar.gz.sig"
190
190
  end
191
- if Dir.exists? "#{YAML_KB}/owasp_top_10"
191
+ if Dir.exist? "#{YAML_KB}/owasp_top_10"
192
192
  system "tar cfvz #{YAML_KB}/owasp_top_10.tar.gz -C #{YAML_KB} owasp_top_10"
193
193
  system "rm -rf #{YAML_KB}/owasp_top_10"
194
194
  system "shasum -a 256 #{YAML_KB}/owasp_top_10.tar.gz > #{YAML_KB}/owasp_top_10.tar.gz.sig"
data/VERSION CHANGED
@@ -1,3 +1,3 @@
1
1
  # I removed codenames :-)
2
2
  # Code review is fun
3
- 2.0.0
3
+ 2.1.1
@@ -0,0 +1 @@
1
+ 85ef0190d8b51e779c42122f673bb6dd495a8d9f
@@ -0,0 +1 @@
1
+ e463c7c3f54c900752f3b9be47da3f311cddd941
data/dawnscanner.gemspec CHANGED
@@ -5,17 +5,17 @@ Gem::Specification.new do |gem|
5
5
  gem.name = "dawnscanner"
6
6
  gem.version = Dawn::VERSION
7
7
  gem.authors = ["Paolo Perego"]
8
- gem.email = ["paolo@dawnscanner.org"]
9
- gem.description = %q{Dawnscanner is a security source code scanner for ruby powered code. It is especially designed for web applications, but it works also with general purpose ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra; it provides more than 150 security checks with their own mitigation suggestion.}
10
- gem.summary = %q{Dawnscanner is a security source code scanner for ruby powered code. It is crafted with love to make your sinatra, padrino and ruby on rails web applications secure.}
11
- gem.homepage = "https://dawnscanner.org"
8
+ gem.email = ["paolo@armoredcode.com"]
9
+ gem.description = %q{dawn is a security source code scanner for ruby powered code. It is especially designed for web applications, but it works also with general purpose ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra; it provides more than 680 security checks with their own mitigation suggestion.}
10
+ gem.summary = %q{dawn is a security source code scanner for ruby powered code. It is crafted with love to make your sinatra, padrino and ruby on rails web applications secure.}
11
+ gem.homepage = "https://github.com/thesp0nge/dawnscanner"
12
12
  gem.files = `git ls-files`.split($/)
13
13
  gem.license = "MIT"
14
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.require_paths = ["lib"]
17
17
 
18
- gem.required_ruby_version = '>= 2.3.0'
18
+ gem.required_ruby_version = '>= 3.0.0'
19
19
 
20
20
  gem.add_dependency 'cvss'
21
21
  gem.add_dependency 'haml'
@@ -1,19 +1,18 @@
1
1
  Given /^the generic project "(.*?)" doesn't exist$/ do |file|
2
- FileUtils.rm(file) if File.exists?(file)
2
+ FileUtils.rm(file) if File.exist?(file)
3
3
  end
4
4
 
5
5
  Given /^the hello world rails project does exist$/ do
6
6
  system("rm -rf /tmp/hello_world_3.2.13")
7
- system("cp -a ./spec/support/hello_world_3.2.13 /tmp")
7
+ system("cp -a ./spec/support/hello_world_3.2.13 /tmp")
8
8
  end
9
9
 
10
10
  Given /^a safe sinatra application exists$/ do
11
11
  system("rm -rf /tmp/sinatra-safe")
12
- system("cp -a ./spec/support/sinatra-safe /tmp")
12
+ system("cp -a ./spec/support/sinatra-safe /tmp")
13
13
  end
14
14
 
15
15
  Given /^a vulnerable sinatra application exists$/ do
16
16
  system("rm -rf /tmp/sinatra-vulnerable")
17
- system("cp -a ./spec/support/sinatra-vulnerable /tmp")
17
+ system("cp -a ./spec/support/sinatra-vulnerable /tmp")
18
18
  end
19
-
@@ -6,21 +6,34 @@ module Dawn
6
6
  # This class is responsible for the "dawn kb" command and related
7
7
  # subcommands.
8
8
  class Kb < Thor
9
- package_name "dawnscanner"
10
- desc "find", "Searches the knowledge base for a given security test"
9
+ package_name "dawn"
10
+ class_option :verbose, :type=>:boolean
11
+ class_option :debug, :type=>:boolean
12
+
13
+ no_commands{
14
+ def init_globals
15
+ $debug = true if options[:debug]
16
+ $verbose = true if options[:verbose]
17
+ end
18
+ }
19
+
20
+ desc "find", "Searches the knowledge base for a given vulnerability"
11
21
  def find(string)
22
+ init_globals
12
23
  kb = Dawn::KnowledgeBase.instance
13
24
  kb.find(string)
14
25
  end
15
26
 
16
27
  desc "lint", "Checks knowledge base content for correcteness"
17
28
  def lint
29
+ init_globals
18
30
  kb = Dawn::KnowledgeBase.instance
19
31
  kb.load(true)
20
32
  end
21
33
 
22
34
  desc "unpack", "Unpacks security checks in KB library path"
23
35
  def unpack
36
+ init_globals
24
37
  $logger.helo APPNAME, Dawn::VERSION
25
38
  kb = Dawn::KnowledgeBase.instance
26
39
  kb.unpack
@@ -30,6 +43,7 @@ module Dawn
30
43
 
31
44
  desc "status", "Checks the status of the knowledge base"
32
45
  def status
46
+ init_globals
33
47
  $logger.helo APPNAME, Dawn::VERSION
34
48
  Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
35
49
  kb = Dawn::KnowledgeBase.instance
@@ -44,10 +58,29 @@ module Dawn
44
58
  $logger.bye
45
59
  Kernel.exit(0)
46
60
  end
61
+
62
+ desc "list gem_name[gem_version]", "List all security issues affecting a gem passed as argument (the version string is optional)."
63
+ def list(gem_name, gem_version=nil)
64
+ init_globals
65
+ to_check="#{gem_name}"
66
+ to_check += ":#{gem_version}" unless gem_version.nil?
67
+
68
+ Dawn::KnowledgeBase.enabled_checks=[:bulletin]
69
+ kb = Dawn::KnowledgeBase.instance
70
+ kb.load
71
+ if kb.security_checks.empty?
72
+ $logger.error(kb.error)
73
+ end
74
+ issues = kb.find_issues_by_gem(to_check)
75
+
76
+ issues.each do |issue|
77
+ puts "#{issue.name} "
78
+ end
79
+ end
47
80
  end
48
81
 
49
82
  class DawnCli < Thor
50
- package_name "dawnscanner"
83
+ package_name "dawn"
51
84
  class_option :verbose, :type=>:boolean
52
85
  class_option :debug, :type=>:boolean
53
86
 
@@ -78,6 +78,13 @@ module Dawn
78
78
  # + :none
79
79
  attr_accessor :priority
80
80
 
81
+ # Introduced in 2.1.0
82
+ # It allows a security check to be marked as positive (vulnerable), only
83
+ # if it matches the dependency gem name, ignoring the version.
84
+ #
85
+ # Only used in DEPENDENCY and UNSAFE_DEPENDENCY checks
86
+ attr_accessor :please_ignore_dep_version
87
+
81
88
  def initialize(options={})
82
89
  @applies = []
83
90
  @ruby_version = ""
@@ -114,6 +121,8 @@ module Dawn
114
121
  @priority = options[:priority] unless options[:priority].nil?
115
122
  @check_family = options[:check_family] unless options[:check_family].nil?
116
123
 
124
+ @please_ignore_dep_version = false
125
+
117
126
  # FIXME.20140325
118
127
  #
119
128
  # I don't want to manually fix 150+ ruby files to add something I can
@@ -31,10 +31,9 @@ module Dawn
31
31
  @dependencies.each do |dep|
32
32
  unless @vulnerable_version_array.nil? or @vulnerable_version_array.empty?
33
33
  if dep[:name] == @vulnerable_version_array[0][:name]
34
- debug_me("DEP VERSION #{dep[:version]}")
35
- debug_me("VULN_VER #{@vulnerable_version_array[0][:version]}")
36
- return false if @vulnerable_version_array[0][:version].nil? or @vulnerable_version_array[0][:version].empty?
37
- return true if @vulnerable_version_array[0][:version].include? dep[:version]
34
+ return true if @please_ignore_dep_version
35
+ return false if @vulnerable_version_array[0][:version].nil? or @vulnerable_version_array[0][:version].empty?
36
+ return true if @vulnerable_version_array[0][:version].include? dep[:version]
38
37
  end
39
38
  end
40
39
  end
@@ -122,6 +122,39 @@ module Dawn
122
122
 
123
123
  def find(name)
124
124
  debug_me "I'm asked to find #{name}"
125
+ debug_me "Please implement find command"
126
+ end
127
+
128
+ # Find all security issues affecting the gem passed as argument.
129
+ # The gem parameter can contains also the version number, separated by a
130
+ # ':'
131
+ #
132
+ # == Parameters:
133
+ # string::
134
+ # A string containing the gem name, and eventually the version, to search
135
+ # for vulnerabilities.
136
+ # e.g.
137
+ # $ dawn kb list sinatra => returns all bulletins affecting sinatra gem
138
+ # $ dawn kb list sinatra 2.0.0 => return all bulletins affecting
139
+ # sinatra gem version 2.0.0
140
+ #
141
+ # == Returns:
142
+ # An array with all the vulnerabilities affecting the gem (or the
143
+ # particular gem version if provided).
144
+ def find_issues_by_gem(string = "")
145
+ issues = []
146
+ @security_checks.each do |check|
147
+ if check.kind == Dawn::KnowledgeBase::DEPENDENCY_CHECK or check.kind == Dawn::KnowledgeBase::UNSAFE_DEPENDENCY_CHECK
148
+ debug_me "applying check #{check.name}"
149
+ name = string.split(':')[0]
150
+ version = string.split(':')[1]
151
+ check.please_ignore_dep_version = true if version.nil?
152
+ check.dependencies = [{:name=>name, :version=>version}]
153
+ issues << check if check.vuln?
154
+ end
155
+ end
156
+ debug_me "#{issues}"
157
+ return issues
125
158
  end
126
159
 
127
160
  def unpack
@@ -187,6 +220,10 @@ module Dawn
187
220
  good =0
188
221
  invalid =0
189
222
 
223
+ unless @security_checks.nil?
224
+ debug_me("KB was previously loaded")
225
+ return @security_checks
226
+ end
190
227
  @security_checks = []
191
228
  # $path = File.join(Dir.pwd, "db")
192
229
 
@@ -207,7 +244,7 @@ module Dawn
207
244
  # Please note that if we enter in this branch, it means someone
208
245
  # tampered the KB between the previous __valid? check and this point.
209
246
  # Of course this is a very rare situation, but we must handle it.
210
- unless Dir.exists?(dir)
247
+ unless Dir.exist?(dir)
211
248
  $logger.warn "Missing check directory #{dir}"
212
249
  else
213
250
  Dir.glob(dir+"/**/*.yml").each do |f|
@@ -274,12 +311,12 @@ module Dawn
274
311
 
275
312
  lines = ""
276
313
 
277
- unless File.exists?(File.join(@path, "kb.yaml"))
314
+ unless File.exist?(File.join(@path, "kb.yaml"))
278
315
  $logger.error "Missing kb.yaml in #{path}. Giving up"
279
316
  return false
280
317
  end
281
318
 
282
- unless File.exists?(File.join(@path, "kb.yaml.sig"))
319
+ unless File.exist?(File.join(@path, "kb.yaml.sig"))
283
320
  $logger.error "Missing kb.yaml signature in #{path}. Giving up"
284
321
  return false
285
322
  end
@@ -306,7 +343,7 @@ module Dawn
306
343
  # local DB path
307
344
  def __packed?
308
345
  FILES.each do |fn|
309
- return true if fn.end_with? 'tar.gz' and File.exists?(File.join(@path, fn))
346
+ return true if fn.end_with? 'tar.gz' and File.exist?(File.join(@path, fn))
310
347
  end
311
348
  return false
312
349
  end
data/lib/dawn/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Dawn
2
- VERSION = "2.0.0"
3
- RELEASE = "20230413"
4
- BUILD = "13"
5
- COMMIT = "g23e6a59"
2
+ VERSION = "2.1.1"
3
+ RELEASE = "20230414"
4
+ BUILD = "1"
5
+ COMMIT = "gbb3ea6d"
6
6
  end
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.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Perego
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cvss
@@ -220,13 +220,12 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
- description: Dawnscanner is a security source code scanner for ruby powered code.
224
- It is especially designed for web applications, but it works also with general purpose
225
- ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino
226
- and sinatra; it provides more than 150 security checks with their own mitigation
227
- suggestion.
223
+ description: dawn is a security source code scanner for ruby powered code. It is especially
224
+ designed for web applications, but it works also with general purpose ruby scripts.
225
+ Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra;
226
+ it provides more than 680 security checks with their own mitigation suggestion.
228
227
  email:
229
- - paolo@dawnscanner.org
228
+ - paolo@armoredcode.com
230
229
  executables:
231
230
  - dawn
232
231
  extensions: []
@@ -273,10 +272,12 @@ files:
273
272
  - checksum/dawnscanner-1.6.6.gem.sha1
274
273
  - checksum/dawnscanner-1.6.7.gem.sha1
275
274
  - checksum/dawnscanner-1.6.8.gem.sha1
275
+ - checksum/dawnscanner-2.0.0.gem.sha1
276
276
  - checksum/dawnscanner-2.0.0.rc1.gem.sha1
277
277
  - checksum/dawnscanner-2.0.0.rc2.gem.sha1
278
278
  - checksum/dawnscanner-2.0.0.rc3.gem.sha1
279
279
  - checksum/dawnscanner-2.0.0.rc5.gem.sha1
280
+ - checksum/dawnscanner-2.1.0.gem.sha1
280
281
  - code_of_conduct.md
281
282
  - dawnscanner.gemspec
282
283
  - doc/change.sh
@@ -342,7 +343,7 @@ files:
342
343
  - support/bootstrap.js
343
344
  - support/bootstrap.min.css
344
345
  - support/codesake.css
345
- homepage: https://dawnscanner.org
346
+ homepage: https://github.com/thesp0nge/dawnscanner
346
347
  licenses:
347
348
  - MIT
348
349
  metadata: {}
@@ -354,7 +355,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
354
355
  requirements:
355
356
  - - ">="
356
357
  - !ruby/object:Gem::Version
357
- version: 2.3.0
358
+ version: 3.0.0
358
359
  required_rubygems_version: !ruby/object:Gem::Requirement
359
360
  requirements:
360
361
  - - ">="
@@ -364,9 +365,8 @@ requirements: []
364
365
  rubygems_version: 3.3.26
365
366
  signing_key:
366
367
  specification_version: 4
367
- summary: Dawnscanner is a security source code scanner for ruby powered code. It is
368
- crafted with love to make your sinatra, padrino and ruby on rails web applications
369
- secure.
368
+ summary: dawn is a security source code scanner for ruby powered code. It is crafted
369
+ with love to make your sinatra, padrino and ruby on rails web applications secure.
370
370
  test_files:
371
371
  - features/dawn_complains_about_an_incorrect_command_line.feature.disabled
372
372
  - features/dawn_scan_a_secure_sinatra_app.feature.disabled