Class: Mihari::Emitters::Database

Inherits:
Base
  • Object
show all
Defined in:
lib/mihari/emitters/database.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #run

Methods included from Retriable

#retry_on_error

Methods included from Configurable

#config_keys, #configuration_status, #configured?

Instance Method Details

#emit(title:, description:, artifacts:, source:, tags: []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mihari/emitters/database.rb', line 10

def emit(title:, description:, artifacts:, source:, tags: [])
  return if artifacts.empty?

  tags = tags.map { |name| Tag.find_or_create_by(name: name) }.compact.uniq
  taggings = tags.map { |tag| Tagging.new(tag_id: tag.id) }

  alert = Alert.new(
    title: title,
    description: description,
    artifacts: artifacts,
    source: source,
    taggings: taggings
  )

  alert.save
  alert
end

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/mihari/emitters/database.rb', line 6

def valid?
  true
end