Module: Metasploit::Model::Search::Association::ClassMethods

Defined in:
lib/metasploit/model/search/association.rb

Overview

Instance Method Summary collapse

Instance Method Details

#search_association(association) ⇒ void

Note:

Use #search_associations to declare multiple associations or a tree of far associations as searchable.

This method returns an undefined value.

Registers association for search.

Examples:

a single searchable association

search_association :children

Parameters:

  • association (#to_sym)

    name of association to search.

See Also:



107
108
109
# File 'lib/metasploit/model/search/association.rb', line 107

def search_association(association)
  search_association_tree[association.to_sym] ||= nil
end

#search_association_operatorsArray<Metasploit::Model::Search::Operator::Association>

The association operators for the searchable associations declared with #search_association and #search_associations.



156
157
158
159
160
161
# File 'lib/metasploit/model/search/association.rb', line 156

def search_association_operators
  @search_association_operators ||= Metasploit::Model::Association::Tree.operators(
      search_association_tree,
      class: self
  )
end

#search_association_treeHash{Symbol => Hash,nil}

Tree of associations that are searchable.

Returns:

  • (Hash{Symbol => Hash,nil})


166
167
168
# File 'lib/metasploit/model/search/association.rb', line 166

def search_association_tree
  @search_association_tree ||= {}
end

#search_associations(*associations) ⇒ void

This method returns an undefined value.

Registers a tree of near and far associations for search. When a tree is used, all intermediate association on the paths are used, so search_association children: :grandchildren makes both children.granchildren and children as search operator prefixes.

Examples:

a single search association

search_associations :children

multiple near associations

search_associations :first,
                    :second

far association

search_associations near: :far

multiple far associations

search_associations near: [
                      :first_far,
                      :second_far
                    ]

mix of near and far associations

# Keep associations in order by near association names by mixing Symbols and Hash{Symbol => Object}
search_associations :apple,
                    {
                      banana: :peel
                    },
                    :cucumber

Parameters:

  • associations (Array<Array, Hash, Symbol>, Hash, Symbol)

See Also:



143
144
145
146
147
148
149
150
# File 'lib/metasploit/model/search/association.rb', line 143

def search_associations(*associations)
  expanded_associations = Metasploit::Model::Association::Tree.expand(associations)

  @search_association_tree = Metasploit::Model::Association::Tree.merge(
      search_association_tree,
      expanded_associations
  )
end