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-4.0.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.0.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.10 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.9 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.8 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.7 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.6 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.5 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.17 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-3.0.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.16 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.15 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.14 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.13 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.12 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.11 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-2.0.10 app/models/metasploit_data_models/search/operation/ip_address.rb