Sha256: 6abaec428ae7dc6bcf905f813da37e1b000abcd336fcc0ec8479118525481111

Contents?: true

Size: 929 Bytes

Versions: 3

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module Mihari
  class TheHive
    # @return [true, false]
    def api_endpont?
      ENV.key? "THEHIVE_API_ENDPOINT"
    end

    # @return [true, false]
    def api_key?
      ENV.key? "THEHIVE_API_KEY"
    end

    # @return [true, false]
    def valid?
      api_endpont? && api_key?
    end

    # @return [Hachi::API]
    def api
      @api ||= Hachi::API.new
    end

    # @return [Hash]
    def search(data:, data_type:, range: "all")
      api.artifact.search(data: data, data_type: data_type, range: range)
    end

    # @return [true, false]
    def exists?(data:, data_type:)
      res = search(data: data, data_type: data_type, range: "0-1")
      !res.empty?
    end

    # @return [Hash]
    def create_alert(title:, description:, artifacts:)
      api.alert.create(title: title, description: description, artifacts: artifacts, type: "external", source: "mihari")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mihari-0.2.1 lib/mihari/the_hive.rb
mihari-0.2.0 lib/mihari/the_hive.rb
mihari-0.1.0 lib/mihari/the_hive.rb