Class: HomographicSpoofing::Detector::EmailAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/homographic_spoofing/detector/email_address.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email_address) ⇒ EmailAddress

Returns a new instance of EmailAddress.



10
11
12
# File 'lib/homographic_spoofing/detector/email_address.rb', line 10

def initialize(email_address)
  @email_address = email_address
end

Class Method Details

.detected?(email_address) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/homographic_spoofing/detector/email_address.rb', line 2

def self.detected?(email_address)
  new(email_address).detected?
end

.detections(email_address) ⇒ Object



6
7
8
# File 'lib/homographic_spoofing/detector/email_address.rb', line 6

def self.detections(email_address)
  new(email_address).detections
end

Instance Method Details

#detected?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/homographic_spoofing/detector/email_address.rb', line 14

def detected?
  detections.any?
end

#detectionsObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/homographic_spoofing/detector/email_address.rb', line 18

def detections
  mail_address = mail_address_wrap(email_address)
  [].tap do |result|
    result.concat detector_for(part: mail_address.name,   type: "quoted_string").detections if mail_address.name
    result.concat detector_for(part: mail_address.local,  type: "local").detections if mail_address.local
    result.concat detector_for(part: mail_address.domain, type: "idn").detections if mail_address.domain
  end
rescue Mail::Field::FieldError
  # Do not analyse invalid email addresses.
  []
end