Sha256: 17697a49766c0e12869c358f8e62a88f0cd8977ad8a2b61f4bbda9e9be6df2a3

Contents?: true

Size: 628 Bytes

Versions: 46

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

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

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

        tags = 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(
          title: title,
          description: description,
          artifacts: artifacts,
          source: source,
          taggings: taggings
        )

        alert.save
        alert
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
mihari-4.12.0 lib/mihari/emitters/database.rb
mihari-4.11.0 lib/mihari/emitters/database.rb
mihari-4.10.0 lib/mihari/emitters/database.rb
mihari-4.9.0 lib/mihari/emitters/database.rb
mihari-4.8.0 lib/mihari/emitters/database.rb
mihari-4.7.4 lib/mihari/emitters/database.rb
mihari-4.7.3 lib/mihari/emitters/database.rb
mihari-4.7.2 lib/mihari/emitters/database.rb
mihari-4.7.1 lib/mihari/emitters/database.rb
mihari-4.7.0 lib/mihari/emitters/database.rb
mihari-4.6.1 lib/mihari/emitters/database.rb
mihari-4.6.0 lib/mihari/emitters/database.rb
mihari-4.5.3 lib/mihari/emitters/database.rb
mihari-4.5.2 lib/mihari/emitters/database.rb
mihari-4.5.1 lib/mihari/emitters/database.rb
mihari-4.5.0 lib/mihari/emitters/database.rb
mihari-4.4.1 lib/mihari/emitters/database.rb
mihari-4.4.0 lib/mihari/emitters/database.rb
mihari-4.3.0 lib/mihari/emitters/database.rb
mihari-4.2.0 lib/mihari/emitters/database.rb