Class: Mihari::Analyzers::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



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

def initialize
  @the_hive = TheHive.new
end

Instance Attribute Details

#the_hiveObject (readonly)

Returns the value of attribute the_hive.



6
7
8
# File 'lib/mihari/analyzers/base.rb', line 6

def the_hive
  @the_hive
end

Instance Method Details

#artifactsArray<String>, Array<Mihari::Artifact>

Returns:

Raises:

  • (NotImplementedError)


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

def artifacts
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
end

#descriptionString

Returns:

  • (String)

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/mihari/analyzers/base.rb', line 23

def description
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
end

#runObject



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

def run
  Mihari.emitters.each do |emitter_class|
    emitter = emitter_class.new
    next unless emitter.valid?

    run_emitter emitter
  end
end

#run_emitter(emitter) ⇒ Object



41
42
43
44
45
# File 'lib/mihari/analyzers/base.rb', line 41

def run_emitter(emitter)
  emitter.emit(title: title, description: description, artifacts: unique_artifacts, tags: tags)
rescue StandardError => e
  puts "Emission by #{emitter.class} is failed: #{e}"
end

#tagsArray<String>

Returns:

  • (Array<String>)


28
29
30
# File 'lib/mihari/analyzers/base.rb', line 28

def tags
  []
end

#titleString

Returns:

  • (String)


18
19
20
# File 'lib/mihari/analyzers/base.rb', line 18

def title
  self.class.to_s.split("::").last
end