Module: RemoteWorkspaceDataService

Includes:
ResponseDataHelper
Included in:
DataServiceAutoLoader
Defined in:
lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb

Constant Summary collapse

WORKSPACE_API_PATH =
'/api/v1/workspaces'
WORKSPACE_MDM_CLASS =
'Mdm::Workspace'

Instance Method Summary collapse

Methods included from ResponseDataHelper

#json_to_hash, #json_to_mdm_object, #process_file, #to_ar

Instance Method Details

#add_workspace(opts) ⇒ Object



9
10
11
12
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 9

def add_workspace(opts)
  response = self.post_data(WORKSPACE_API_PATH, opts)
  json_to_mdm_object(response, WORKSPACE_MDM_CLASS).first
end

#default_workspaceObject



14
15
16
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 14

def default_workspace
  json_to_mdm_object(self.get_data(WORKSPACE_API_PATH, nil, { name: Msf::DBManager::Workspace::DEFAULT_WORKSPACE_NAME }), WORKSPACE_MDM_CLASS)
end

#delete_workspaces(opts) ⇒ Object



37
38
39
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 37

def delete_workspaces(opts)
  json_to_mdm_object(self.delete_data(WORKSPACE_API_PATH, opts), WORKSPACE_MDM_CLASS)
end

#update_workspace(opts) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 41

def update_workspace(opts)
  path = WORKSPACE_API_PATH
  if opts && opts[:id]
    id = opts.delete(:id)
    path = "#{WORKSPACE_API_PATH}/#{id}"
  end
  json_to_mdm_object(self.put_data(path, opts), WORKSPACE_MDM_CLASS).first
end

#workspaceObject



18
19
20
21
22
23
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 18

def workspace
  # The @current_workspace is tracked on the client side, so attempting to call it directly from the RemoteDataService
  # will not return the correct results. Run it back through the proxy.
  wlog "[DEPRECATION] Calling workspace from within the RemoteDataService is no longer supported. Please call from WorkspaceDataProxy instead."
  caller.each { |line| wlog "#{line}"}
end

#workspace=(workspace) ⇒ Object



25
26
27
28
29
30
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 25

def workspace=(workspace)
  # The @current_workspace is tracked on the client side, so attempting to call it directly from the RemoteDataService
  # will not return the correct results. Run it back through the proxy.
  wlog "[DEPRECATION] Setting the current workspace from the RemoteDataService is no longer supported. Please call from WorkspaceDataProxy instead."
  caller.each { |line| wlog "#{line}"}
end

#workspaces(opts) ⇒ Object



32
33
34
35
# File 'lib/metasploit/framework/data_service/remote/http/remote_workspace_data_service.rb', line 32

def workspaces(opts)
  path = get_path_select(opts, WORKSPACE_API_PATH)
  json_to_mdm_object(self.get_data(path, nil, opts), WORKSPACE_MDM_CLASS)
end