Sha256: e097d0ed954bd510ca635c2570c08b9010c7031fdf76cfc55458ab4879732f04

Contents?: true

Size: 912 Bytes

Versions: 25

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module Mihari
  class TheHive
    class Artifact < Base
      # @return [Array]
      def search(data:, data_type:, range: "all")
        api.artifact.search({ data: data, data_type: data_type }, range: range)
      end

      # @return [Array]
      def search_all(data:, range: "all")
        api.artifact.search({ data: data }, 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 [Array<Mihari::Artifact>]
      def find_non_existing_artifacts(artifacts)
        data = artifacts.map(&:data)
        results = search_all(data: data)
        keys = results.map { |result| result.dig("data") }.compact.uniq
        artifacts.reject do |artifact|
          keys.include? artifact.data
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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