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.22.8 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.8-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.7 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.7-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.6 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.6-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.5 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.5-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.4-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.3-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.2-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.22.1-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.3-java app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-0.21.2-java app/models/metasploit_data_models/search/operation/ip_address.rb