Class: HomographicSpoofing::Detector::Base

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

Direct Known Subclasses

Local, QuotedString

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Base

Returns a new instance of Base.



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

def initialize(label)
  @label = label
end

Class Method Details

.detected?(label) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.detections(label) ⇒ Object



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

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

Instance Method Details

#detected?Boolean

Returns:

  • (Boolean)


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

def detected?
  detections.any?
end

#detectionsObject



18
19
20
21
22
23
24
25
# File 'lib/homographic_spoofing/detector/base.rb', line 18

def detections
  rules.select(&:attack_detected?).map do |rule|
    HomographicSpoofing::Detector::Detection.new(rule.reason, rule.label)
  end
rescue Encoding::CompatibilityError
  # String must be in Unicode.
  [ HomographicSpoofing::Detector::Detection.new("invalid_unicode", label) ]
end