Class: Metasploit::Model::Search::Operator::Deprecated::Ref

Inherits:
Group::Union show all
Defined in:
app/models/metasploit/model/search/operator/deprecated/ref.rb

Overview

Translates ref:<value> to union of authorities.abbreviation:<value>, references.designation:<value>, and references.designation:<value>.

Instance Attribute Summary

Attributes inherited from Base

#klass

Instance Method Summary collapse

Methods inherited from Group::Base

#operate_on, operation_class, #operation_class, operation_class_name, operation_class_name!, operation_class_name=

Methods inherited from Metasploit::Model::Search::Operator::Delegation

#name, #operator, operator_name

Methods inherited from Base

#name

Methods included from Help

#help

Methods inherited from Base

#initialize, #valid!

Constructor Details

This class inherits a constructor from Metasploit::Model::Base

Instance Method Details

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

Array of authorities.abbreviation:<formatted_value>, references.designation:<formatted_value>, and references.url:<formatted_value>. If formatted_value contains a '-' then the portion of formatted_value before '-' is treated is passed to authorities.abbreviation and the portion of formatted_value after '-' is treated is passed to references.designation. If the portion of formatted_value before the '-' case-insensitively matches 'URL', then authorities.abbreviation and references.designation is not used and the portion of formatted_value after the '-' is passed to references.url. If any portion of the parsed formatted_value is blank, then the corresponding child operation will not be in the returned Array.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/metasploit/model/search/operator/deprecated/ref.rb', line 14

def children(formatted_value)
  if formatted_value.include? '-'
    head, tail = formatted_value.split('-', 2)

    if head.casecmp('URL') == 0
      # URL is not a valid abbreviation
      abbreviation = nil
      designation = nil
      url = tail
    else
      abbreviation = head
      designation = tail
      url = nil
    end
  else
    abbreviation = formatted_value
    designation = formatted_value
    url = formatted_value
  end

  operations = []

  unless abbreviation.blank?
    operations << operator('authorities.abbreviation').operate_on(abbreviation)
  end

  unless designation.blank?
    operations << operator('references.designation').operate_on(designation)
  end

  unless url.blank?
    operations << operator('references.url').operate_on(url)
  end

  operations
end