Class: HomographicSpoofing::Detector::Base
- Inherits:
-
Object
- Object
- HomographicSpoofing::Detector::Base
- Defined in:
- lib/homographic_spoofing/detector/base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #detected? ⇒ Boolean
- #detections ⇒ Object
-
#initialize(label) ⇒ Base
constructor
A new instance of Base.
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
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
14 15 16 |
# File 'lib/homographic_spoofing/detector/base.rb', line 14 def detected? detections.any? end |
#detections ⇒ Object
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 |