Sha256: 6fd5c2cde621b512571adbdc5555416ef3139cfc37795fb777aecb61ce8ccbb2

Contents?: true

Size: 794 Bytes

Versions: 14

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Emitters
    class TheHive < Base
      # @return [true, false]
      def valid?
        the_hive.valid?
      end

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

        the_hive.alert.create(
          title: title,
          description: description,
          artifacts: artifacts.map(&:to_h),
          tags: tags
        )

        save_as_cache artifacts.map(&:data)
      end

      private

      def config_keys
        %w(THEHIVE_API_ENDPOINT THEHIVE_API_KEY)
      end

      def the_hive
        @the_hive ||= Mihari::TheHive.new
      end

      def cache
        @cache ||= Cache.new
      end

      def save_as_cache(data)
        cache.save data
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mihari-0.17.5 lib/mihari/emitters/the_hive.rb
mihari-0.17.4 lib/mihari/emitters/the_hive.rb
mihari-0.17.3 lib/mihari/emitters/the_hive.rb
mihari-0.17.2 lib/mihari/emitters/the_hive.rb
mihari-0.17.1 lib/mihari/emitters/the_hive.rb
mihari-0.17.0 lib/mihari/emitters/the_hive.rb
mihari-0.16.0 lib/mihari/emitters/the_hive.rb
mihari-0.15.0 lib/mihari/emitters/the_hive.rb
mihari-0.14.0 lib/mihari/emitters/the_hive.rb
mihari-0.13.2 lib/mihari/emitters/the_hive.rb
mihari-0.13.1 lib/mihari/emitters/the_hive.rb
mihari-0.13.0 lib/mihari/emitters/the_hive.rb
mihari-0.12.0 lib/mihari/emitters/the_hive.rb
mihari-0.11.0 lib/mihari/emitters/the_hive.rb