Sha256: 3aad22ec3b8acdf332c219d2a695ccab3575d3d29e1fb49bb20d786eda48d5b0

Contents?: true

Size: 633 Bytes

Versions: 7

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Emitters
    class Database < Base
      def valid?
        configured?
      end

      #
      # Create an alert
      #
      # @return [Mihari::Alert]
      #
      def emit
        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

      def configuration_keys
        %w[database_url]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-5.4.1 lib/mihari/emitters/database.rb
mihari-5.4.0 lib/mihari/emitters/database.rb
mihari-5.3.2 lib/mihari/emitters/database.rb
mihari-5.3.1 lib/mihari/emitters/database.rb
mihari-5.3.0 lib/mihari/emitters/database.rb
mihari-5.2.4 lib/mihari/emitters/database.rb
mihari-5.2.3 lib/mihari/emitters/database.rb