Sha256: f0e9ecb7a4d03fea5ce1acf0a5c27b45d043ac47e52b4245ace2bad7ece8988d

Contents?: true

Size: 857 Bytes

Versions: 13

Compression:

Stored size: 857 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

      #
      # Search
      #
      # @return [Array<Hash>]
      #
      def search
        exclude = exclude_expired ? "expired" : nil
        api.search(query, exclude: exclude)
      rescue ::Crtsh::Error => _e
        []
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mihari-3.12.0 lib/mihari/analyzers/crtsh.rb
mihari-3.11.0 lib/mihari/analyzers/crtsh.rb
mihari-3.10.1 lib/mihari/analyzers/crtsh.rb
mihari-3.10.0 lib/mihari/analyzers/crtsh.rb
mihari-3.9.2 lib/mihari/analyzers/crtsh.rb
mihari-3.9.1 lib/mihari/analyzers/crtsh.rb
mihari-3.9.0 lib/mihari/analyzers/crtsh.rb
mihari-3.8.1 lib/mihari/analyzers/crtsh.rb
mihari-3.8.0 lib/mihari/analyzers/crtsh.rb
mihari-3.7.2 lib/mihari/analyzers/crtsh.rb
mihari-3.7.1 lib/mihari/analyzers/crtsh.rb
mihari-3.7.0 lib/mihari/analyzers/crtsh.rb
mihari-3.6.1 lib/mihari/analyzers/crtsh.rb