Sha256: 68ee31e48f94f2659d17278df01ab244ecdcfcc95ab4368ac7bc9d5285dcdf3b
Contents?: true
Size: 1.29 KB
Versions: 7
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Mihari module Commands # # Search sub-commands # module Search class << self def included(thor) thor.class_eval do include Concerns::DatabaseConnectable desc "search [PATH_OR_ID]", "Search by a rule" around :with_db_connection method_option :force_overwrite, type: :boolean, default: false, aliases: "-f", desc: "Force overwriting a rule" # # Search by a rule # # @param [String] path_or_id # def search(path_or_id) force_overwrite = options["force_overwrite"] || false message = "Are you sure you want to overwrite this rule? (y/n)" # @type [Mihari::Models::Alert] alert = Dry::Monads::Try[StandardError] do # @type [Mihari::Rule] rule = Services::RuleBuilder.call(path_or_id) exit 0 if rule.diff? && !force_overwrite && !yes?(message) rule.update_or_create rule.call end.value! data = Entities::Alert.represent(alert) puts JSON.pretty_generate(data.as_json) end end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems