Sha256: 4713d6f2c7ebae10c9c3d2542f1a0262354c65cede82716753e3408037891631

Contents?: true

Size: 642 Bytes

Versions: 9

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

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

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

9 entries across 9 versions & 1 rubygems

Version Path
mihari-5.5.0 lib/mihari/emitters/database.rb
mihari-5.4.9 lib/mihari/emitters/database.rb
mihari-5.4.8 lib/mihari/emitters/database.rb
mihari-5.4.7 lib/mihari/emitters/database.rb
mihari-5.4.6 lib/mihari/emitters/database.rb
mihari-5.4.5 lib/mihari/emitters/database.rb
mihari-5.4.4 lib/mihari/emitters/database.rb
mihari-5.4.3 lib/mihari/emitters/database.rb
mihari-5.4.2 lib/mihari/emitters/database.rb