class Metasploit::Credential::Core
Core
credential that combines {#private}, {#public}, and/or {#realm} so that {Metasploit::Credential::Private} or {Metasploit::Credential::Public} that are gathered from a {Metasploit::Credential::Realm} are properly scoped when used.
A core credential must always have an {#origin}, but only needs 1 of {#private}, {#public}, or {#realm} set.
Public Class Methods
Source
# File app/models/metasploit/credential/core.rb, line 281 def self.cores_from_host(host_id) left = origin_service_host_id(host_id).arel.ast right = origin_session_host_id(host_id).arel.ast Arel::Nodes::UnionAll.new( left, right ) end
Provides UNIONing cores from a host via service origins or via session origins. @param host_id [Integer] @return [String]
Private Instance Methods
Source
# File app/models/metasploit/credential/core.rb, line 300 def consistent_workspaces case origin when Metasploit::Credential::Origin::Manual user = origin.user # admins can access any workspace so there's no inconsistent workspace unless user && ( user.admin || # use database query when possible ( user.persisted? && user.workspaces.exists?(self.workspace.id) ) || # otherwise fall back to in-memory query user.workspaces.include?(self.workspace) ) errors.add(:workspace, :origin_user_workspaces) end when Metasploit::Credential::Origin::Service unless self.workspace == origin.service.try(:host).try(:workspace) errors.add(:workspace, :origin_service_host_workspace) end when Metasploit::Credential::Origin::Session unless self.workspace == origin.session.try(:host).try(:workspace) errors.add(:workspace, :origin_session_host_workspace) end end end
Validates that the direct {#workspace} is consistent with the ‘Mdm::Workspace` accessible through the {#origin}.
@return [void]