Class: MetasploitDataModels::Search::Operator::Multitext

Inherits:
Metasploit::Model::Search::Operator::Group::Intersection
  • Object
show all
Defined in:
app/models/metasploit_data_models/search/operator/multitext.rb

Overview

Searches multiple text fields by breaking up the formatted value into words and doing text search for each word across each operator named in #operator_names.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameSymbol

The name of this operator.

Returns:

  • (Symbol)


14
15
16
# File 'app/models/metasploit_data_models/search/operator/multitext.rb', line 14

def name
  @name
end

#operator_namesArray<Symbol>

The name of the operators to search for each word.

Returns:

  • (Array<Symbol>)

    Default to []



20
# File 'app/models/metasploit_data_models/search/operator/multitext.rb', line 20

attr_writer :operator_names

Instance Method Details

#children(formatted_value) ⇒ Array<Metasploit::Model::Search::Operation::Group::Union>

Breaks formatted_value into words using Shellwords.split. Each word is then searched across all #operators, where any operator can match for that word. The search for multiple multiple is intersected, so that additional words can refine the search.

Parameters:

  • formatted_value (#to_s)

Returns:

  • (Array<Metasploit::Model::Search::Operation::Group::Union>)

    Unions to be intersected.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/metasploit_data_models/search/operator/multitext.rb', line 43

def children(formatted_value)
  words = Shellwords.split formatted_value.to_s

  words.map { |word|
    child_operators = operators.map { |operator|
      operator.operate_on(word)
    }

    Metasploit::Model::Search::Operation::Group::Union.new(
        children: child_operators,
        operator: self
    )
  }
end

#operatorsArray<Metasploit::Model::Search::Operator::Base>

Operators with #operator_names.

Returns:

  • (Array<Metasploit::Model::Search::Operator::Base>)


68
69
70
71
72
# File 'app/models/metasploit_data_models/search/operator/multitext.rb', line 68

def operators
  @operators ||= operator_names.map { |operator_name|
    operator(operator_name)
  }
end