Skip to content

Commit 752c324

Browse files
author
Brent Cook
committed
wrap print* functions in report_* wrappers
Preserve the semantics in the code, but don't call functions like 'print_error' unless there is an actual error running the module. Fix spelling of 'Overall'.
1 parent 9d78aa9 commit 752c324

File tree

1 file changed

+65
-49
lines changed

1 file changed

+65
-49
lines changed

modules/auxiliary/gather/ssllabs_scan.rb

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,22 @@ def initialize(info = {})
429429
], self.class)
430430
end
431431

432+
def report_good(line)
433+
print_good line
434+
end
435+
436+
def report_warning(line)
437+
print_warning line
438+
end
439+
440+
def report_bad(line)
441+
print_warning line
442+
end
443+
444+
def report_status(line)
445+
print_status line
446+
end
447+
432448
def output_endpoint_data(r)
433449
ssl_protocols = [
434450
{ id: 771, name: "TLS", version: "1.2", secure: true, active: false },
@@ -438,21 +454,21 @@ def output_endpoint_data(r)
438454
{ id: 2, name: "SSL", version: "2.0", secure: false, active: false }
439455
]
440456

441-
print_status "-----------------------------------------------------------------"
442-
print_status "Report for #{r.server_name} (#{r.ip_address})"
443-
print_status "-----------------------------------------------------------------"
457+
report_status "-----------------------------------------------------------------"
458+
report_status "Report for #{r.server_name} (#{r.ip_address})"
459+
report_status "-----------------------------------------------------------------"
444460

445461
case r.grade.to_s
446462
when "A+", "A", "A-"
447-
print_good "Overal rating: #{r.grade}"
463+
report_good "Overall rating: #{r.grade}"
448464
when "B"
449-
print_warning "Overal rating: #{r.grade}"
465+
report_warning "Overall rating: #{r.grade}"
450466
when "C", "D", "E", "F"
451-
print_error "Overal rating: #{r.grade}"
467+
report_bad "Overall rating: #{r.grade}"
452468
when "M"
453-
print_error "Overal rating: #{r.grade} - Certificate name mismatch"
469+
report_bad "Overall rating: #{r.grade} - Certificate name mismatch"
454470
when "T"
455-
print_error "Overal rating: #{r.grade} - Server's certificate is not trusted"
471+
report_bad "Overall rating: #{r.grade} - Server's certificate is not trusted"
456472
end
457473

458474
# Supported protocols
@@ -464,105 +480,105 @@ def output_endpoint_data(r)
464480
ssl_protocols.each do |proto|
465481
if proto[:active]
466482
if proto[:secure]
467-
print_good "#{proto[:name]} #{proto[:version]} - Yes"
483+
report_good "#{proto[:name]} #{proto[:version]} - Yes"
468484
else
469-
print_error "#{proto[:name]} #{proto[:version]} - Yes"
485+
report_bad "#{proto[:name]} #{proto[:version]} - Yes"
470486
end
471487
else
472-
print_status "#{proto[:name]} #{proto[:version]} - No"
488+
report_good "#{proto[:name]} #{proto[:version]} - No"
473489
end
474490
end
475491

476492
# Renegotioation
477493
case
478494
when r.details.reneg_support == 0
479-
print_warning "Secure renegotiation is not supported"
495+
report_warning "Secure renegotiation is not supported"
480496
when r.details.reneg_support[0] == 1
481-
print_error "Insecure client-initiated renegotiation is supported"
497+
report_bad "Insecure client-initiated renegotiation is supported"
482498
when r.details.reneg_support[1] == 1
483-
print_good "Secure renegotiation is supported"
499+
report_good "Secure renegotiation is supported"
484500
when r.details.reneg_support[2] == 1
485-
print_warning "Secure client-initiated renegotiation is supported"
501+
report_warning "Secure client-initiated renegotiation is supported"
486502
when r.details.reneg_support[3] == 1
487-
print_warning "Server requires secure renegotiation support"
503+
report_warning "Server requires secure renegotiation support"
488504
end
489505

490506
# BEAST
491507
if r.details.vuln_beast?
492-
print_error "BEAST attack - Yes"
508+
report_bad "BEAST attack - Yes"
493509
else
494-
print_good "BEAST attack - No"
510+
report_good "BEAST attack - No"
495511
end
496512

497513
# puts "POODLE (SSLv3)- ?"
498514

499515
# POODLE TLS
500516
case r.details.poodle_tls
501517
when -1
502-
print_warning "POODLE TLS - Test failed"
518+
report_warning "POODLE TLS - Test failed"
503519
when 0
504-
print_warning "POODLE TLS - Unknown"
520+
report_warning "POODLE TLS - Unknown"
505521
when 1
506-
print_good "POODLE TLS - No"
522+
report_good "POODLE TLS - No"
507523
when 2
508-
print_error "POODLE TLS - Yes"
524+
report_bad "POODLE TLS - Yes"
509525
end
510526

511527
# Downgrade attack prevention
512528
if r.details.fallback_scsv?
513-
print_good "Downgrade attack prevention - Yes"
529+
report_good "Downgrade attack prevention - Yes"
514530
else
515-
print_error "Downgrade attack prevention - No"
531+
report_bad "Downgrade attack prevention - No"
516532
end
517533

518534
# RC4
519535
if r.details.supports_rc4?
520-
print_warning "RC4 - Server supports at least one RC4 suite"
536+
report_warning "RC4 - Server supports at least one RC4 suite"
521537
else
522-
print_good "RC4 - No"
538+
report_good "RC4 - No"
523539
end
524540

525541
# RC4 with modern browsers
526-
print_warning "RC4 is used with modern clients" if r.details.rc4_with_modern?
542+
report_warning "RC4 is used with modern clients" if r.details.rc4_with_modern?
527543

528544
# Heartbeat
529545
if r.details.heartbeat?
530-
print_status "Heartbeat (extension) - Yes"
546+
report_status "Heartbeat (extension) - Yes"
531547
else
532-
print_status "Heartbeat (extension) - No"
548+
report_status "Heartbeat (extension) - No"
533549
end
534550

535551
# Heartbleed
536552
if r.details.heartbleed?
537-
print_error "Heartbleed (vulnerability) - Yes"
553+
report_bad "Heartbleed (vulnerability) - Yes"
538554
else
539-
print_good "Heartbeat (vulnerability) - No"
555+
report_good "Heartbeat (vulnerability) - No"
540556
end
541557

542558
# OpenSSL CCS
543559
case r.details.open_ssl_ccs
544560
when -1
545-
print_warning "OpenSSL CCS vulnerability (CVE-2014-0224) - Test failed"
561+
report_warning "OpenSSL CCS vulnerability (CVE-2014-0224) - Test failed"
546562
when 0
547-
print_warning "OpenSSL CCS vulnerability (CVE-2014-0224) - Unknown"
563+
report_warning "OpenSSL CCS vulnerability (CVE-2014-0224) - Unknown"
548564
when 1
549-
print_good "OpenSSL CCS vulnerability (CVE-2014-0224) - No"
565+
report_good "OpenSSL CCS vulnerability (CVE-2014-0224) - No"
550566
when 2
551-
print_error "OpenSSL CCS vulnerability (CVE-2014-0224) - Possibly vulnerable, but not exploitable"
567+
report_bad "OpenSSL CCS vulnerability (CVE-2014-0224) - Possibly vulnerable, but not exploitable"
552568
when 3
553-
print_error "OpenSSL CCS vulnerability (CVE-2014-0224) - Vulnerable and exploitable"
569+
report_bad "OpenSSL CCS vulnerability (CVE-2014-0224) - Vulnerable and exploitable"
554570
end
555571

556572
# Forward Secrecy
557573
case
558574
when r.details.forward_secrecy == 0
559-
print_error "Forward Secrecy - No"
575+
report_bad "Forward Secrecy - No"
560576
when r.details.forward_secrecy[0] == 1
561-
print_error "Forward Secrecy - With some browsers"
577+
report_bad "Forward Secrecy - With some browsers"
562578
when r.details.forward_secrecy[1] == 1
563-
print_good "Forward Secrecy - With modern browsers"
579+
report_good "Forward Secrecy - With modern browsers"
564580
when r.details.forward_secrecy[2] == 1
565-
print_good "Forward Secrecy - Yes (with most browsers)"
581+
report_good "Forward Secrecy - Yes (with most browsers)"
566582
end
567583

568584
# HSTS
@@ -572,31 +588,31 @@ def output_endpoint_data(r)
572588
str += ":max-age=#{r.details.sts_max_age}"
573589
end
574590
str += ":includeSubdomains" if r.details.sts_subdomains?
575-
print_good str
591+
report_good str
576592
else
577-
print_error "Strict Transport Security (HSTS) - No"
593+
report_bad "Strict Transport Security (HSTS) - No"
578594
end
579595

580596
# HPKP
581597
if r.details.pkp_response_header
582-
print_good "Public Key Pinning (HPKP) - Yes"
598+
report_good "Public Key Pinning (HPKP) - Yes"
583599
else
584-
print_warning "Public Key Pinning (HPKP) - No"
600+
report_warning "Public Key Pinning (HPKP) - No"
585601
end
586602

587603
# Compression
588604
if r.details.compression_methods == 0
589-
print_good "Compression - No"
605+
report_good "Compression - No"
590606
elsif (r.details.session_tickets & 1) != 0
591-
print_warning "Compression - Yes (Deflate)"
607+
report_warning "Compression - Yes (Deflate)"
592608
end
593609

594610
# Session Resumption
595611
case r.details.session_resumption
596612
when 0
597613
print_status "Session resumption - No"
598614
when 1
599-
print_warning "Session resumption - No (IDs assigned but not accepted)"
615+
report_warning "Session resumption - No (IDs assigned but not accepted)"
600616
when 2
601617
print_status "Session resumption - Yes"
602618
end
@@ -608,9 +624,9 @@ def output_endpoint_data(r)
608624
when r.details.session_tickets[0] == 1
609625
print_status "Session tickets - Yes"
610626
when r.details.session_tickets[1] == 1
611-
print_good "Session tickets - Implementation is faulty"
627+
report_good "Session tickets - Implementation is faulty"
612628
when r.details.session_tickets[2] == 1
613-
print_warning "Session tickets - Server is intolerant to the extension"
629+
report_warning "Session tickets - Server is intolerant to the extension"
614630
end
615631

616632
# OCSP stapling

0 commit comments

Comments
 (0)