Class: Mihari::Emitters::Database

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

Constant Summary

Constants included from Mixins::Retriable

Mixins::Retriable::DEFAULT_ON

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #run

Methods included from Mixins::Retriable

#retry_on_error

Methods included from Mixins::Configurable

#configuration_values, #configured?

Constructor Details

This class inherits a constructor from Mihari::Emitters::Base

Instance Method Details

#configuration_keysObject



33
34
35
# File 'lib/mihari/emitters/database.rb', line 33

def configuration_keys
  %w[database_url]
end

#emit(artifacts:, rule:) ⇒ Mihari::Alert

Create an alert

Parameters:

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mihari/emitters/database.rb', line 18

def emit(artifacts:, rule:)
  return if artifacts.empty?

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

  alert = Alert.new(
    artifacts: artifacts,
    taggings: taggings,
    rule_id: rule.id
  )
  alert.save
  alert
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  true
end