Class: SslscanWrapper::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/sslscan_wrapper/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Report

Initialize a new report object

Examples

content = File.read('report.xml')
SslscanWrapper::Report.new(content)

Returns a new SslscanWrapper::Report



18
19
20
21
# File 'lib/sslscan_wrapper/report.rb', line 18

def initialize(output)
  @body = output
  @doc = Nokogiri::XML(@body)
end

Instance Attribute Details

#bodyObject (readonly)

The content body of the report



7
8
9
# File 'lib/sslscan_wrapper/report.rb', line 7

def body
  @body
end

#docObject (readonly)

The nokogiri document object



9
10
11
# File 'lib/sslscan_wrapper/report.rb', line 9

def doc
  @doc
end

Instance Method Details

#altnamesObject

Subject alternative names of the certificate



58
59
60
# File 'lib/sslscan_wrapper/report.rb', line 58

def altnames
  @doc.xpath('//certificate/altnames').first.content
end

#cipher_supported?(cipher) ⇒ Boolean

Is the cipher supported?

Returns:

  • (Boolean)


95
96
97
# File 'lib/sslscan_wrapper/report.rb', line 95

def cipher_supported?(cipher)
  @doc.xpath("//cipher[@cipher=\"#{cipher}\"]").count > 0
end

#ciphersObject

Returns a list of supported ciphers



90
91
92
# File 'lib/sslscan_wrapper/report.rb', line 90

def ciphers
  @doc.xpath('//cipher/@cipher').map(&:value)
end

#compression_supported?Boolean

Is ssl compression supported on target?

Returns:

  • (Boolean)


34
35
36
# File 'lib/sslscan_wrapper/report.rb', line 34

def compression_supported?
  @doc.xpath('//compression/@supported').first.value == '1'
end

#expired?Boolean

Is the certificate expired?

Returns:

  • (Boolean)


73
74
75
# File 'lib/sslscan_wrapper/report.rb', line 73

def expired?
  @doc.xpath('//certificate/expired').first.content == 'true'
end

#heartbleed_vulnerable?Boolean

Are there any heartblead vulnerable SSL/TLS protocol versions?

Returns:

  • (Boolean)


110
111
112
# File 'lib/sslscan_wrapper/report.rb', line 110

def heartbleed_vulnerable?
  @doc.xpath('//heartbleed[@vulnerable="1"]').count > 0
end

#heartbleed_vulnerable_sslversionsObject

Returns a list of SSL/TLS protocol versions vulnerable to heartbleed



105
106
107
# File 'lib/sslscan_wrapper/report.rb', line 105

def heartbleed_vulnerable_sslversions
  @doc.xpath('//heartbleed[@vulnerable="1"]/@sslversion').map(&:value)
end

#hostObject

The hostname of the scanned host



24
25
26
# File 'lib/sslscan_wrapper/report.rb', line 24

def host
  @doc.xpath('//ssltest/@host').first.value
end

#issuerObject

Issuer of the certificate



63
64
65
# File 'lib/sslscan_wrapper/report.rb', line 63

def issuer
  @doc.xpath('//certificate/issuer').first.content
end

#not_afterObject

Time the certificate is no longer valid



84
85
86
87
# File 'lib/sslscan_wrapper/report.rb', line 84

def not_after
  time_str = @doc.xpath('//certificate/not-valid-after').first.content
  Time.parse(time_str)
end

#not_beforeObject

Time the certificate starts to be valid



78
79
80
81
# File 'lib/sslscan_wrapper/report.rb', line 78

def not_before
  time_str = @doc.xpath('//certificate/not-valid-before').first.content
  Time.parse(time_str)
end

#portObject

The port of the scan report



29
30
31
# File 'lib/sslscan_wrapper/report.rb', line 29

def port
  @doc.xpath('//ssltest/@port').first.value
end

#preferred_ciphersObject

Returns a list of preferred ciphers



100
101
102
# File 'lib/sslscan_wrapper/report.rb', line 100

def preferred_ciphers
  @doc.xpath('//cipher[@status="preferred"]/@cipher').map(&:value)
end

#renegotiation_secure?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/sslscan_wrapper/report.rb', line 43

def renegotiation_secure?
  @doc.xpath('//renegotiation/@secure').first.value == '1'
end

#renegotiation_supported?Boolean

Does the target support TLS renegotiation?

Returns:

  • (Boolean)


39
40
41
# File 'lib/sslscan_wrapper/report.rb', line 39

def renegotiation_supported?
  @doc.xpath('//renegotiation/@supported').first.value == '1'
end

#self_signed?Boolean

Is the certificate a self-signed certificate?

Returns:

  • (Boolean)


68
69
70
# File 'lib/sslscan_wrapper/report.rb', line 68

def self_signed?
  @doc.xpath('//certificate/self-signed').first.content == 'true'
end

#signature_algorithmObject

Signature algorithm used in the certificate



48
49
50
# File 'lib/sslscan_wrapper/report.rb', line 48

def signature_algorithm
  @doc.xpath('//certificate/signature-algorithm').first.content
end

#subjectObject

Subject of the certificate



53
54
55
# File 'lib/sslscan_wrapper/report.rb', line 53

def subject
  @doc.xpath('//certificate/subject').first.content
end