Sha256: 913d1cbc75e728c8e4442a25ed3db4db80d48e5af380465e01c61e98003a9587

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    #
    # crt.sh analyzer
    #
    class Crtsh < Base
      # @return [Boolean]
      attr_reader :exclude_expired

      #
      # @param [String] query
      # @param [Hash, nil] options
      # @param [Bool] exclude_expired
      #
      def initialize(query, options: nil, exclude_expired: true)
        super(query, options: options)

        @exclude_expired = exclude_expired
      end

      def artifacts
        exclude = exclude_expired ? "expired" : nil
        client.search(query, exclude: exclude).map do |result|
          values = result["name_value"].to_s.lines.map(&:chomp).reject { |value| value.starts_with?("*.") }
          values.map { |value| Models::Artifact.new(data: value, metadata: result) }
        end.flatten
      end

      private

      #
      # @return [Mihari::Clients::Crtsh]
      #
      def client
        Mihari::Clients::Crtsh.new(timeout: timeout)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mihari-7.0.0 lib/mihari/analyzers/crtsh.rb