Skip to content

Commit 04d305f

Browse files
committed
update SSL Labs scanner with new API, be robust
This updates the SSL Labs scanner to know about new additions to the API, and prevents the module from breaking again just because there is new JSON in the output. I couldn't figure out how to get the Api class to print messages normally, and there is some other output that needs to be added. But the module does work again.
1 parent 682c915 commit 04d305f

File tree

1 file changed

+65
-16
lines changed

1 file changed

+65
-16
lines changed

modules/auxiliary/gather/ssllabs_scan.rb

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,34 @@ def request(name, params = {})
6565
end
6666
end
6767

68+
def report_unused_attrs(type, unused_attrs)
69+
unused_attrs.each do | attr |
70+
# $stderr.puts "#{type} request returned unknown parameter #{attr}"
71+
end
72+
end
73+
6874
def info
69-
Info.load request(:info)
75+
obj, unused_attrs = Info.load request(:info)
76+
report_unused_attrs('info', unused_attrs)
77+
obj
7078
end
7179

7280
def analyse(params = {})
73-
Host.load request(:analyze, params)
81+
obj, unused_attrs = Host.load request(:analyze, params)
82+
report_unused_attrs('analyze', unused_attrs)
83+
obj
7484
end
7585

7686
def get_endpoint_data(params = {})
77-
Endpoint.load request(:get_endpoint_data, params)
87+
obj, unused_attrs = Endpoint.load request(:get_endpoint_data, params)
88+
report_unused_attrs('get_endpoint_data', unused_attrs)
89+
obj
7890
end
7991

8092
def get_status_codes
81-
StatusCodes.load request(:get_status_codes)
93+
obj, unused_attrs = StatusCodes.load request(:get_status_codes)
94+
report_unused_attrs('get_status_codes', unused_attrs)
95+
obj
8296
end
8397
end
8498

@@ -142,18 +156,30 @@ def self.has_object_ref(name, klass)
142156

143157
def self.load(attributes = {})
144158
obj = self.new
159+
unused_attrs = []
145160
attributes.each do |name, value|
146161
if @fields.include?(name)
147162
obj.instance_variable_set("@#{name}", value)
148163
elsif @lists.key?(name)
149-
obj.instance_variable_set("@#{name}", value.map { |v| @lists[name].load(v) }) unless value.nil?
164+
unless value.nil?
165+
var = value.map do |v|
166+
val, ua = @lists[name].load(v)
167+
unused_attrs.concat ua
168+
val
169+
end
170+
obj.instance_variable_set("@#{name}", var)
171+
end
150172
elsif @refs.key?(name)
151-
obj.instance_variable_set("@#{name}", @refs[name].load(value)) unless value.nil?
173+
unless value.nil?
174+
val, ua = @refs[name].load(value)
175+
unused_attrs.concat ua
176+
obj.instance_variable_set("@#{name}", val)
177+
end
152178
else
153-
fail ArgumentError, "#{name} is not an attribute of object #{self.name}"
179+
unused_attrs << name
154180
end
155181
end
156-
obj
182+
return obj, unused_attrs
157183
end
158184

159185
def to_json(opts = {})
@@ -184,7 +210,10 @@ class Cert < ApiObject
184210
:sgc?,
185211
:validationType,
186212
:issues,
187-
:sct?
213+
:sct?,
214+
:mustStaple,
215+
:sha1Hash,
216+
:pinSha256
188217

189218
def valid?
190219
issues == 0
@@ -210,7 +239,9 @@ class ChainCert < ApiObject
210239
:revocationStatus,
211240
:crlRevocationStatus,
212241
:ocspRevocationStatus,
213-
:raw
242+
:raw,
243+
:sha1Hash,
244+
:pinSha256
214245

215246
def valid?
216247
issues == 0
@@ -273,7 +304,8 @@ class Info < ApiObject
273304
:clientMaxAssessments,
274305
:maxAssessments,
275306
:currentAssessments,
276-
:messages
307+
:messages,
308+
:newAssessmentCoolOff
277309
end
278310

279311
class SimClient < ApiObject
@@ -289,7 +321,8 @@ class Simulation < ApiObject
289321
has_fields :errorCode,
290322
:attempts,
291323
:protocolId,
292-
:suiteId
324+
:suiteId,
325+
:kxInfo
293326

294327
def success?
295328
error_code == 0
@@ -376,7 +409,23 @@ class EndpointDetails < ApiObject
376409
:poodleTls,
377410
:fallbackScsv?,
378411
:freak?,
379-
:hasSct
412+
:hasSct,
413+
:stsStatus,
414+
:stsPreload,
415+
:supportsAlpn,
416+
:rc4Only,
417+
:protocolIntolerance,
418+
:miscIntolerance,
419+
:openSSLLuckyMinus20,
420+
:logjam,
421+
:chaCha20Preference,
422+
:hstsPolicy,
423+
:hstsPreloads,
424+
:hpkpPolicy,
425+
:hpkpRoPolicy,
426+
:drownHosts,
427+
:drownErrors,
428+
:drownVulnerable
380429
end
381430

382431
class Endpoint < ApiObject
@@ -688,7 +737,7 @@ def output_common_info(r)
688737
print_status "Host: #{r.host}"
689738

690739
r.endpoints.each do |e|
691-
print_status "\t #{e.ip_address}\n"
740+
print_status "\t #{e.ip_address}"
692741
end
693742
end
694743

@@ -799,8 +848,6 @@ def run
799848
r = api.analyse(host: hostname, all: 'done')
800849
end
801850

802-
rescue
803-
print_error "Invalid parameters"
804851
rescue RequestRateTooHigh
805852
print_error "Request rate is too high, please slow down"
806853
rescue InternalError
@@ -809,5 +856,7 @@ def run
809856
print_error "Service is not available, sleep 15 minutes"
810857
rescue ServiceOverloaded
811858
print_error "Service is overloaded, sleep 30 minutes"
859+
rescue
860+
print_error "Invalid parameters"
812861
end
813862
end

0 commit comments

Comments
 (0)