codesake-dawn 1.0.0.rc2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/Changelog.md +36 -5
  4. data/KnowledgeBase.md +153 -0
  5. data/README.md +36 -13
  6. data/Rakefile +21 -3
  7. data/Roadmap.md +22 -22
  8. data/codesake-dawn.gemspec +3 -3
  9. data/doc/dawn_1_0_announcement.md +40 -0
  10. data/lib/codesake/dawn/kb/basic_check.rb +42 -2
  11. data/lib/codesake/dawn/kb/cve_2012_1098.rb +31 -0
  12. data/lib/codesake/dawn/kb/cve_2012_2139.rb +28 -0
  13. data/lib/codesake/dawn/kb/cve_2012_2671.rb +30 -0
  14. data/lib/codesake/dawn/kb/cve_2012_6134.rb +1 -1
  15. data/lib/codesake/dawn/kb/cve_2013_0162.rb +30 -0
  16. data/lib/codesake/dawn/kb/cve_2013_0263.rb +3 -4
  17. data/lib/codesake/dawn/kb/cve_2013_1756.rb +28 -0
  18. data/lib/codesake/dawn/kb/cve_2013_4457.rb +1 -0
  19. data/lib/codesake/dawn/kb/dependency_check.rb +4 -0
  20. data/lib/codesake/dawn/kb/owasp_ror_cheatsheet.rb +2 -0
  21. data/lib/codesake/dawn/kb/pattern_match_check.rb +17 -1
  22. data/lib/codesake/dawn/knowledge_base.rb +10 -0
  23. data/lib/codesake/dawn/version.rb +8 -5
  24. data/spec/lib/dawn/codesake_knowledgebase_spec.rb +25 -0
  25. data/spec/lib/kb/codesake_cve_2013_4457_spec.rb +1 -0
  26. data/spec/lib/kb/codesake_dependency_version_check_spec.rb +65 -0
  27. data/spec/lib/kb/cve_2011_2705_spec.rb +28 -1
  28. data/spec/lib/kb/cve_2011_2930_spec.rb +25 -1
  29. data/spec/lib/kb/cve_2011_3009_spec.rb +18 -1
  30. data/spec/lib/kb/cve_2011_3187_spec.rb +17 -1
  31. data/spec/lib/kb/cve_2011_4319_spec.rb +37 -1
  32. data/spec/lib/kb/cve_2012_1098_spec.rb +36 -0
  33. data/spec/lib/kb/cve_2012_2139_spec.rb +20 -0
  34. data/spec/lib/kb/cve_2012_2671_spec.rb +23 -0
  35. data/spec/lib/kb/cve_2013_0162_spec.rb +23 -0
  36. data/spec/lib/kb/cve_2013_0256_spec.rb +34 -1
  37. data/spec/lib/kb/cve_2013_0263_spec.rb +4 -1
  38. data/spec/lib/kb/cve_2013_1756_spec.rb +23 -0
  39. data/spec/lib/kb/cve_2013_2090_spec.rb +13 -1
  40. data/spec/lib/kb/cve_2013_2119_spec.rb +20 -1
  41. data/spec/lib/kb/cve_2013_5647_spec.rb +12 -1
  42. data/spec/lib/kb/cve_2013_6459_spec.rb +12 -5
  43. data/spec/lib/kb/cve_2013_7086_spec.rb +1 -1
  44. metadata +28 -95
  45. data/spec/lib/kb/cve_2004_0983_spec.rb +0 -8
  46. data/spec/lib/kb/cve_2005_1992_spec.rb +0 -8
  47. data/spec/lib/kb/cve_2005_2337_spec.rb +0 -8
  48. data/spec/lib/kb/cve_2006_1931_spec.rb +0 -8
  49. data/spec/lib/kb/cve_2006_2582_spec.rb +0 -8
  50. data/spec/lib/kb/cve_2006_3694_spec.rb +0 -8
  51. data/spec/lib/kb/cve_2006_4112_spec.rb +0 -8
  52. data/spec/lib/kb/cve_2006_5467_spec.rb +0 -8
  53. data/spec/lib/kb/cve_2006_6303_spec.rb +0 -8
  54. data/spec/lib/kb/cve_2006_6852_spec.rb +0 -8
  55. data/spec/lib/kb/cve_2006_6979_spec.rb +0 -8
  56. data/spec/lib/kb/cve_2007_0469_spec.rb +0 -8
  57. data/spec/lib/kb/cve_2007_5162_spec.rb +0 -8
  58. data/spec/lib/kb/cve_2007_5379_spec.rb +0 -8
  59. data/spec/lib/kb/cve_2007_5380_spec.rb +0 -8
  60. data/spec/lib/kb/cve_2007_5770_spec.rb +0 -8
  61. data/spec/lib/kb/cve_2007_6077_spec.rb +0 -8
  62. data/spec/lib/kb/cve_2007_6612_spec.rb +0 -8
  63. data/spec/lib/kb/cve_2008_1145_spec.rb +0 -8
  64. data/spec/lib/kb/cve_2008_1891_spec.rb +0 -8
  65. data/spec/lib/kb/cve_2008_2376_spec.rb +0 -8
  66. data/spec/lib/kb/cve_2008_2662_spec.rb +0 -8
  67. data/spec/lib/kb/cve_2008_2663_spec.rb +0 -8
  68. data/spec/lib/kb/cve_2008_2664_spec.rb +0 -8
  69. data/spec/lib/kb/cve_2008_2725_spec.rb +0 -8
  70. data/spec/lib/kb/cve_2008_3655_spec.rb +0 -8
  71. data/spec/lib/kb/cve_2008_3657_spec.rb +0 -8
  72. data/spec/lib/kb/cve_2008_3790_spec.rb +0 -8
  73. data/spec/lib/kb/cve_2008_3905_spec.rb +0 -8
  74. data/spec/lib/kb/cve_2008_4094_spec.rb +0 -8
  75. data/spec/lib/kb/cve_2008_4310_spec.rb +0 -8
  76. data/spec/lib/kb/cve_2008_5189_spec.rb +0 -8
  77. data/spec/lib/kb/cve_2008_7248_spec.rb +0 -8
  78. data/spec/lib/kb/cve_2009_4078_spec.rb +0 -8
  79. data/spec/lib/kb/cve_2009_4124_spec.rb +0 -8
  80. data/spec/lib/kb/cve_2009_4214_spec.rb +0 -8
  81. data/spec/lib/kb/cve_2010_2489_spec.rb +0 -8
  82. data/spec/lib/kb/cve_2010_3933_spec.rb +0 -8
  83. data/spec/lib/kb/cve_2011_0188_spec.rb +0 -8
  84. data/spec/lib/kb/cve_2011_0739_spec.rb +0 -8
  85. data/spec/lib/kb/cve_2011_1004_spec.rb +0 -8
  86. data/spec/lib/kb/cve_2011_1005_spec.rb +0 -8
  87. data/spec/lib/kb/cve_2011_2686_spec.rb +0 -8
@@ -14,6 +14,14 @@ module Codesake
14
14
  # if pattern attack is nor present.
15
15
  attr_reader :negative_search
16
16
 
17
+ EXCLUSION_LIST = [
18
+ "tags",
19
+ "vendor/bundle",
20
+ "features",
21
+ "specs",
22
+ "test"
23
+ ]
24
+
17
25
  def initialize(options={})
18
26
  super(options)
19
27
  @attack_pattern = options[:attack_pattern]
@@ -23,12 +31,20 @@ module Codesake
23
31
  @glob = File.join(@glob, options[:glob]) unless options[:glob].nil?
24
32
  end
25
33
 
34
+ def must_exclude?(filename)
35
+ EXCLUSION_LIST.each do |ex|
36
+ debug_me "skipping #{filename}" if filename.start_with?(ex)
37
+ return true if filename.start_with?(ex)
38
+ end
39
+ return false
40
+ end
41
+
26
42
  def vuln?
27
43
  Dir.glob(File.join("#{root_dir}", @glob)).each do |filename|
28
44
  debug_me("#{File.basename(__FILE__)}@#{__LINE__}: analyzing #{filename}: search is #{@negative_search}")
29
45
  matches = []
30
46
  begin
31
- matches = run(load_file(filename)) if File.exists?(filename) and File.file?(filename) and ! File.binary?(filename)
47
+ matches = run(load_file(filename)) if File.exists?(filename) && File.file?(filename) && ! File.binary?(filename) && ! must_exclude?(filename)
32
48
  rescue ArgumentError => e
33
49
  puts "Skipping pattern match check for #{filename}: #{e.message}"
34
50
  end
@@ -102,11 +102,14 @@ require "codesake/dawn/kb/cve_2011_4319"
102
102
  require "codesake/dawn/kb/cve_2011_4815"
103
103
 
104
104
  # CVE - 2012
105
+ require "codesake/dawn/kb/cve_2012_1098"
105
106
  require "codesake/dawn/kb/cve_2012_1099"
106
107
  require "codesake/dawn/kb/cve_2012_1241"
108
+ require "codesake/dawn/kb/cve_2012_2139"
107
109
  require "codesake/dawn/kb/cve_2012_2140"
108
110
  require "codesake/dawn/kb/cve_2012_2660"
109
111
  require "codesake/dawn/kb/cve_2012_2661"
112
+ require "codesake/dawn/kb/cve_2012_2671"
110
113
  require "codesake/dawn/kb/cve_2012_2694"
111
114
  require "codesake/dawn/kb/cve_2012_2695"
112
115
  require "codesake/dawn/kb/cve_2012_3424"
@@ -127,6 +130,7 @@ require "codesake/dawn/kb/cve_2012_6497"
127
130
  # CVE - 2013
128
131
  require "codesake/dawn/kb/cve_2013_0155"
129
132
  require "codesake/dawn/kb/cve_2013_0156"
133
+ require "codesake/dawn/kb/cve_2013_0162"
130
134
  require "codesake/dawn/kb/cve_2013_0175"
131
135
  require "codesake/dawn/kb/cve_2013_0233"
132
136
  require "codesake/dawn/kb/cve_2013_0256"
@@ -139,6 +143,7 @@ require "codesake/dawn/kb/cve_2013_0285"
139
143
  require "codesake/dawn/kb/cve_2013_0333"
140
144
  require "codesake/dawn/kb/cve_2013_1655"
141
145
  require "codesake/dawn/kb/cve_2013_1656"
146
+ require "codesake/dawn/kb/cve_2013_1756"
142
147
  require "codesake/dawn/kb/cve_2013_1800"
143
148
  require "codesake/dawn/kb/cve_2013_1801"
144
149
  require "codesake/dawn/kb/cve_2013_1802"
@@ -307,11 +312,14 @@ module Codesake
307
312
  Codesake::Dawn::Kb::CVE_2011_3187.new,
308
313
  Codesake::Dawn::Kb::CVE_2011_4319.new,
309
314
  Codesake::Dawn::Kb::CVE_2011_4815.new,
315
+ Codesake::Dawn::Kb::CVE_2012_1098.new,
310
316
  Codesake::Dawn::Kb::CVE_2012_1099.new,
311
317
  Codesake::Dawn::Kb::CVE_2012_1241.new,
318
+ Codesake::Dawn::Kb::CVE_2012_2139.new,
312
319
  Codesake::Dawn::Kb::CVE_2012_2140.new,
313
320
  Codesake::Dawn::Kb::CVE_2012_2660.new,
314
321
  Codesake::Dawn::Kb::CVE_2012_2661.new,
322
+ Codesake::Dawn::Kb::CVE_2012_2671.new,
315
323
  Codesake::Dawn::Kb::CVE_2012_2694.new,
316
324
  Codesake::Dawn::Kb::CVE_2012_2695.new,
317
325
  Codesake::Dawn::Kb::CVE_2012_3424.new,
@@ -330,6 +338,7 @@ module Codesake
330
338
  Codesake::Dawn::Kb::CVE_2012_6497.new,
331
339
  Codesake::Dawn::Kb::CVE_2013_0155.new,
332
340
  Codesake::Dawn::Kb::CVE_2013_0156.new,
341
+ Codesake::Dawn::Kb::CVE_2013_0162.new,
333
342
  Codesake::Dawn::Kb::CVE_2013_0175.new,
334
343
  Codesake::Dawn::Kb::CVE_2013_0233.new,
335
344
  Codesake::Dawn::Kb::CVE_2013_0256.new,
@@ -342,6 +351,7 @@ module Codesake
342
351
  Codesake::Dawn::Kb::CVE_2013_0333.new,
343
352
  Codesake::Dawn::Kb::CVE_2013_1655.new,
344
353
  Codesake::Dawn::Kb::CVE_2013_1656.new,
354
+ Codesake::Dawn::Kb::CVE_2013_1756.new,
345
355
  Codesake::Dawn::Kb::CVE_2013_1800.new,
346
356
  Codesake::Dawn::Kb::CVE_2013_1801.new,
347
357
  Codesake::Dawn::Kb::CVE_2013_1802.new,
@@ -6,13 +6,16 @@ module Codesake
6
6
  #
7
7
  # Future releases
8
8
  #
9
- # "Tow Mater" - v 1.2.0
10
- # "Finn McMissile" - v 1.3.0
11
- # "Fillmore" - v 1.4.0
9
+ # "Tow Mater"
10
+ # "Finn McMissile"
11
+ # "Fillmore"
12
+ # "Holly Shiftwell"
13
+ # "Guido"
14
+ # "Luigi"
12
15
 
13
- VERSION = "1.0.0.rc2"
16
+ VERSION = "1.0.0"
14
17
  CODENAME = "Lightning McQueen"
15
- RELEASE = "20140114"
18
+ RELEASE = "20140121"
16
19
 
17
20
  end
18
21
  end
@@ -742,5 +742,30 @@ end
742
742
  sc = kb.find("CVE-2013-0256")
743
743
  sc.should_not be_nil
744
744
  sc.class.should == Codesake::Dawn::Kb::CVE_2013_0256
745
+ end
746
+ it "must have test for CVE-2013-0162" do
747
+ sc = kb.find("CVE-2013-0162")
748
+ sc.should_not be_nil
749
+ sc.class.should == Codesake::Dawn::Kb::CVE_2013_0162
750
+ end
751
+ it "must have test for CVE-2012-2671" do
752
+ sc = kb.find("CVE-2012-2671")
753
+ sc.should_not be_nil
754
+ sc.class.should == Codesake::Dawn::Kb::CVE_2012_2671
755
+ end
756
+ it "must have test for CVE-2012-2139" do
757
+ sc = kb.find("CVE-2012-2139")
758
+ sc.should_not be_nil
759
+ sc.class.should == Codesake::Dawn::Kb::CVE_2012_2139
760
+ end
761
+ it "must have test for CVE-2012-1098" do
762
+ sc = kb.find("CVE-2012-1098")
763
+ sc.should_not be_nil
764
+ sc.class.should == Codesake::Dawn::Kb::CVE_2012_1098
765
+ end
766
+ it "must have test for CVE-2013-1756" do
767
+ sc = kb.find("CVE-2013-1756")
768
+ sc.should_not be_nil
769
+ sc.class.should == Codesake::Dawn::Kb::CVE_2013_1756
745
770
  end
746
771
  end
@@ -32,6 +32,7 @@ describe "The CVE-2013-4457 vulnerability" do
32
32
 
33
33
  it "is skipped if non vulnerable version of cocaine rubygem is detected" do
34
34
  @check.dependencies=[{:name=>"cocaine", :version=>'0.3.2'}]
35
+ # @check.debug = true
35
36
  @check.vuln?.should be_false
36
37
  end
37
38
 
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ class DependencyMockup
4
+ include Codesake::Dawn::Kb::DependencyCheck
5
+
6
+ def initialize
7
+ message = "This is a mock"
8
+ super(
9
+ :kind=>Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK,
10
+ :applies=>['sinatra', 'padrino', 'rails'],
11
+ :message=> message
12
+ )
13
+ # self.debug = true
14
+
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
+ end
17
+ end
18
+
19
+
20
+ describe "The security check for gem dependency should" do
21
+ before(:all) do
22
+ @check = DependencyMockup.new
23
+ end
24
+ # let (:check) {Mockup.new}
25
+
26
+ it "fires if vulnerable 0.2.9 version is detected" do
27
+ @check.dependencies = [{:name=>"this_gem", :version=>'0.2.9'}]
28
+ @check.vuln?.should be_true
29
+ end
30
+ it "doesn't fire if not vulnerable 0.4.0 version is found" do
31
+ @check.dependencies = [{:name=>"this_gem", :version=>'0.4.0'}]
32
+ @check.vuln?.should be_false
33
+ end
34
+
35
+ it "fires if vulnerable 1.3.2 version is found" do
36
+ @check.dependencies = [{:name=>"this_gem", :version=>'1.3.2'}]
37
+ @check.vuln?.should be_true
38
+ end
39
+
40
+ it "doesn't fire if not vulnerable 1.4.2 version is found" do
41
+ @check.dependencies = [{:name=>"this_gem", :version=>'1.4.2'}]
42
+ @check.vuln?.should be_false
43
+ end
44
+
45
+ it "fires when a non vulnerable version is found but there is a fixed version with higher minor release" do
46
+ @check.dependencies = [{:name=>"this_gem", :version=>'2.3.3'}]
47
+ @check.vuln?.should be_true
48
+ end
49
+ it "should tell me there is a fixed version with 2 as major and 4 as minor release number" do
50
+ @check.is_there_an_higher_minor_version?(['0.3.0', '1.3.3', '2.3.3', '2.4.2', '9.4.31.2'], '2.3.3').should be_true
51
+ end
52
+ it "doesn't fires when a non vulnerable version is found and there is a fixed version with higher minor release but I asked to honor the minor version (useful with rails gem)" do
53
+ @check.dependencies = [{:name=>"this_gem", :version=>'2.3.3'}]
54
+ @check.save_minor_fixes = true
55
+ @check.vuln?.should be_false
56
+ end
57
+ it "fires when a vulnerable version (2.3.2) is found even if I asked to save minors..." do
58
+ @check.dependencies = [{:name=>"this_gem", :version=>'2.3.2'}]
59
+ @check.save_minor_fixes = true
60
+ @check.vuln?.should be_true
61
+
62
+ end
63
+
64
+
65
+ end
@@ -4,5 +4,32 @@ describe "The CVE-2011-2705 vulnerability" do
4
4
  @check = Codesake::Dawn::Kb::CVE_2011_2705.new
5
5
  # @check.debug = true
6
6
  end
7
- it "needs some test..."
7
+ it "fires when ruby 1.8.7-p351 is detected" do
8
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.8.7", :patchlevel=>"p351"}
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "fires when ruby 1.9.0 any patchlevel is detected" do
12
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.9.0", :patchlevel=>"p351"}
13
+ @check.vuln?.should be_true
14
+ end
15
+ it "fires when ruby 1.9.1 any patchlevel is detected" do
16
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.9.1", :patchlevel=>"p351"}
17
+ @check.vuln?.should be_true
18
+ end
19
+ it "fires when ruby 1.9.2-p289 is detected" do
20
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.9.2", :patchlevel=>"p289"}
21
+ @check.vuln?.should be_true
22
+ end
23
+ it "doesn't fire when ruby 1.8.7-p352 is detected" do
24
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.8.7", :patchlevel=>"p352"}
25
+ @check.vuln?.should be_false
26
+ end
27
+ it "doesn't fire when ruby 1.9.2-p290 is detected" do
28
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.9.2", :patchlevel=>"p290"}
29
+ @check.vuln?.should be_false
30
+ end
31
+ it "doesn't fire when ruby 1.9.3-p290 is detected" do
32
+ @check.detected_ruby ={:engine=>"ruby", :version=>"1.9.3", :patchlevel=>"p290"}
33
+ @check.vuln?.should be_false
34
+ end
8
35
  end
@@ -4,5 +4,29 @@ describe "The CVE-2011-2930 vulnerability" do
4
4
  @check = Codesake::Dawn::Kb::CVE_2011_2930.new
5
5
  # @check.debug = true
6
6
  end
7
- it "needs some test..."
7
+ it "fires when vulnerable rails version is used (2.3.12)" do
8
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.12'}]
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "fires when vulnerable rails version is used (3.0.9)" do
12
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.9'}]
13
+ @check.vuln?.should be_true
14
+ end
15
+ it "fires when vulnerable rails version is used (3.1.0)" do
16
+ @check.dependencies = [{:name=>"rails", :version=>'3.1.0'}]
17
+ @check.vuln?.should be_true
18
+ end
19
+ it "doesn't fire when safe rails version is used (2.3.14)" do
20
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.14'}]
21
+ @check.vuln?.should be_false
22
+ end
23
+ it "doesn't fire when safe rails version is used (3.0.10)" do
24
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.10'}]
25
+ @check.vuln?.should be_false
26
+ end
27
+ it "doesn't fire when safe rails version is used (3.1.1.)" do
28
+ @check.dependencies = [{:name=>"rails", :version=>'3.1.1'}]
29
+ @check.vuln?.should be_false
30
+ end
31
+ # self.safe_dependencies = [{:name=>"rails", :version=>['2.3.13', '3.0.10', '3.1.1']}]
8
32
  end
@@ -1,8 +1,25 @@
1
1
  require 'spec_helper'
2
+
2
3
  describe "The CVE-2011-3009 vulnerability" do
3
4
  before(:all) do
4
5
  @check = Codesake::Dawn::Kb::CVE_2011_3009.new
5
6
  # @check.debug = true
6
7
  end
7
- it "needs some test..."
8
+ it "fires if ruby version is vulnerable (1.8.6-p111)" do
9
+ @check.detected_ruby = {:engine=>'ruby', :version=>"1.8.6", :patchlevel=>"p111"}
10
+ @check.vuln?.should be_true
11
+ end
12
+ it "fires if ruby version is vulnerable (1.8.5-p111)" do
13
+ @check.detected_ruby = {:engine=>'ruby', :version=>"1.8.5", :patchlevel=>"p111"}
14
+ @check.vuln?.should be_true
15
+ end
16
+ it "doesn't fire if ruby version is not vulnerable (1.8.6-p112)" do
17
+ @check.detected_ruby = {:engine=>'ruby', :version=>"1.8.6", :patchlevel=>"p112"}
18
+ @check.vuln?.should be_false
19
+ end
20
+ it "doesn't fire if ruby version is not vulnerable (1.9.2-p112)" do
21
+ @check.detected_ruby = {:engine=>'ruby', :version=>"1.9.2", :patchlevel=>"p112"}
22
+ @check.vuln?.should be_false
23
+ end
24
+
8
25
  end
@@ -4,5 +4,21 @@ describe "The CVE-2011-3187 vulnerability" do
4
4
  @check = Codesake::Dawn::Kb::CVE_2011_3187.new
5
5
  # @check.debug = true
6
6
  end
7
- it "needs some test..."
7
+ it "fires when vulnerable rails version it has been found (3.0.5)" do
8
+ @check.dependencies = [{:name=>'rails', :version=>'3.0.5'}]
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "doesn't fire when safe rails version it has been found (3.0.6)" do
12
+ @check.dependencies = [{:name=>'rails', :version=>'3.0.6'}]
13
+ @check.vuln?.should be_false
14
+ end
15
+ it "doesn't fire when safe rails version it has been found (3.1.6)" do
16
+ @check.dependencies = [{:name=>'rails', :version=>'3.1.6'}]
17
+ @check.vuln?.should be_false
18
+ end
19
+ it "doesn't fire when safe rails version it has been found (2.3.16)" do
20
+ @check.dependencies = [{:name=>'rails', :version=>'2.3.16'}]
21
+ @check.vuln?.should be_false
22
+ end
23
+ # self.safe_dependencies = [{:name=>"rails", :version=>['3.0.6']}]
8
24
  end
@@ -4,5 +4,41 @@ describe "The CVE-2011-4319 vulnerability" do
4
4
  @check = Codesake::Dawn::Kb::CVE_2011_4319.new
5
5
  # @check.debug = true
6
6
  end
7
- it "needs some test..."
7
+ it "fires when vulnerable rails version it has been found (2.3.12)" do
8
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.12'}]
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "fires when vulnerable rails version it has been found (3.0.10)" do
12
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.10'}]
13
+ @check.vuln?.should be_true
14
+ end
15
+ it "fires when vulnerable rails version it has been found (3.1.1)" do
16
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.10'}]
17
+ @check.vuln?.should be_true
18
+ end
19
+ it "doesn't fire when safe rails version it has been found (2.3.13)" do
20
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.13'}]
21
+ @check.vuln?.should be_false
22
+ end
23
+ it "doesn't fire when safe rails version it has been found (2.3.14)" do
24
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.14'}]
25
+ @check.vuln?.should be_false
26
+ end
27
+ it "doesn't fire when safe rails version it has been found (3.0.11)" do
28
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.11'}]
29
+ @check.vuln?.should be_false
30
+ end
31
+ it "doesn't fire when safe rails version it has been found (3.0.12)" do
32
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.12'}]
33
+ @check.vuln?.should be_false
34
+ end
35
+ it "doesn't fire when safe rails version it has been found (3.1.2)" do
36
+ @check.dependencies = [{:name=>"rails", :version=>'3.1.2'}]
37
+ @check.vuln?.should be_false
38
+ end
39
+ it "doesn't fire when safe rails version it has been found (3.2.0)" do
40
+ @check.dependencies = [{:name=>"rails", :version=>'3.2.0'}]
41
+ @check.vuln?.should be_false
42
+ end
43
+ # self.safe_dependencies = [{:name=>"rails", :version=>['2.3.13', '3.0.11', '3.1.2']}]
8
44
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ describe "The CVE-2012-1098 vulnerability" do
3
+ before(:all) do
4
+ @check = Codesake::Dawn::Kb::CVE_2012_1098.new
5
+ # @check.debug = true
6
+ end
7
+ it "fires when vulnerable rails version it has been found (3.0.11)" do
8
+ @check.dependencies = [{:name=>"rails", :version=>'3.0.11'}]
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "fires when vulnerable rails version it has been found (3.1.3)" do
12
+ @check.dependencies = [{:name=>"rails", :version=>'3.1.3'}]
13
+ @check.vuln?.should be_true
14
+ end
15
+ it "fires when vulnerable rails version it has been found (3.2.1)" do
16
+ @check.dependencies = [{:name=>"rails", :version=>'3.2.1'}]
17
+ @check.vuln?.should be_true
18
+ end
19
+ it "doesn't fire when non vulnerable rails version it has been found (3.2.2)" do
20
+ @check.dependencies = [{:name=>"rails", :version=>'3.2.2'}]
21
+ @check.vuln?.should be_false
22
+ end
23
+ it "doesn't fire when non vulnerable rails version it has been found (3.2.4)" do
24
+ @check.dependencies = [{:name=>"rails", :version=>'3.2.4'}]
25
+ @check.vuln?.should be_false
26
+ end
27
+ it "doesn't fire when non vulnerable rails version it has been found (3.1.4)" do
28
+ @check.dependencies = [{:name=>"rails", :version=>'3.1.4'}]
29
+ # @check.debug = true
30
+ @check.vuln?.should be_false
31
+ end
32
+ it "doesn't fire when rails version older than 3.x.y it has been found" do
33
+ @check.dependencies = [{:name=>"rails", :version=>'2.3.12'}]
34
+ @check.vuln?.should be_false
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ describe "The CVE-2012-2139 vulnerability" do
3
+ before(:all) do
4
+ @check = Codesake::Dawn::Kb::CVE_2012_2139.new
5
+ # @check.debug = true
6
+ end
7
+ it "is reported when mail_gem version 2.4.3 is used" do
8
+ @check.dependencies = [{:name=>"mail_gem", :version=>"2.4.3"}]
9
+ @check.vuln?.should be_true
10
+ end
11
+ it "is reported when mail_gem version 2.3.3 is used" do
12
+ @check.dependencies = [{:name=>"mail_gem", :version=>"2.3.3"}]
13
+ @check.vuln?.should be_true
14
+ end
15
+
16
+ it "is not reported when mail_gem version 2.4.4 is used" do
17
+ @check.dependencies = [{:name=>"mail_gem", :version=>"2.4.4"}]
18
+ @check.vuln?.should be_false
19
+ end
20
+ end