Class: Mihari::Analyzers::Crtsh

Inherits:
Base show all
Defined in:
lib/mihari/analyzers/crtsh.rb

Overview

crt.sh analyzer

Constant Summary

Constants included from Concerns::Retriable

Concerns::Retriable::DEFAULT_CONDITION, Concerns::Retriable::RETRIABLE_ERRORS

Instance Attribute Summary collapse

Attributes inherited from Base

#query

Attributes inherited from Mihari::Actor

#options

Instance Method Summary collapse

Methods inherited from Base

#call, from_params, #ignore_error?, inherited, #normalized_artifacts, #pagination_interval, #pagination_limit, #parallel?, #result, #truncated_query

Methods inherited from Mihari::Actor

#call, configuration_keys, key, key_aliases, keys, #result, #retry_exponential_backoff, #retry_interval, #retry_times, #timeout, type, #validate_configuration!

Methods included from Concerns::Retriable

#retry_on_error

Methods included from Concerns::Configurable

#configuration_keys?, #configured?

Constructor Details

#initialize(query, options: nil, exclude_expired: true, match: nil) ⇒ Crtsh



21
22
23
24
25
26
# File 'lib/mihari/analyzers/crtsh.rb', line 21

def initialize(query, options: nil, exclude_expired: true, match: nil)
  super(query, options:)

  @exclude_expired = exclude_expired
  @match = match
end

Instance Attribute Details

#exclude_expiredBoolean (readonly)



10
11
12
# File 'lib/mihari/analyzers/crtsh.rb', line 10

def exclude_expired
  @exclude_expired
end

#matchString? (readonly)



13
14
15
# File 'lib/mihari/analyzers/crtsh.rb', line 13

def match
  @match
end

Instance Method Details

#artifactsObject



28
29
30
31
32
33
34
# File 'lib/mihari/analyzers/crtsh.rb', line 28

def artifacts
  exclude = exclude_expired ? "expired" : nil
  client.search(query, exclude:, match:).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