Sha256: 9e7fc5b8e9d8c13460f81e7453bb8c3cdd91c59ce2104c9662c6365ea9d75578

Contents?: true

Size: 1.32 KB

Versions: 119

Compression:

Stored size: 1.32 KB

Contents

# Searches an `inet` column in a PostgreSQL database using
# {MetasploitDataModels::IPAddress::V4::Single a standard IPv4 address},
# {MetasploitDataModels::IPAddress::V4::CIDR an IPv4 CIDR block}, or
# {MetasploitDataModels::IPAddress::V4::Range an IPv4 address range}.
class MetasploitDataModels::Search::Operation::IPAddress < Metasploit::Model::Search::Operation::Base
  include MetasploitDataModels::Match::Parent

  #
  # Match Children
  #

  # in order of precedence, so simpler single IPv4 addresses are matched before the more complex ranges which may
  # degenerate to equivalent formatted value
  match_children_named %w{
    MetasploitDataModels::IPAddress::V4::Single
    MetasploitDataModels::IPAddress::V4::CIDR
    MetasploitDataModels::IPAddress::V4::Range
  }

  #
  #
  # Validations
  #
  #

  #
  # Validation Methods
  #

  validate :value_valid

  #
  # Attribute Validations
  #

  validates :value,
            presence: true

  #
  # Instance Method
  #

  # @param formatted_value [#to_s]
  def value=(formatted_value)
    @value = match_child(formatted_value) || formatted_value
  end

  private

  # Validates that `#value` is valid.
  #
  # @return [void]
  def value_valid
    if value.present?
      unless value.respond_to?(:valid?) && value.valid?
        errors.add(:value, :invalid)
      end
    end
  end
end

Version data entries

119 entries across 119 versions & 2 rubygems

Version Path
metasploit_data_models-0.21.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.0-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.0.pre.engine.pre.requires app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.20.1.pre.recog app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.20.1-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.20.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.20.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.20.0-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.8 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.8-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.7 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.7-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.4-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.3-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.19.0-java app/models/metasploit_data_models/search/operation/ip_address.rb