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.



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.



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.



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.



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