Class: PhisherPhinder::MailParser::AuthenticationHeaders::AuthResultsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/phisher_phinder/mail_parser/authentication_headers/auth_results_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(ip_factory:) ⇒ AuthResultsParser

Returns a new instance of AuthResultsParser.



7
8
9
# File 'lib/phisher_phinder/mail_parser/authentication_headers/auth_results_parser.rb', line 7

def initialize(ip_factory:)
  @ip_factory = ip_factory
end

Instance Method Details

#parse(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/phisher_phinder/mail_parser/authentication_headers/auth_results_parser.rb', line 11

def parse(value)
  output_template = {authserv_id: nil, auth: [], dkim: [], dmarc: [], iprev: [], spf: []}

  components(value).inject(output_template) do |output, component|
    component_type, parsed_component = parse_component(component)
    if output[component_type].respond_to?(:<<)
      output.merge(component_type => (output[component_type] << parsed_component))
    else
      output.merge(component_type => parsed_component)
    end
  end
end