From 90bf20b4f65d208fa8543cc9f5a6f3935d56610e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Mon, 23 Sep 2019 15:18:49 +0200 Subject: [PATCH] F #3380: Lock conflicting api calls (#3747) --- include/HookAPI.h | 2 ++ src/hm/HookAPI.cc | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/HookAPI.h b/include/HookAPI.h index 67775b0fa6..ba0c9441d5 100644 --- a/include/HookAPI.h +++ b/include/HookAPI.h @@ -88,6 +88,8 @@ private: * String representation of the API call */ std::string call; + + const static std::string unsupported_calls[]; }; #endif diff --git a/src/hm/HookAPI.cc b/src/hm/HookAPI.cc index 30e2a6fcad..87103ce558 100644 --- a/src/hm/HookAPI.cc +++ b/src/hm/HookAPI.cc @@ -21,6 +21,11 @@ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +const string HookAPI::unsupported_calls[] = {"one.hook.info", "one.hookpool.info"}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + std::string * HookAPI::format_message(std::string method, ParamList& paramList, const RequestAttributes& att) { @@ -63,7 +68,7 @@ int HookAPI::parse_template(Template * tmpl, string& error_str) if (!call_exist(call)) { - error_str = "API call does not exist: " + call; + error_str = "API call does not exist or is not supported: " + call; return -1; } @@ -81,7 +86,7 @@ int HookAPI::from_template(const Template * tmpl, string& error_str) if (!call_exist(call)) { - error_str = "API call does not exist: " + call; + error_str = "API call does not exist or is not supported: " + call; return -1; } @@ -119,5 +124,18 @@ bool HookAPI::call_exist(const string& api_call) { RequestManager * rm = Nebula::instance().get_rm(); - return rm->exist_method(api_call); + if (!rm->exist_method(api_call)) + { + return false; + } + + for (const auto& call : unsupported_calls) + { + if (api_call == call) + { + return false; + } + } + + return true; }