app/models/mdm/workspace.rb in metasploit_data_models-3.0.10 vs app/models/mdm/workspace.rb in metasploit_data_models-4.0.0

- old
+ new

@@ -1,8 +1,8 @@ # Workspace to separate different collections of {#hosts}. Can be used to separate pentests against different networks # or different clients as reports are normally generated against all records in a workspace. -class Mdm::Workspace < ActiveRecord::Base +class Mdm::Workspace < ApplicationRecord # # CONSTANTS # DEFAULT = 'default' @@ -50,11 +50,11 @@ dependent: :destroy # Users that are allowed to use this workspace. Does not necessarily include all users, as an {Mdm::User#admin # administrator} can access any workspace, even ones where they are not a member. has_and_belongs_to_many :users, - -> { uniq }, + -> { distinct }, class_name: 'Mdm::User', join_table: 'workspace_members' # # through: :hosts @@ -208,11 +208,11 @@ Mdm::WebForm.joins( Mdm::WebForm.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) - ).where(Mdm::Workspace[:id].eq(id)).uniq + ).where(Mdm::Workspace[:id].eq(id)).distinct end # Web pages found on {#web_sites}. # @@ -221,22 +221,22 @@ Mdm::WebPage.joins( Mdm::WebPage.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) - ).where(Mdm::Workspace[:id].eq(id)).uniq + ).where(Mdm::Workspace[:id].eq(id)).distinct end # Web sites running on {#services}. # # @return [ActiveRecord::Relation<Mdm::WebSite>] def web_sites Mdm::WebSite.joins( Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) - ).where(Mdm::Workspace[:id].eq(id)).uniq + ).where(Mdm::Workspace[:id].eq(id)).distinct end # Web vulnerability found on {#web_sites}. # # @return [ActiveRecord::Relation<Mdm::WebVuln>] @@ -244,10 +244,10 @@ Mdm::WebVuln.joins( Mdm::WebVuln.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) - ).where(Mdm::Workspace[:id].eq(id)).uniq + ).where(Mdm::Workspace[:id].eq(id)).distinct end # Web forms on {#web_sites}. # # @return [ActiveRecord::Relation<Mdm::WebForm>]