Sha256: 25c3e78aa14e42a8889cf8611b2d8de936ca98696a2d41f4939c912a9ce6e4e9
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true module Mihari module Analyzers # # urlscan.io analyzer # 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 ValueError, "allowed_data_types should be any of url, domain and ip." end def artifacts # @type [Array<Mihari::Models::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 Clients::Urlscan.new( api_key: api_key, pagination_interval: pagination_interval, timeout: timeout ) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.7.2 | lib/mihari/analyzers/urlscan.rb |
mihari-5.7.1 | lib/mihari/analyzers/urlscan.rb |
mihari-5.7.0 | lib/mihari/analyzers/urlscan.rb |