WIP: REST API for async-callbacks, added UUID search

This commit is contained in:
Aaron Soto
2019-03-19 14:36:40 -05:00
committed by bwatters-r7
parent 84acf0d09d
commit afddfff3be
3 changed files with 14 additions and 11 deletions
@@ -108,19 +108,20 @@ module AsyncCallbackApiDoc
end
end
swagger_path '/api/v1/async-callbacks/{id}' do
# Swagger documentation for api/v1/async-callbacks/:id GET
swagger_path '/api/v1/async-callbacks/{uuid}' do
# Swagger documentation for api/v1/async-callbacks/:uuid GET
operation :get do
key :description, 'Return specific asynchronous payload callback that is stored in the database.'
key :tags, [ 'async_callback' ]
parameter :workspace
parameter do
key :name, :id
key :name, :uuid
key :in, :path
key :description, 'ID of asynchronous payload callback to retrieve.'
key :description, 'UUID of asynchronous payload callback to retrieve.'
key :required, true
key :type, :integer
key :format, :int32
key :type, :string
end
response 200 do
+4 -2
View File
@@ -15,8 +15,10 @@ module Msf::DBManager::AsyncCallback
def async_callbacks(opts)
::ActiveRecord::Base.connection_pool.with_connection do
if opts[:id] && !opts[:id].to_s.empty?
return Array.wrap(Mdm::AsyncCallback.find(opts[:id]))
if opts[:uuid] && !opts[:uuid].to_s.empty?
#return Array.wrap(Mdm::AsyncCallback.find_by :uuid => opts[:uuid] )
#return Array.wrap( Mdm::AsyncCallback.where ( uuid: opts[:uuid] ))
return Mdm::AsyncCallback.where( 'uuid' => opts[:uuid] )
end
wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)
@@ -4,12 +4,12 @@ module AsyncCallbackServlet
'/api/v1/async-callbacks'
end
def self.api_path_with_id
"#{AsyncCallbackServlet.api_path}/?:id?"
def self.api_path_with_uuid
"#{AsyncCallbackServlet.api_path}/?:uuid?"
end
def self.registered(app)
app.get AsyncCallbackServlet.api_path_with_id, &get_async_callback
app.get AsyncCallbackServlet.api_path_with_uuid, &get_async_callback
app.post AsyncCallbackServlet.api_path, &create_async_callback
end