Use a constant for default workspace name
parent
7d58b0a5f4
commit
e892911fbe
|
@ -21,9 +21,9 @@ module WorkspaceDataProxy
|
|||
|
||||
def default_workspace
|
||||
begin
|
||||
ws = find_workspace('default')
|
||||
ws = find_workspace(Msf::DBManager::Workspace::DEFAULT_WORKSPACE_NAME)
|
||||
if ws.nil?
|
||||
ws = add_workspace('default')
|
||||
ws = add_workspace(Msf::DBManager::Workspace::DEFAULT_WORKSPACE_NAME)
|
||||
end
|
||||
ws
|
||||
rescue Exception => e
|
||||
|
|
|
@ -5,7 +5,6 @@ module RemoteWorkspaceDataService
|
|||
|
||||
WORKSPACE_API_PATH = '/api/v1/workspaces'
|
||||
WORKSPACE_MDM_CLASS = 'Mdm::Workspace'
|
||||
DEFAULT_WORKSPACE_NAME = 'default'
|
||||
|
||||
def add_workspace(workspace_name)
|
||||
response = self.post_data(WORKSPACE_API_PATH, {:workspace_name => workspace_name})
|
||||
|
@ -13,7 +12,7 @@ module RemoteWorkspaceDataService
|
|||
end
|
||||
|
||||
def default_workspace
|
||||
json_to_mdm_object(self.get_data(WORKSPACE_API_PATH, nil, {:name => default}, false), WORKSPACE_MDM_CLASS, [])
|
||||
json_to_mdm_object(self.get_data(WORKSPACE_API_PATH, nil, {:name => Msf::DBManager::Workspace::DEFAULT_WORKSPACE_NAME}, false), WORKSPACE_MDM_CLASS, [])
|
||||
end
|
||||
|
||||
def workspace
|
||||
|
|
|
@ -22,20 +22,17 @@ module Msf::DBManager::VulnAttempt
|
|||
# This methods returns a list of all vulnerability attempts in the database
|
||||
#
|
||||
def vuln_attempts(opts)
|
||||
wspace = opts.delete(:workspace) || opts.delete(:wspace) || workspace
|
||||
if wspace.kind_of? String
|
||||
wspace = find_workspace(wspace)
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
# 'workspace' is not a valid attribute for Mdm::VulnAttempt. Remove it.
|
||||
Msf::Util::DBManager.process_opts_workspace(opts, framework)
|
||||
|
||||
search_term = opts.delete(:search_term)
|
||||
if search_term && !search_term.empty?
|
||||
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::VulnAttempt, search_term)
|
||||
Mdm::VulnAttempt.where(opts).where(column_search_conditions)
|
||||
else
|
||||
Mdm::VulnAttempt.where(opts)
|
||||
end
|
||||
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
|
||||
search_term = opts.delete(:search_term)
|
||||
if search_term && !search_term.empty?
|
||||
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::VulnAttempt, search_term)
|
||||
Mdm::VulnAttempt.where(opts).where(column_search_conditions)
|
||||
else
|
||||
Mdm::VulnAttempt.where(opts)
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,4 +1,6 @@
|
|||
module Msf::DBManager::Workspace
|
||||
|
||||
DEFAULT_WORKSPACE_NAME = 'default'
|
||||
#
|
||||
# Creates a new workspace in the database
|
||||
#
|
||||
|
@ -75,7 +77,7 @@ module Msf::DBManager::Workspace
|
|||
end
|
||||
begin
|
||||
deleted << ws.destroy
|
||||
framework.db.workspace = framework.db.add_workspace('default') if default_deleted
|
||||
framework.db.workspace = framework.db.add_workspace(DEFAULT_WORKSPACE_NAME) if default_deleted
|
||||
rescue
|
||||
elog("Forcibly deleting #{workspace}")
|
||||
deleted << ws.delete
|
||||
|
|
|
@ -235,7 +235,7 @@ class Db
|
|||
|
||||
def print_deleted_workspaces(deleted_workspaces, starting_ws)
|
||||
deleted_workspaces.each do |ws|
|
||||
if ws.name == 'default'
|
||||
if ws.name == Msf::DBManager::Workspace::DEFAULT_WORKSPACE_NAME
|
||||
print_status 'Deleted and recreated the default workspace'
|
||||
elsif ws == starting_ws
|
||||
print_status "Switched workspace: #{framework.db.workspace.name}"
|
||||
|
|
|
@ -16,7 +16,7 @@ module DBManager
|
|||
end
|
||||
|
||||
def self.process_opts_workspace(opts, framework)
|
||||
wspace = opts.delete(:wspace) || opts.delete(:workspace)
|
||||
wspace = opts.delete(:workspace) || opts.delete(:wspace)
|
||||
raise ArgumentError.new("opts must include a valid :workspace.") if wspace.nil? || ((wspace.kind_of? String) && wspace.empty?)
|
||||
|
||||
if wspace.kind_of? String
|
||||
|
|
Loading…
Reference in New Issue