Sha256: cd490c1c0f3e46eb89c3af5b6415719e7759fe08f87cd0c21dcb9d0e1e8c38c8
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module Mihari module Analyzers class Urlscan < Base SUPPORTED_DATA_TYPES = %w[url domain ip].freeze # @return [String, nil] attr_reader :api_key # @return [Array<String>] attr_reader :allowed_data_types # # @param [String] query # @param [Hash, nil] options # @param [String, nil] api_key # @param [Array<String>] allowed_data_types # def initialize(query, options: nil, api_key: nil, allowed_data_types: SUPPORTED_DATA_TYPES) super(query, options: options) @api_key = api_key || Mihari.config.urlscan_api_key @allowed_data_types = allowed_data_types return if valid_allowed_data_types? raise InvalidInputError, "allowed_data_types should be any of url, domain and ip." end def artifacts # @type [Array<Mihari::Artifact>] artifacts = client.search_with_pagination(query, pagination_limit: pagination_limit).map(&:artifacts).flatten artifacts.select do |artifact| allowed_data_types.include? artifact.data_type end end def configuration_keys %w[urlscan_api_key] end private def client @client ||= Clients::UrlScan.new(api_key: api_key, interval: interval) end # # Check whether a data type is valid or not # # @return [Boolean] # def valid_allowed_data_types? allowed_data_types.all? { |type| SUPPORTED_DATA_TYPES.include? type } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.4.3 | lib/mihari/analyzers/urlscan.rb |