class Metasploit::Model::Search::Operator::Group::Base

Operator that {#operate_on produces} {Metasploit::Model::Search::Operation::Group::Base group operations}.

Public Class Methods

operation_class() click to toggle source

{Metasploit::Model::Search::Operation::Group::Base Group operation class} to wrap {#children} in and return from {#operate_on}.

@return [Class<Metasploit::Model::Search::Operation::Group::Base>]

# File app/models/metasploit/model/search/operator/group/base.rb, line 27
def self.operation_class
  @operation_class ||= operation_class_name.constantize
end
operation_class_name!() click to toggle source

Sets the {operation_class_name} to the operation with same name as this operator, but with 'Operation' substituted for 'Operator'.

@return (see operation_class_name=)

# File app/models/metasploit/model/search/operator/group/base.rb, line 35
def self.operation_class_name!
  self.operation_class_name = name.gsub('Operator', 'Operation')
end

Public Instance Methods

children(formatted_value) click to toggle source

{Metasploit::Model::Search::Operation::Group::Base#children}.

@param formatted_value [String] value parsed from formatted operation @return [Array<Metasploit::Model::Search::Operation::Base>]

# File app/models/metasploit/model/search/operator/group/base.rb, line 49
def children(formatted_value)
  raise NotImplementedError
end
operate_on(formatted_value) click to toggle source

Group's children operating on `formatted_value`.

@param formatted_value [String] value parsed from formatted operation. @return [Metasploit::Model::Search::Operation::Group::Base] {#operation_class} instance will not contain {#children}

that are invalid.
# File app/models/metasploit/model/search/operator/group/base.rb, line 63
def operate_on(formatted_value)
  children = self.children(formatted_value)

  # filter children for validity as valid values for one child won't necessarily be valid values for another child.
  # this is specifically a problem with Metasploit::Model::Search::Operation::Set as no partial matching is allowed,
  # but can also be a problem with string vs integer operations.
  valid_children = children.select(&:valid?)

  operation_class.new(
      :children => valid_children,
      :operator => self,
      :value => formatted_value
  )
end
operation_class() click to toggle source

(see ::operation_class)

# File app/models/metasploit/model/search/operator/group/base.rb, line 54
def operation_class
  self.class.operation_class
end