Whitespace
parent
06443ea4d0
commit
c41bfa9141
|
@ -52,7 +52,7 @@ class Result
|
|||
# @raise [ArgumentError] if the version supplied is invalid
|
||||
# @return [Array] An array of accepted cipher details matching the supplied versions
|
||||
def accepted(version = :all)
|
||||
enum_ciphers(:accepted, version)
|
||||
enum_ciphers(:accepted, version)
|
||||
end
|
||||
|
||||
# Returns all rejected ciphers matching the supplied version
|
||||
|
@ -60,7 +60,7 @@ class Result
|
|||
# @raise [ArgumentError] if the version supplied is invalid
|
||||
# @return [Array] An array of rejected cipher details matching the supplied versions
|
||||
def rejected(version = :all)
|
||||
enum_ciphers(:rejected, version)
|
||||
enum_ciphers(:rejected, version)
|
||||
end
|
||||
|
||||
def each_accepted(version = :all)
|
||||
|
@ -160,41 +160,41 @@ class Result
|
|||
table.rows.sort_by!{|row| [row[0],row[2],row[3]]}
|
||||
text = "#{table.to_s}"
|
||||
if @cert
|
||||
text <<" \n\n #{@cert.to_text}"
|
||||
text << " \n\n #{@cert.to_text}"
|
||||
end
|
||||
if openssl_sslv2 == false
|
||||
text << "\n\n *** WARNING: Your OS hates freedom! Your OpenSSL libs are compiled without SSLv2 support!"
|
||||
end
|
||||
text
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
# @param [Symbol] state Either :accepted or :rejected
|
||||
# @param [Symbol, Array] version The SSL Version to filter on (:SSLv2:SSLv3,:TLSv1, :all)
|
||||
# @return [Set] The Set of cipher results matching the filter criteria
|
||||
def enum_ciphers(state, version = :all)
|
||||
case version
|
||||
when Symbol
|
||||
case version
|
||||
when :all
|
||||
return @ciphers.select{|cipher| cipher[:status] == state}
|
||||
when :SSLv2, :SSLv3, :TLSv1
|
||||
return @ciphers.select{|cipher| cipher[:status] == state and cipher[:version] == version}
|
||||
else
|
||||
raise ArgumentError, "Invalid SSL Version Supplied: #{version}"
|
||||
end
|
||||
when Array
|
||||
version = version.reject{|v| !(@supported_versions.include? v)}
|
||||
if version.empty?
|
||||
return @ciphers.select{|cipher| cipher[:status] == state}
|
||||
else
|
||||
return @ciphers.select{|cipher| cipher[:status] == state and version.include? cipher[:version]}
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "Was expecting Symbol or Array and got #{version.class}"
|
||||
end
|
||||
end
|
||||
# @param [Symbol] state Either :accepted or :rejected
|
||||
# @param [Symbol, Array] version The SSL Version to filter on (:SSLv2:SSLv3,:TLSv1, :all)
|
||||
# @return [Set] The Set of cipher results matching the filter criteria
|
||||
def enum_ciphers(state, version = :all)
|
||||
case version
|
||||
when Symbol
|
||||
case version
|
||||
when :all
|
||||
return @ciphers.select{|cipher| cipher[:status] == state}
|
||||
when :SSLv2, :SSLv3, :TLSv1
|
||||
return @ciphers.select{|cipher| cipher[:status] == state and cipher[:version] == version}
|
||||
else
|
||||
raise ArgumentError, "Invalid SSL Version Supplied: #{version}"
|
||||
end
|
||||
when Array
|
||||
version = version.reject{|v| !(@supported_versions.include? v)}
|
||||
if version.empty?
|
||||
return @ciphers.select{|cipher| cipher[:status] == state}
|
||||
else
|
||||
return @ciphers.select{|cipher| cipher[:status] == state and version.include? cipher[:version]}
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "Was expecting Symbol or Array and got #{version.class}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class Scanner
|
|||
attr_accessor :host
|
||||
attr_accessor :port
|
||||
attr_accessor :timeout
|
||||
|
||||
|
||||
attr_reader :supported_versions
|
||||
attr_reader :sslv2
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Scanner
|
|||
'SSLVersion' => :SSLv23,
|
||||
'Timeout' => @timeout
|
||||
)
|
||||
rescue ::Exception => e
|
||||
rescue ::Exception => e
|
||||
return :rejected
|
||||
ensure
|
||||
if scan_client
|
||||
|
@ -101,7 +101,7 @@ class Scanner
|
|||
'SSLVersion' => :TLSv1,
|
||||
'Timeout' => @timeout
|
||||
)
|
||||
rescue ::Exception => e
|
||||
rescue ::Exception => e
|
||||
return :rejected
|
||||
ensure
|
||||
if scan_client
|
||||
|
@ -127,14 +127,14 @@ class Scanner
|
|||
'SSLCipher' => cipher,
|
||||
'Timeout' => @timeout
|
||||
)
|
||||
rescue ::Exception => e
|
||||
rescue ::Exception => e
|
||||
return :rejected
|
||||
ensure
|
||||
if scan_client
|
||||
scan_client.close
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return :accepted
|
||||
end
|
||||
|
||||
|
@ -160,7 +160,7 @@ class Scanner
|
|||
else
|
||||
return nil
|
||||
end
|
||||
rescue ::Exception => e
|
||||
rescue ::Exception => e
|
||||
return nil
|
||||
ensure
|
||||
if scan_client
|
||||
|
@ -172,7 +172,7 @@ class Scanner
|
|||
|
||||
protected
|
||||
|
||||
# Validates that the SSL Version and Cipher are valid both seperately and
|
||||
# Validates that the SSL Version and Cipher are valid both seperately and
|
||||
# together as part of an SSL Context.
|
||||
# @param ssl_version [Symbol] The SSL version to use (:SSLv2, :SSLv3, :TLSv1)
|
||||
# @param cipher [String] The SSL Cipher to use
|
||||
|
@ -193,7 +193,7 @@ class Scanner
|
|||
end
|
||||
|
||||
def check_opensslv2
|
||||
begin
|
||||
begin
|
||||
OpenSSL::SSL::SSLContext.new(:SSLv2)
|
||||
rescue
|
||||
return false
|
||||
|
@ -202,4 +202,4 @@ class Scanner
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue