Sha256: ce35a52514f321c0d6c5120f6d70cc0f39b2078433cc1c7ff23048dd2f74db42
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Mihari module Analyzers class Base attr_reader :the_hive def initialize @the_hive = TheHive.new end # @return [Array<String>, Array<Mihari::Artifact>] def artifacts raise NotImplementedError, "You must implement #{self.class}##{__method__}" end # @return [String] def title self.class.to_s.split("::").last end # @return [String] def description raise NotImplementedError, "You must implement #{self.class}##{__method__}" end def run(reject_exists_ones: true) unique_artifacts = normalized_artifacts.reject do |artifact| reject_exists_ones & the_hive.valid? && the_hive.exists?(data: artifact.data, data_type: artifact.data_type) end Mihari.notifiers.each do |notifier_class| notifier = notifier_class.new next unless notifier.valid? notifier.notify(title: title, description: description, artifacts: unique_artifacts) end end private # @return [Array<Mihari::Artifact>] def normalized_artifacts artifacts.map do |artifact| artifact.is_a?(Artifact) ? artifact : Artifact.new(artifact) end.select(&:valid?) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mihari-0.2.1 | lib/mihari/analyzers/base.rb |
mihari-0.2.0 | lib/mihari/analyzers/base.rb |
mihari-0.1.0 | lib/mihari/analyzers/base.rb |