Skip to content

Commit 7332d31

Browse files
David MaloneyDavid Maloney
authored andcommitted
fix some style things for egypt
1 parent f253b28 commit 7332d31

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/rex/sslscan/result.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Result
1212

1313
def initialize()
1414
@cert = nil
15-
@ciphers = []
15+
@ciphers = Set.new
1616
@supported_versions = [:SSLv2, :SSLv3, :TLSv1]
1717
end
1818

@@ -53,7 +53,8 @@ def strong_ciphers
5353
# @raise [ArgumentError] if the version supplied is invalid
5454
# @return [Array] An array of accepted cipher details matching the supplied versions
5555
def accepted(version = :all)
56-
if version.kind_of? Symbol
56+
case version
57+
when Symbol
5758
case version
5859
when :all
5960
return @ciphers.reject{|cipher| cipher[:status] == :rejected}
@@ -62,8 +63,8 @@ def accepted(version = :all)
6263
else
6364
raise ArgumentError, "Invalid SSL Version Supplied: #{version}"
6465
end
65-
elsif version.kind_of? Array
66-
version.reject!{|v| !(@supported_versions.include? v)}
66+
when Array
67+
version = version.reject{|v| !(@supported_versions.include? v)}
6768
if version.empty?
6869
return @ciphers.reject{|cipher| cipher[:status] == :rejected}
6970
else
@@ -80,7 +81,8 @@ def accepted(version = :all)
8081
# @raise [ArgumentError] if the version supplied is invalid
8182
# @return [Array] An array of rejected cipher details matching the supplied versions
8283
def rejected(version = :all)
83-
if version.kind_of? Symbol
84+
case version
85+
when Symbol
8486
case version
8587
when :all
8688
return @ciphers.reject{|cipher| cipher[:status] == :accepted}
@@ -89,8 +91,8 @@ def rejected(version = :all)
8991
else
9092
raise ArgumentError, "Invalid SSL Version Supplied: #{version}"
9193
end
92-
elsif version.kind_of? Array
93-
version.reject!{|v| !(@supported_versions.include? v)}
94+
when Array
95+
version = version.reject{|v| !(@supported_versions.include? v)}
9496
if version.empty?
9597
return @ciphers.reject{|cipher| cipher[:status] == :accepted}
9698
else
@@ -173,7 +175,6 @@ def add_cipher(version, cipher, key_length, status)
173175

174176
cipher_details = {:version => version, :cipher => cipher, :key_length => key_length, :weak => weak, :status => status}
175177
@ciphers << cipher_details
176-
@ciphers.uniq!
177178
end
178179

179180
def to_s

spec/lib/rex/sslscan/result_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
subject.cert.should == nil
2626
end
2727

28-
it "should return an empty array for ciphers" do
29-
subject.ciphers.should == []
28+
it "should return an empty set for ciphers" do
29+
subject.ciphers.empty?.should == true
3030
end
3131

3232
it "should return an empty array for accepted" do

0 commit comments

Comments
 (0)