Sha256: a07fd0957f22237a35500ca5ab708ec2f04fb23e237b7e0bfeda4db7df836a23

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Commands
    module Validator
      def self.included(thor)
        thor.class_eval do
          desc "validate [PATH]", "Validate a rule file"
          #
          # Validate format of a rule
          #
          # @param [String] path
          #
          # @return [nil]
          #
          def validate(path)
            rule = Structs::Rule.from_path_or_id(path)

            begin
              rule.validate!
              Mihari.logger.info "Valid format. The input is parsed as the following:"
              Mihari.logger.info rule.data.to_yaml
            rescue RuleValidationError
              nil
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mihari-5.0.1 lib/mihari/commands/validator.rb
mihari-5.0.0 lib/mihari/commands/validator.rb