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)

/\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.



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

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.



66
67
68
# File 'lib/mta_sts/report.rb', line 66

def domain
  @domain
end

#ignoredObject (readonly)

Returns the value of attribute ignored.



66
67
68
# File 'lib/mta_sts/report.rb', line 66

def ignored
  @ignored
end

#ruaObject (readonly)

Returns the value of attribute rua.



66
67
68
# File 'lib/mta_sts/report.rb', line 66

def rua
  @rua
end

Class Method Details

.parse(text, domain: nil) ⇒ Object



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

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

Instance Method Details

#httpsObject



77
78
79
# File 'lib/mta_sts/report.rb', line 77

def https
  rua.grep(HTTPS)
end

#inspectObject



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

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

#mailtoObject



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

def mailto
  rua.grep(MAILTO)
end

#to_sObject



81
82
83
# File 'lib/mta_sts/report.rb', line 81

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