Skip to content

Commit 3a72fa4

Browse files
David MaloneyDavid Maloney
authored andcommitted
address sslv2 issues in specs
the ubuntu sslv2 thing caused all kinds of issues with rspec handling this by expecting those exceptions properly or doing away with sslv2 where it isn't needed in the examples
1 parent 3bb1b2b commit 3a72fa4

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

spec/lib/rex/sslscan/result_spec.rb

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
end
135135
end
136136
context "that was accepted" do
137-
it "should add an SSLv2 cipher result to the SSLv2 Accepted array" do
137+
it "should add an SSLv2 cipher result to the SSLv2 Accepted array or generate an SSLv2 exception" do
138138
begin
139139
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
140140
subject.accepted(:SSLv2).should include({
@@ -144,7 +144,7 @@
144144
:weak=> false,
145145
:status => :accepted})
146146
rescue ArgumentError => e
147-
e.message.should == "unknown SSL method `SSLv2'"
147+
e.message.should == "unknown SSL method `SSLv2'."
148148
end
149149
end
150150

@@ -192,14 +192,18 @@
192192
end
193193
end
194194
context "that was rejected" do
195-
it "should add an SSLv2 cipher result to the SSLv2 Rejected array" do
196-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected)
197-
subject.rejected(:SSLv2).should include({
198-
:version => :SSLv2,
199-
:cipher=>"DES-CBC3-MD5",
200-
:key_length=>168,
201-
:weak=> false,
202-
:status => :rejected})
195+
it "should add an SSLv2 cipher result to the SSLv2 Rejected array or generate an SSLv2 exception" do
196+
begin
197+
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected)
198+
subject.rejected(:SSLv2).should include({
199+
:version => :SSLv2,
200+
:cipher=>"DES-CBC3-MD5",
201+
:key_length=>168,
202+
:weak=> false,
203+
:status => :rejected})
204+
rescue ArgumentError => e
205+
e.message.should == "unknown SSL method `SSLv2'."
206+
end
203207
end
204208

205209
it "should add an SSLv3 cipher result to the SSLv3 Rejected array" do
@@ -249,7 +253,6 @@
249253

250254
context "enumerating all accepted ciphers" do
251255
before(:each) do
252-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
253256
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
254257
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
255258
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
@@ -267,7 +270,7 @@
267270
subject.each_accepted do |cipher_details|
268271
count = count+1
269272
end
270-
count.should == 4
273+
count.should == 3
271274
end
272275
end
273276

@@ -281,8 +284,8 @@
281284
end
282285

283286
it "should return only ciphers matching the version" do
284-
subject.each_accepted(:SSLv2) do |cipher_details|
285-
cipher_details[:version].should == :SSLv2
287+
subject.each_accepted(:SSLv3) do |cipher_details|
288+
cipher_details[:version].should == :SSLv3
286289
end
287290
end
288291
end
@@ -293,7 +296,7 @@
293296
subject.each_accepted([:TLSv3, :TLSv4]) do |cipher_details|
294297
count = count+1
295298
end
296-
count.should == 4
299+
count.should == 3
297300
end
298301

299302
it "should return only the ciphers for the specified version" do
@@ -306,7 +309,6 @@
306309

307310
context "enumerating all rejected ciphers" do
308311
before(:each) do
309-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected)
310312
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :rejected)
311313
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :rejected)
312314
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected)
@@ -324,7 +326,7 @@
324326
subject.each_rejected do |cipher_details|
325327
count = count+1
326328
end
327-
count.should == 4
329+
count.should == 3
328330
end
329331
end
330332

@@ -338,8 +340,8 @@
338340
end
339341

340342
it "should return only ciphers matching the version" do
341-
subject.each_rejected(:SSLv2) do |cipher_details|
342-
cipher_details[:version].should == :SSLv2
343+
subject.each_rejected(:SSLv3) do |cipher_details|
344+
cipher_details[:version].should == :SSLv3
343345
end
344346
end
345347
end
@@ -350,7 +352,7 @@
350352
subject.each_rejected([:TLSv3, :TLSv4]) do |cipher_details|
351353
count = count+1
352354
end
353-
count.should == 4
355+
count.should == 3
354356
end
355357

356358
it "should return only the ciphers for the specified version" do
@@ -366,9 +368,13 @@
366368
it "should return false if there are no accepted ciphers" do
367369
subject.supports_sslv2?.should == false
368370
end
369-
it "should return true if there are accepted ciphers" do
370-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
371-
subject.supports_sslv2?.should == true
371+
it "should return true if there are accepted ciphers or raise an SSLv2 exception" do
372+
begin
373+
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
374+
subject.supports_sslv2?.should == true
375+
rescue ArgumentError => e
376+
e.message.should == "unknown SSL method `SSLv2'."
377+
end
372378
end
373379
end
374380
context "for SSLv3" do
@@ -403,8 +409,8 @@
403409
context "checking for weak ciphers" do
404410
context "when weak ciphers are supported" do
405411
before(:each) do
406-
subject.add_cipher(:SSLv2, "DES-CBC-MD5", 56, :accepted)
407-
subject.add_cipher(:SSLv2, "EXP-RC2-CBC-MD5", 40, :accepted)
412+
subject.add_cipher(:SSLv3, "EXP-RC4-MD5", 40, :accepted)
413+
subject.add_cipher(:SSLv3, "DES-CBC-SHA", 56, :accepted)
408414
end
409415
it "should return an array of weak ciphers from #weak_ciphers" do
410416
weak = subject.weak_ciphers
@@ -422,7 +428,6 @@
422428

423429
context "when no weak ciphers are supported" do
424430
before(:each) do
425-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
426431
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
427432
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
428433
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
@@ -442,9 +447,13 @@
442447
subject.standards_compliant?.should == true
443448
end
444449

445-
it "should return false if SSLv2 is supported" do
446-
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
447-
subject.standards_compliant?.should == false
450+
it "should return false if SSLv2 is supported or raise an SSLv2 exception" do
451+
begin
452+
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
453+
subject.standards_compliant?.should == false
454+
rescue ArgumentError => e
455+
e.message.should == "unknown SSL method `SSLv2'."
456+
end
448457
end
449458

450459
it "should return false if weak ciphers are supported" do

0 commit comments

Comments
 (0)