Class: PhisherPhinder::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/phisher_phinder/mail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_email:, original_headers:, original_body:, headers:, tracing_headers:, body:, authentication_headers:) ⇒ Mail

Returns a new instance of Mail.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/phisher_phinder/mail.rb', line 13

def initialize(
  original_email:, original_headers:, original_body:, headers:, tracing_headers:, body:, authentication_headers:
)
  @original_email = original_email
  @original_headers = original_headers
  @original_body = original_body
  @headers = headers
  @tracing_headers = tracing_headers
  @authentication_headers = authentication_headers
  @body = body
end

Instance Attribute Details

#authentication_headersObject (readonly)

Returns the value of attribute authentication_headers.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def authentication_headers
  @authentication_headers
end

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def headers
  @headers
end

#original_bodyObject (readonly)

Returns the value of attribute original_body.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def original_body
  @original_body
end

#original_emailObject (readonly)

Returns the value of attribute original_email.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def original_email
  @original_email
end

#original_headersObject (readonly)

Returns the value of attribute original_headers.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def original_headers
  @original_headers
end

#tracing_headersObject (readonly)

Returns the value of attribute tracing_headers.



5
6
7
# File 'lib/phisher_phinder/mail.rb', line 5

def tracing_headers
  @tracing_headers
end

Instance Method Details



33
34
35
36
37
38
# File 'lib/phisher_phinder/mail.rb', line 33

def hypertext_links
  body_as_html.
    xpath('//a').
    select { |el| el.attributes['href'] }.
    map { |el| BodyHyperlink.new(el.attributes['href'].value, el.text) }
end

#reply_to_addressesObject



25
26
27
28
29
30
31
# File 'lib/phisher_phinder/mail.rb', line 25

def reply_to_addresses
  (@headers[:reply_to] || []).map do |value_string|
    value_string.split(",")
  end.flatten.map do |email_address_string|
    extract_email_address(email_address_string)
  end.uniq
end