Sha256: cbaa61b48bded24a2fdcbd5b7db2d301bd65c0ea1835cc31d62bd0d7adb90847

Contents?: true

Size: 1.35 KB

Versions: 18

Compression:

Stored size: 1.35 KB

Contents

module Metasploit
  module Model
    module Search
      # Namespace for search operations.  {parse} acts as a factory to parse a `String` and return a type-specific
      # operation.
      module Operation
        # @param options [Hash{Symbol => Object}]
        # @option options [Metasploit::Module::Search::Query] :query The query that the parsed operation is a part.
        # @option options [String] :formatted_operation A '<operator>:<value>' string.
        # @return [Metasploit::Model::Search::Operation::Base, Array<Metasploit::Model::Search::Operation::Base>]
        #   operation(s) parsed from the formatted operation.
        # @raise [KeyError] unless :formatted_operation is given.
        # @raise [KeyError] unless :query is given.
        def self.parse(options={})
          formatted_operation = options.fetch(:formatted_operation)
          query = options.fetch(:query)

          formatted_operator, formatted_value = formatted_operation.split(':', 2)
          operator = query.parse_operator(formatted_operator)

          # formatted_value will be nil if formatted_operation did not contain a ':', it should be treated the same
          # as nothing after the ':'.
          formatted_value ||= ''
          operation_or_operations = operator.operate_on(formatted_value)

          operation_or_operations
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
metasploit-model-0.27.0.pre.dep.pre.railties lib/metasploit/model/search/operation.rb
metasploit-model-0.26.1-java lib/metasploit/model/search/operation.rb
metasploit-model-0.26.1 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.7 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.7-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.6 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.6-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.3 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.3-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.2 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.2-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.1 lib/metasploit/model/search/operation.rb
metasploit-model-0.25.1-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.1.pre.metasploit.pre.model.pre.search.pre.operator.pre.and.pre.operation.pre.groups-java lib/metasploit/model/search/operation.rb
metasploit-model-0.25.1.pre.metasploit.pre.model.pre.search.pre.operator.pre.and.pre.operation.pre.groups lib/metasploit/model/search/operation.rb
metasploit-model-0.24.1-java lib/metasploit/model/search/operation.rb
metasploit-model-0.24.1 lib/metasploit/model/search/operation.rb
metasploit-model-0.24.1.pre.semantic.pre.versioning.pre.2.pre.0 lib/metasploit/model/search/operation.rb