Class: Mihari::Analyzers::Urlscan

Inherits:
Base
  • Object
show all
Defined in:
lib/mihari/analyzers/urlscan.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#ignore_old_artifacts, #ignore_threshold

Instance Method Summary collapse

Methods inherited from Base

inherited, #run, #run_emitter, #source

Methods included from Retriable

#retry_on_error

Methods included from Configurable

#configuration_values, #configured?

Constructor Details

#initialize(query, description: nil, tags: [], target_type: "url", title: nil, use_similarity: false) ⇒ Urlscan

Returns a new instance of Urlscan.

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mihari/analyzers/urlscan.rb', line 10

def initialize(
  query,
  description: nil,
  tags: [],
  target_type: "url",
  title: nil,
  use_similarity: false
)
  super()

  @query = query
  @title = title || "urlscan lookup"
  @description = description || "query = #{query}"
  @tags = tags

  @target_type = target_type
  @use_similarity = use_similarity

  raise InvalidInputError, "type should be url, domain or ip." unless valid_target_type?
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def description
  @description
end

#queryObject (readonly)

Returns the value of attribute query.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def query
  @query
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def tags
  @tags
end

#target_typeObject (readonly)

Returns the value of attribute target_type.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def target_type
  @target_type
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def title
  @title
end

#use_similarityObject (readonly)

Returns the value of attribute use_similarity.



8
9
10
# File 'lib/mihari/analyzers/urlscan.rb', line 8

def use_similarity
  @use_similarity
end

Instance Method Details

#artifactsObject



31
32
33
34
35
36
37
38
39
# File 'lib/mihari/analyzers/urlscan.rb', line 31

def artifacts
  result = search
  return [] unless result

  results = result["results"] || []
  results.map do |match|
    match.dig "page", target_type
  end.compact.uniq
end