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
wg-metasploit_data_models-4.1.4.02 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.5 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-6.0.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.6 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.5 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-5.0.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.1.4 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.1.3 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.1.2 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.1.1 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.1.0 app/models/metasploit_data_models/search/operation/ip_address.rb
metasploit_data_models-4.0.2 app/models/metasploit_data_models/search/operation/ip_address.rb