Class: SSLyze::XML::HTTPHeaders::HTTPPublicKeyPinning

Inherits:
Object
  • Object
show all
Includes:
Attributes::Exception, Attributes::IsSupported, Types
Defined in:
lib/sslyze/xml/http_headers/http_public_key_pinning.rb

Overview

Represents the <httpPublicKeyPinning> XML element.

Since:

  • 1.0.0

Constant Summary

Constants included from Types

Types::Boolean, Types::None

Instance Method Summary collapse

Methods included from Attributes::Exception

#exception, #exception?

Methods included from Attributes::IsSupported

#is_supported?

Constructor Details

#initialize(node) ⇒ HTTPPublicKeyPinning

Since:

  • 1.0.0



23
24
25
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 23

def initialize(node)
  @node = node
end

Instance Method Details

#each_pin_sha256 {|sha256| ... } ⇒ Enumerator Also known as: each_sha256

Parses each pinSha256 XML element.

Yields:

  • (sha256)

    Yields each SHA256 checksum.

Yield Parameters:

  • sha256 (String)

    An individual pinned SHA256 checksum.

Returns:

  • (Enumerator)

Since:

  • 1.0.0



38
39
40
41
42
43
44
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 38

def each_pin_sha256
  return enum_for(__method__) unless block_given?

  @node.xpath('pinSha256').each do |element|
    yield element.inner_text
  end
end

#include_sub_domains?Boolean

Parses the includeSubDomains XML attribute.

Returns:

Since:

  • 1.0.0



64
65
66
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 64

def include_sub_domains?
  Boolean[@node['includeSubDomains']]
end

#is_backup_pin_configured?Boolean

Parses the isBackupPinConfigured XML attribute.

Returns:

Since:

  • 1.0.0



114
115
116
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 114

def is_backup_pin_configured?
  Boolean[@node['isBackupPinConfigured']]
end

#is_valid_pin_configured?Boolean

Parses the isValidPinConfigured XML attribute.

Returns:

Since:

  • 1.0.0



105
106
107
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 105

def is_valid_pin_configured?
  Boolean[@node['isValidPinConfigured']]
end

#max_ageInteger?

Parses the maxAge attribute.

Returns:

  • (Integer, nil)

Since:

  • 1.0.0



73
74
75
76
77
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 73

def max_age
  @max_age ||= if (value = @node['maxAge'])
                 value.to_i
               end
end

#pin_sha256sArray<String> Also known as: sha256s

Returns:

  • (Array<String>)

See Also:

Since:

  • 1.0.0



53
54
55
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 53

def pin_sha256s
  each_pin_sha256.to_a
end

#report_onlyBoolean

Parses the reportOnly XML attribute.

Returns:

Since:

  • 1.0.0



84
85
86
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 84

def report_only
  Boolean[@node['reportOnly']]
end

#report_uriString?

Parses the reportUri XML attribute.

Returns:

  • (String, nil)

Since:

  • 1.0.0



93
94
95
96
97
98
# File 'lib/sslyze/xml/http_headers/http_public_key_pinning.rb', line 93

def report_uri
  @report_uri ||= case (value = @node['reportUri'])
                  when nil, 'None' then nil
                  else                  value
                  end
end