module Metasploit::Credential::CoreValidations

This mixin is intended to provide all of the common validations sued by {Metasploit::Credential::Core} and anything that mimics it’s behaviour by tying together {Metasploit::Credential::Public}, {Metasploit::Credential::Private}, and {Metasploit::Credential::Realm} objects.

Private Instance Methods

minimum_presence() click to toggle source

Validates that at least one of {#private}, {#public}, or {#realm} is present.

@return [void]

# File lib/metasploit/credential/core_validations.rb, line 96
def minimum_presence
  any_present = [:private, :public, :realm].any? { |attribute|
    send(attribute).present?
  }

  unless any_present
    errors.add(:base, :minimum_presence)
  end
end
public_for_ssh_key() click to toggle source

Validates that a Core’s Private of type {Metasploit::Credential::SSHKey} has a {Metasploit::Credential::Public}

# File lib/metasploit/credential/core_validations.rb, line 107
def public_for_ssh_key
  if private.present? && private.type == Metasploit::Credential::SSHKey.name
    errors.add(:base, :public_for_ssh_key) unless public.present?
  end
end