class Mihari::Analyzers::Urlscan

Public Class Methods

new(*args, **kwargs) click to toggle source
Calls superclass method Mihari::Analyzers::Base::new
# File lib/mihari/analyzers/urlscan.rb, line 17
def initialize(*args, **kwargs)
  super

  raise InvalidInputError, "allowed_data_types should be any of url, domain and ip." unless valid_alllowed_data_types?
end

Public Instance Methods

artifacts() click to toggle source
# File lib/mihari/analyzers/urlscan.rb, line 23
def artifacts
  result = search
  return [] unless result

  results = result["results"] || []

  allowed_data_types.map do |type|
    results.filter_map do |match|
      match.dig "page", type
    end.uniq
  end.flatten
end

Private Instance Methods

api() click to toggle source
# File lib/mihari/analyzers/urlscan.rb, line 42
def api
  @api ||= ::UrlScan::API.new(Mihari.config.urlscan_api_key)
end
configuration_keys() click to toggle source
# File lib/mihari/analyzers/urlscan.rb, line 38
def configuration_keys
  %w[urlscan_api_key]
end
valid_alllowed_data_types?() click to toggle source

Check whether a data type is valid or not

@return [Boolean]

# File lib/mihari/analyzers/urlscan.rb, line 62
def valid_alllowed_data_types?
  allowed_data_types.all? { |type| SUPPORTED_DATA_TYPES.include? type }
end