Land #11222, Display error when update operation has invalid fields
commit
65f127a66f
|
@ -262,7 +262,9 @@ module Msf::DBManager::Cred
|
|||
end
|
||||
|
||||
id = opts.delete(:id)
|
||||
Metasploit::Credential::Core.update(id, opts)
|
||||
cred = Metasploit::Credential::Core.find(id)
|
||||
cred.update!(opts)
|
||||
return cred
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -283,7 +283,9 @@ module Msf::DBManager::Host
|
|||
opts[:workspace] = wspace if wspace
|
||||
|
||||
id = opts.delete(:id)
|
||||
Mdm::Host.update(id, opts)
|
||||
host = Mdm::Host.find(id)
|
||||
host.update!(opts)
|
||||
return host
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ module Msf::DBManager::Login
|
|||
wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework, false)
|
||||
opts[:workspace] = wspace if wspace
|
||||
id = opts.delete(:id)
|
||||
Metasploit::Credential::Login.update(id, opts)
|
||||
login = Metasploit::Credential::Login.find(id)
|
||||
login.update!(opts)
|
||||
return login
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -102,7 +102,9 @@ module Msf::DBManager::Loot
|
|||
opts[:workspace] = wspace if wspace
|
||||
|
||||
id = opts.delete(:id)
|
||||
Mdm::Loot.update(id, opts)
|
||||
loot = Mdm::Loot.find(id)
|
||||
loot.update!(opts)
|
||||
return loot
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -128,4 +130,4 @@ module Msf::DBManager::Loot
|
|||
return deleted
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -200,7 +200,9 @@ module Msf::DBManager::Note
|
|||
opts[:workspace] = wspace if wspace
|
||||
|
||||
id = opts.delete(:id)
|
||||
Mdm::Note.update(id, opts)
|
||||
note = Mdm::Note.find(id)
|
||||
note.update!(opts)
|
||||
return note
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -170,7 +170,9 @@ module Msf::DBManager::Service
|
|||
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
id = opts.delete(:id)
|
||||
Mdm::Service.update(id, opts)
|
||||
service = Mdm::Service.find(id)
|
||||
service.update!(opts)
|
||||
return service
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -188,7 +188,9 @@ module Msf::DBManager::Session
|
|||
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
id = opts.delete(:id)
|
||||
::Mdm::Session.update(id, opts)
|
||||
session = ::Mdm::Session.find(id)
|
||||
session.update!(opts)
|
||||
return session
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -75,7 +75,9 @@ module Msf::DBManager::User
|
|||
def update_user(opts)
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
id = opts.delete(:id)
|
||||
Mdm::User.update(id, opts)
|
||||
user = Mdm::User.find(id)
|
||||
user.update!(opts)
|
||||
return user
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -133,7 +135,9 @@ module Msf::DBManager::User
|
|||
|
||||
token_length = opts[:token_length] || MIN_TOKEN_LENGTH
|
||||
# NOTE: repurposing persistence_token in the database as the API token
|
||||
Mdm::User.update(opts[:id], {persistence_token: SecureRandom.hex(token_length)}).persistence_token
|
||||
user = Mdm::User.find(opts[:id])
|
||||
user.update!({persistence_token: SecureRandom.hex(token_length)})
|
||||
user.persistence_token
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -25,7 +25,9 @@ module Msf::DBManager::VulnDetail
|
|||
def update_vuln_details(details)
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
criteria = details.delete(:key) || {}
|
||||
::Mdm::VulnDetail.update(key, details)
|
||||
vuln_detail = ::Mdm::VulnDetail.find(key)
|
||||
vuln_detail.update!(criteria)
|
||||
return vuln_detail
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,7 +99,7 @@ module Msf::DBManager::Workspace
|
|||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
ws_to_update = workspaces({ id: opts.delete(:id) }).first
|
||||
default_renamed = true if ws_to_update.name == DEFAULT_WORKSPACE_NAME
|
||||
updated_ws = Mdm::Workspace.update(ws_to_update.id, opts)
|
||||
updated_ws = ws_to_update.update!(opts)
|
||||
add_workspace({ name: DEFAULT_WORKSPACE_NAME }) if default_renamed
|
||||
updated_ws
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue