Start adding sslscan results object

Building out the result object for the SSlScan
bug/bundler_fix
David Maloney 2013-02-07 12:42:18 -06:00
parent ebd03ccceb
commit 7036365e04
2 changed files with 97 additions and 0 deletions

37
lib/rex/sslscan/result.rb Normal file
View File

@ -0,0 +1,37 @@
require 'rex/socket'
module Rex::SSLScan
class Result
attr_accessor :sslv2
attr_accessor :sslv3
attr_accessor :tlsv1
attr_reader :supported_versions
def initialize()
@cert = nil
@sslv2 = {}
@sslv3 = {}
@tlsv1 = {}
@supported_versions = [:sslv2, :sslv3, :tlsv1]
end
def cert
@cert
end
def cert=(input)
unless input.kind_of? OpenSSL::X509::Certificate or input.nil?
raise ArgumentError, "Must be an X509 Cert!"
end
@cert = input
end
def add_cipher(version, cipher, key_length, status)
end
end
end

View File

@ -0,0 +1,60 @@
require 'rex/sslscan/result'
describe Rex::SSLScan::Result do
subject{Rex::SSLScan::Result.new}
it "should respond to cert" do
subject.should respond_to :cert
end
it "should respond to sslv2" do
subject.should respond_to :sslv2
end
it "should respond to sslv3" do
subject.should respond_to :sslv3
end
it "should respond to tlsv1" do
subject.should respond_to :tlsv1
end
context "with no values set" do
it "should return nil for the cert" do
subject.cert.should == nil
end
it "should return an empty hash for sslv2" do
subject.sslv2.should == {}
end
it "should return an empty hash for sslv3" do
subject.sslv3.should == {}
end
it "should return an empty hash for tlsv1" do
subject.tlsv1.should == {}
end
end
context "setting the cert" do
it "should accept nil" do
subject.cert = nil
subject.cert.should == nil
end
it "should accept an X509 cert" do
cert = OpenSSL::X509::Certificate.new
subject.cert = cert
subject.cert.should == cert
end
it "should raise an exception for anything else" do
expect{subject.cert = "foo"}.to raise_error
end
end
end