Class: MtaSts::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/mta_sts/report.rb,
lib/mta_sts/report/result.rb

Defined Under Namespace

Classes: Invalid, Result

Constant Summary collapse

REPORT_VERSION =
"TLSRPTv1"
REPORT_RECORD =

RFC 8460 §3: tlsrpt-version = %s"v=TLSRPTv1", then 1*(field-delim tlsrpt-field). Its field-delim is *WSP ";" *WSP while its prose discards records not beginning with "v=TLSRPTv1;" — the same contradiction RFC 8461 §3.1 has

/\Av=#{REPORT_VERSION};/
FIELD_DELIM =
";"
RUA_FIELD =

RFC 8460 §3

"rua="
URI_DELIM =
","
MAILTO =

RFC 3986 §3.1 — scheme is case-insensitive

/\Amailto:/i
HTTPS =
/\Ahttps:/i
SCHEMES =
[ MAILTO, HTTPS ].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rua:, domain: nil) ⇒ Report

Returns a new instance of Report.



70
71
72
73
# File 'lib/mta_sts/report.rb', line 70

def initialize(rua:, domain: nil)
  @rua, @ignored = validated_destinations(rua)
  @domain = domain && Policy.normalize(domain)
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



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

def domain
  @domain
end

#ignoredObject (readonly)

Returns the value of attribute ignored.



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

def ignored
  @ignored
end

#ruaObject (readonly)

Returns the value of attribute rua.



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

def rua
  @rua
end

Class Method Details

.parse(text, domain: nil) ⇒ Object



21
22
23
# File 'lib/mta_sts/report.rb', line 21

def parse(text, domain: nil)
  new rua: uris_in(fields_in(text)), domain: domain
end

Instance Method Details

#httpsObject



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

def https
  rua.grep(HTTPS)
end

#inspectObject



87
88
89
# File 'lib/mta_sts/report.rb', line 87

def inspect
  "#<#{self.class.name} rua: #{rua.inspect}, ignored: #{ignored.inspect}>"
end

#mailtoObject



75
76
77
# File 'lib/mta_sts/report.rb', line 75

def mailto
  rua.grep(MAILTO)
end

#to_sObject



83
84
85
# File 'lib/mta_sts/report.rb', line 83

def to_s
  "v=#{REPORT_VERSION}; #{RUA_FIELD}#{rua.join(", ")}"
end