From 58b3f63c1ac553e68cf3323999a93173a3476f9f Mon Sep 17 00:00:00 2001 From: Erin Bleiweiss Date: Tue, 31 Jul 2018 15:57:26 -0500 Subject: [PATCH] Update to reflect new JSON models --- documentation/api/v1/module_search_api_doc.rb | 16 +++++++++++++--- .../servlet/module_search_servlet.rb | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/documentation/api/v1/module_search_api_doc.rb b/documentation/api/v1/module_search_api_doc.rb index c7a98af53d..fb5b6c25c3 100644 --- a/documentation/api/v1/module_search_api_doc.rb +++ b/documentation/api/v1/module_search_api_doc.rb @@ -158,12 +158,22 @@ module ModuleSearchApiDoc response 200 do key :description, 'Returns modules matching keywords with appropriate metadata.' schema do - key :type, :array - items do - key :'$ref', :Module + property :data do + key :type, :array + items do + key :'$ref', :Module + end end end end + + response 500 do + key :description, 'An error occurred during the operation. See the message for more details.' + schema do + key :'$ref', :ErrorModel + end + end + end end diff --git a/lib/msf/core/web_services/servlet/module_search_servlet.rb b/lib/msf/core/web_services/servlet/module_search_servlet.rb index c09a466271..6e68b6b23b 100644 --- a/lib/msf/core/web_services/servlet/module_search_servlet.rb +++ b/lib/msf/core/web_services/servlet/module_search_servlet.rb @@ -20,9 +20,9 @@ module ModuleSearchServlet begin sanitized_params = sanitize_params(params) data = Msf::WebServices.search_modules(sanitized_params) - set_json_response(data) + set_json_data_response(response: data) rescue => e - set_error_on_response(e) + print_error_and_create_response(error: e, message: 'There was an error completing the module search:', code: 500) end } end