Sha256: 8fe4ee5cc247ecf031c1a983e8a4db370850aa766eef974ad0fe811ffc62cdd4

Contents?: true

Size: 1.99 KB

Versions: 57

Compression:

Stored size: 1.99 KB

Contents

# Translates `ref:<value>` to union of `authorities.abbreviation:<value>`, `references.designation:<value>`, and
# `references.designation:<value>`.
class Metasploit::Model::Search::Operator::Deprecated::Ref < Metasploit::Model::Search::Operator::Group::Union
  # 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.
  #
  # @param formatted_value [String] value parsed from formatted operation.
  # @return [Array<Metasploit::Model::Search::Operation::Base>]
  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
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
metasploit-model-5.0.2 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-5.0.1 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-5.0.0 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.6 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.5 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.4 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.3 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.2 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.1 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-4.0.0 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.1.4 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.1.3 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.1.2 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.1.1 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.1.0 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-3.0.0 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-2.0.4 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-2.0.3 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-2.0.2 app/models/metasploit/model/search/operator/deprecated/ref.rb
metasploit-model-2.0.1 app/models/metasploit/model/search/operator/deprecated/ref.rb