Sha256: d7f3054424b2e1d15c23857a85d2a7228446b83eb9ed8ddf731abafcdda9ce26

Contents?: true

Size: 788 Bytes

Versions: 9

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

require "crtsh"

module Mihari
  module Analyzers
    class Crtsh < Base
      param :query
      option :title, default: proc { "crt.sh search" }
      option :description, default: proc { "query = #{query}" }
      option :tags, default: proc { [] }
      option :exclude_expired, default: proc { true }

      def artifacts
        results = search
        name_values = results.filter_map { |result| result["name_value"] }
        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-3.6.0 lib/mihari/analyzers/crtsh.rb
mihari-3.5.0 lib/mihari/analyzers/crtsh.rb
mihari-3.4.1 lib/mihari/analyzers/crtsh.rb
mihari-3.4.0 lib/mihari/analyzers/crtsh.rb
mihari-3.3.0 lib/mihari/analyzers/crtsh.rb
mihari-3.2.0 lib/mihari/analyzers/crtsh.rb
mihari-3.1.0 lib/mihari/analyzers/crtsh.rb
mihari-3.0.1 lib/mihari/analyzers/crtsh.rb
mihari-3.0.0 lib/mihari/analyzers/crtsh.rb