Sha256: 295733e9115f35f2a4e4f6348dde48bec07d2f73fdc02e778c4e0f5508fea4e6

Contents?: true

Size: 963 Bytes

Versions: 9

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

require "crtsh"

module Mihari
  module Analyzers
    class Crtsh < Base
      attr_reader :title, :description, :query, :tags, :exclude_expired

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

        @query = query
        @title = title || "crt.sh lookup"
        @description = description || "query = #{query}"
        @tags = tags

        @exclude_expired = exclude_expired.nil? ? true : exclude_expired
      end

      def artifacts
        results = search
        name_values = results.map { |result| result["name_value"] }.compact
        name_values.map(&:lines).flatten.uniq.map(&:chomp)
      end

      private

      def api
        @api ||= ::Crtsh::API.new
      end

      def search
        exclude = exclude_expired ? "expired" : nil
        api.search(query, exclude: exclude)
      rescue ::Crtsh::Error => _e
        []
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mihari-2.4.0 lib/mihari/analyzers/crtsh.rb
mihari-2.3.1 lib/mihari/analyzers/crtsh.rb
mihari-2.3.0 lib/mihari/analyzers/crtsh.rb
mihari-2.2.1 lib/mihari/analyzers/crtsh.rb
mihari-2.2.0 lib/mihari/analyzers/crtsh.rb
mihari-2.1.0 lib/mihari/analyzers/crtsh.rb
mihari-2.0.0 lib/mihari/analyzers/crtsh.rb
mihari-1.5.1 lib/mihari/analyzers/crtsh.rb
mihari-1.5.0 lib/mihari/analyzers/crtsh.rb