Sha256: 22a4c329a6887def6e843beee145243ce6805e3a548c113100f65eae6231b7ca

Contents?: true

Size: 763 Bytes

Versions: 25

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

require "net/ping"
require "uri"

module Mihari
  class TheHive
    attr_reader :artifact
    attr_reader :alert

    def initialize
      @artifact = Artifact.new
      @alert = Alert.new
    end

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

    private

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

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

    def ping?
      base_url = ENV.fetch("THEHIVE_API_ENDPOINT")
      base_url = base_url.end_with?("/") ? base_url[0..-2] : base_url
      url = "#{base_url}/index.html"

      http = Net::Ping::HTTP.new(url)
      http.ping?
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
mihari-0.17.5 lib/mihari/the_hive.rb
mihari-0.17.4 lib/mihari/the_hive.rb
mihari-0.17.3 lib/mihari/the_hive.rb
mihari-0.17.2 lib/mihari/the_hive.rb
mihari-0.17.1 lib/mihari/the_hive.rb
mihari-0.17.0 lib/mihari/the_hive.rb
mihari-0.16.0 lib/mihari/the_hive.rb
mihari-0.15.0 lib/mihari/the_hive.rb
mihari-0.14.0 lib/mihari/the_hive.rb
mihari-0.13.2 lib/mihari/the_hive.rb
mihari-0.13.1 lib/mihari/the_hive.rb
mihari-0.13.0 lib/mihari/the_hive.rb
mihari-0.12.0 lib/mihari/the_hive.rb
mihari-0.11.0 lib/mihari/the_hive.rb
mihari-0.10.0 lib/mihari/the_hive.rb
mihari-0.9.1 lib/mihari/the_hive.rb
mihari-0.9.0 lib/mihari/the_hive.rb
mihari-0.8.2 lib/mihari/the_hive.rb
mihari-0.8.1 lib/mihari/the_hive.rb
mihari-0.8.0 lib/mihari/the_hive.rb