Sha256: 0980689d95e9944037da72f4c583d47d253c3746732a33251b98f55e644698f6

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require "parallel"

module Mihari
  module Analyzers
    class PassiveSSL < Base
      attr_reader :query
      attr_reader :type

      attr_reader :title
      attr_reader :description
      attr_reader :tags

      ANALYZERS = [
        Mihari::Analyzers::CIRCL,
        Mihari::Analyzers::PassiveTotal,
      ].freeze

      def initialize(query, title: nil, description: nil, tags: [])
        super()

        @query = query
        @type = TypeChecker.detailed_type(query)

        @title = title || "PassiveSSL cross search"
        @description = description || "query = #{query}"
        @tags = tags
      end

      def artifacts
        Parallel.map(analyzers) do |analyzer|
          run_analyzer analyzer
        end.flatten
      end

      private

      def valid_type?
        %w(sha1).include? type
      end

      def analyzers
        raise InvalidInputError, "#{query}(type: #{type || 'unknown'}) is not supported." unless valid_type?

        ANALYZERS.map do |klass|
          klass.new(query)
        end
      end

      def run_analyzer(analyzer)
        analyzer.artifacts
      rescue ArgumentError, InvalidInputError => _e
        nil
      rescue ::PassiveCIRCL::Error, ::PassiveTotal::Error => _e
        nil
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mihari-1.4.1 lib/mihari/analyzers/passive_ssl.rb
mihari-1.4.0 lib/mihari/analyzers/passive_ssl.rb
mihari-1.3.2 lib/mihari/analyzers/passive_ssl.rb
mihari-1.3.1 lib/mihari/analyzers/passive_ssl.rb
mihari-1.3.0 lib/mihari/analyzers/passive_ssl.rb
mihari-1.2.1 lib/mihari/analyzers/passive_ssl.rb
mihari-1.2.0 lib/mihari/analyzers/passive_ssl.rb
mihari-1.1.1 lib/mihari/analyzers/passive_ssl.rb
mihari-1.1.0 lib/mihari/analyzers/passive_ssl.rb
mihari-1.0.1 lib/mihari/analyzers/passive_ssl.rb
mihari-1.0.0 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.5 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.4 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.3 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.2 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.1 lib/mihari/analyzers/passive_ssl.rb
mihari-0.17.0 lib/mihari/analyzers/passive_ssl.rb
mihari-0.16.0 lib/mihari/analyzers/passive_ssl.rb
mihari-0.15.0 lib/mihari/analyzers/passive_ssl.rb
mihari-0.14.0 lib/mihari/analyzers/passive_ssl.rb