Skip to content

Commit

Permalink
Fix code scanning alert no. 2: Information exposure through an exception
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 0e60712 commit 0a13446
Showing 1 changed file with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,32 @@ def __init__(self):
self.__m_session = crawl_session_controller()

def __handle_request(self, p_data):
m_status, m_crawl_model = self.__m_session.invoke_trigger(CRAWL_COMMANDS.M_INIT, p_data)
if m_status is False:
m_context = [False, CRAWL_ERROR_CALLBACK.M_INVALID_PARAM]
return HttpResponse(json.dumps(m_context))
else:
m_crawl_model.m_data = json.loads(m_crawl_model.m_data)
m_generic_index = json.loads(m_crawl_model.m_data['m_generic_model'])
m_leak_index = json.loads(m_crawl_model.m_data['m_leak_data_model'])
m_response_leak = []
m_data_leak = []
try:
m_status, m_crawl_model = self.__m_session.invoke_trigger(CRAWL_COMMANDS.M_INIT, p_data)
if m_status is False:
m_context = [False, CRAWL_ERROR_CALLBACK.M_INVALID_PARAM]
return HttpResponse(json.dumps(m_context))
else:
m_crawl_model.m_data = json.loads(m_crawl_model.m_data)
m_generic_index = json.loads(m_crawl_model.m_data['m_generic_model'])
m_leak_index = json.loads(m_crawl_model.m_data['m_leak_data_model'])
m_response_leak = []
m_data_leak = []

mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_STATUS, ["m_crawler"], [None]])
mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_STATUS, ["m_crawler"], [None]])

m_response_generic, m_data_generic = elastic_controller.get_instance().invoke_trigger(m_crawl_model.m_command, [ELASTIC_REQUEST_COMMANDS.S_INDEX_GENERAL, [m_generic_index, ELASTIC_INDEX.S_GENERIC_INDEX]])
if len(m_leak_index["cards_data"]):
m_response_leak, m_data_leak = elastic_controller.get_instance().invoke_trigger(m_crawl_model.m_command, [ELASTIC_REQUEST_COMMANDS.S_INDEX_LEAK, [m_leak_index, ELASTIC_INDEX.S_LEAK_INDEX]])
mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_URL_STATUS, [m_leak_index["base_url"], True, len(m_leak_index["cards_data"]) > 0, m_leak_index["content_type"]], [None]])
else:
mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_URL_STATUS, [m_generic_index["m_base_url"], True, None, m_generic_index["m_content_type"]], [None]])
m_response_generic, m_data_generic = elastic_controller.get_instance().invoke_trigger(m_crawl_model.m_command, [ELASTIC_REQUEST_COMMANDS.S_INDEX_GENERAL, [m_generic_index, ELASTIC_INDEX.S_GENERIC_INDEX]])
if len(m_leak_index["cards_data"]):
m_response_leak, m_data_leak = elastic_controller.get_instance().invoke_trigger(m_crawl_model.m_command, [ELASTIC_REQUEST_COMMANDS.S_INDEX_LEAK, [m_leak_index, ELASTIC_INDEX.S_LEAK_INDEX]])
mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_URL_STATUS, [m_leak_index["base_url"], True, len(m_leak_index["cards_data"]) > 0, m_leak_index["content_type"]], [None]])
else:
mongo_controller.getInstance().invoke_trigger(MONGODB_CRUD.S_UPDATE, [MONGO_COMMANDS.M_UPDATE_URL_STATUS, [m_generic_index["m_base_url"], True, None, m_generic_index["m_content_type"]], [None]])

m_context = [m_response_generic, m_data_generic, m_response_leak, m_data_leak]
return HttpResponse(json.dumps(m_context))
m_context = [m_response_generic, m_data_generic, m_response_leak, m_data_leak]
return HttpResponse(json.dumps(m_context))

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
Stack trace information
flows to this location and may be exposed to an external user.
Stack trace information
flows to this location and may be exposed to an external user.
Stack trace information
flows to this location and may be exposed to an external user.
Stack trace information
flows to this location and may be exposed to an external user.
except Exception as e:
log.g().e("Error in __handle_request: " + str(e))
return HttpResponse(json.dumps({"error": "An internal error has occurred."}), status=500)

def __handle_publish_feeder(self, p_data):
m_status, m_crawl_model = self.__m_session.invoke_trigger(CRAWL_COMMANDS.M_INIT, p_data)
Expand Down

0 comments on commit 0a13446

Please sign in to comment.