Class: Koji::Plugins::Domain

Inherits:
Base
  • Object
show all
Defined in:
lib/koji/plugins/domain.rb

Constant Summary collapse

SUSPICIOUS_WORDS =
%w(dev development stg staging test testing).freeze

Instance Attribute Summary

Attributes inherited from Base

#website

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #name, #report

Constructor Details

This class inherits a constructor from Koji::Plugins::Base

Instance Method Details

#domainObject



10
11
12
# File 'lib/koji/plugins/domain.rb', line 10

def domain
  @domain ||= PublicSuffix.parse(website.url.hostname)
end

#evidence_listObject



14
15
16
17
18
# File 'lib/koji/plugins/domain.rb', line 14

def evidence_list
  @evidence_list ||= domain.trd.to_s.split(".").map do |part|
    "#{domain} contains a suspicious keyword: #{part}." if SUSPICIOUS_WORDS.include?(part)
  end.compact
end

#scoreObject



20
21
22
# File 'lib/koji/plugins/domain.rb', line 20

def score
  evidence_list.empty? ? 0 : 50
end