Sha256: 4ce0751668605a0710ea2d3aeaf740b56d71f6977da0da13208279d5819c48a0

Contents?: true

Size: 654 Bytes

Versions: 7

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Services
    class AlertRunner
      include Dry::Monads[:result, :try]

      # @return [Mihari::Services::AlertProxy]
      attr_reader :alert

      def initialize(alert)
        @alert = alert
      end

      #
      # @return [Mihari::Alert]
      #
      def run
        emitter = Mihari::Emitters::Database.new(artifacts: alert.artifacts, rule: alert.rule)
        emitter.emit
      end

      #
      # @return [Dry::Monads::Result::Success<Mihari::Alert, nil>, Dry::Monads::Result::Failure]
      #
      def result
        Try[StandardError] { run }.to_result
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-5.5.0 lib/mihari/services/alert_runner.rb
mihari-5.4.9 lib/mihari/services/alert_runner.rb
mihari-5.4.8 lib/mihari/services/alert_runner.rb
mihari-5.4.7 lib/mihari/services/alert_runner.rb
mihari-5.4.6 lib/mihari/services/alert_runner.rb
mihari-5.4.5 lib/mihari/services/alert_runner.rb
mihari-5.4.4 lib/mihari/services/alert_runner.rb