From 0c020031a71f86684a7798962fed6c904b7ef396 Mon Sep 17 00:00:00 2001 From: "Maksym Ked (GitHub)" Date: Wed, 19 Jun 2019 13:45:27 +0300 Subject: Fixes after rebase --- .../include/application_manager/message_helper.h | 12 +-- .../application_manager/rpc_protection_manager.h | 18 ++--- .../rpc_protection_manager_impl.h | 10 +-- .../include/application_manager/rpc_service_impl.h | 1 + .../rc_get_interior_vehicle_data_consent_test.cc | 2 +- .../src/application_manager_impl.cc | 2 - .../src/message_helper/message_helper.cc | 61 +++++++-------- .../src/rpc_protection_manager_impl.cc | 12 +-- .../mock_rpc_protection_manager.h | 4 +- .../mock_rpc_protection_mediator.h | 4 +- .../policies/policy_encryption_flag_getter.h | 10 +-- .../policies/policy_handler_interface.h | 2 +- .../rpc_encryption_data_accessor_interface.h | 10 +-- .../policy/policy_external/policy/policy_manager.h | 4 - .../policy/policy_regular/policy/policy_manager.h | 2 - .../policies/mock_policy_handler_interface.h | 2 +- .../include/policy/cache_manager_interface.h | 10 +-- .../policy_external/include/policy/policy_helper.h | 8 +- .../policy_external/include/policy/policy_types.h | 1 + .../policy/policy_external/src/policy_helper.cc | 79 +++++++++---------- .../policy_regular/include/policy/policy_types.h | 1 + .../policy/policy_regular/src/policy_helper.cc | 91 +++++++++++----------- .../protocol_handler/src/protocol_handler_impl.cc | 12 +-- .../security_manager/test/security_manager_test.cc | 12 ++- 24 files changed, 181 insertions(+), 189 deletions(-) (limited to 'src') diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 29954680cb..5e1d27452c 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -511,12 +511,12 @@ class MessageHelper { ApplicationManager& app_man); /* - * @brief Send notification to mobile on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - * @param app_mngr reference ro application manager - * @param require_encryption require encryption flag - */ + * @brief Send notification to mobile on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + * @param app_mngr reference ro application manager + * @param require_encryption require encryption flag + */ static void SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager.h b/src/components/application_manager/include/application_manager/rpc_protection_manager.h index fcd2cd64db..2f77143573 100644 --- a/src/components/application_manager/include/application_manager/rpc_protection_manager.h +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager.h @@ -53,14 +53,14 @@ class Application; namespace application_manager { /** - * @brief RPCProtectionManager interface - * This entity exists to get info from policy table regarding encryption on - * application and function group level, as well as make decisions whether - * certain RPC should be encrypted or not. - * It mediates communication between PRCService and - * PolicyEncryptionFlagGetterInterface which is implemented by PolicyManager, - * providing adequate level of abstraction. - */ + * @brief RPCProtectionManager interface + * This entity exists to get info from policy table regarding encryption on + * application and function group level, as well as make decisions whether + * certain RPC should be encrypted or not. + * It mediates communication between PRCService and + * PolicyEncryptionFlagGetterInterface which is implemented by PolicyManager, + * providing adequate level of abstraction. + */ class RPCProtectionManager : public policy::PolicyHandlerObserver { public: /* @@ -106,6 +106,6 @@ class RPCProtectionManager : public policy::PolicyHandlerObserver { virtual void RemoveFromEncryptionNeededCache( const uint32_t app_id, const uint32_t correlation_id) = 0; }; -} // namespace policy +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h index ca7b010d49..76e36626e0 100644 --- a/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h @@ -33,15 +33,15 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ -#include #include -#include "application_manager/rpc_protection_manager.h" +#include #include "application_manager/policies/policy_handler.h" +#include "application_manager/rpc_protection_manager.h" namespace application_manager { /* -* @brief RPCProtectionManager implementation -*/ + * @brief RPCProtectionManager implementation + */ class RPCProtectionManagerImpl : public RPCProtectionManager { public: typedef std::pair AppIdCorrIdPair; @@ -111,6 +111,6 @@ class RPCProtectionManagerImpl : public RPCProtectionManager { std::set encryption_needed_cache_; sync_primitives::Lock message_needed_encryption_lock_; }; -} // namespace policy +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 5ebcb577cc..e32cdf42a2 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -38,6 +38,7 @@ #include "application_manager/message_helper.h" #include "application_manager/mobile_message_handler.h" #include "application_manager/request_controller.h" +#include "application_manager/rpc_protection_manager.h" #include "application_manager/rpc_service.h" #include "application_manager/usage_statistics.h" diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc index 9351ec4e02..c607721bbd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc @@ -41,6 +41,7 @@ #include "application_manager/mock_request_controller_settings.h" #include "application_manager/mock_rpc_plugin.h" #include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_rpc_protection_manager.h" #include "application_manager/request_controller.h" #include "application_manager/rpc_service_impl.h" #include "hmi_message_handler/mock_hmi_message_handler.h" @@ -55,7 +56,6 @@ #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/mock_rpc_protection_manager.h" using ::testing::_; using ::testing::Mock; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 7cfea6eab7..3829005047 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -48,8 +48,6 @@ #include "application_manager/helpers/application_helper.h" #include "application_manager/hmi_capabilities_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_service_impl.h" -#include "application_manager/rpc_handler_impl.h" #include "application_manager/mobile_message_handler.h" #include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "application_manager/policies/policy_handler.h" diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 5a693b0951..dd99d174f2 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2563,37 +2563,36 @@ void MessageHelper::SendOnPermissionsChangeNotification( auto permission_item_encryption_flag_state = [](const EncryptionRequired& app_flag, const EncryptionRequired& groups_flag) -> EncryptionRequired { - enum EncryptionFlagState { TRUE, FALSE, MISSING }; - auto enum_from_optional_bool = [](const EncryptionRequired& flag) { - if (!flag.is_initialized()) { - return MISSING; - } - return *flag ? TRUE : FALSE; - }; - - typedef std::pair - EnctyptionStatePair; - typedef std::map - PermissionItemEncryptionTable; - static PermissionItemEncryptionTable encryption_state_table = { - {{TRUE, TRUE}, EncryptionRequired(true)}, - {{TRUE, FALSE}, EncryptionRequired()}, - {{TRUE, MISSING}, EncryptionRequired()}, - {{FALSE, TRUE}, EncryptionRequired()}, - {{FALSE, FALSE}, EncryptionRequired()}, - {{FALSE, MISSING}, EncryptionRequired()}, - {{MISSING, TRUE}, EncryptionRequired(true)}, - {{MISSING, FALSE}, EncryptionRequired()}, - {{MISSING, MISSING}, EncryptionRequired()}, - }; - const auto app_flag_state = enum_from_optional_bool(app_flag); - const auto groups_flag_state = enum_from_optional_bool(groups_flag); - auto it = encryption_state_table.find( - EnctyptionStatePair(app_flag_state, groups_flag_state)); - DCHECK_OR_RETURN(it != encryption_state_table.end(), - EncryptionRequired()); - return it->second; - }; + enum EncryptionFlagState { TRUE, FALSE, MISSING }; + auto enum_from_optional_bool = [](const EncryptionRequired& flag) { + if (!flag.is_initialized()) { + return MISSING; + } + return *flag ? TRUE : FALSE; + }; + + typedef std::pair + EnctyptionStatePair; + typedef std::map + PermissionItemEncryptionTable; + static PermissionItemEncryptionTable encryption_state_table = { + {{TRUE, TRUE}, EncryptionRequired(true)}, + {{TRUE, FALSE}, EncryptionRequired()}, + {{TRUE, MISSING}, EncryptionRequired()}, + {{FALSE, TRUE}, EncryptionRequired()}, + {{FALSE, FALSE}, EncryptionRequired()}, + {{FALSE, MISSING}, EncryptionRequired()}, + {{MISSING, TRUE}, EncryptionRequired(true)}, + {{MISSING, FALSE}, EncryptionRequired()}, + {{MISSING, MISSING}, EncryptionRequired()}, + }; + const auto app_flag_state = enum_from_optional_bool(app_flag); + const auto groups_flag_state = enum_from_optional_bool(groups_flag); + auto it = encryption_state_table.find( + EnctyptionStatePair(app_flag_state, groups_flag_state)); + DCHECK_OR_RETURN(it != encryption_state_table.end(), EncryptionRequired()); + return it->second; + }; for (size_t index_pi = 0; it_permissions != it_permissions_end; ++it_permissions, ++index_pi) { diff --git a/src/components/application_manager/src/rpc_protection_manager_impl.cc b/src/components/application_manager/src/rpc_protection_manager_impl.cc index 3250e0d0b8..19b4ba263e 100644 --- a/src/components/application_manager/src/rpc_protection_manager_impl.cc +++ b/src/components/application_manager/src/rpc_protection_manager_impl.cc @@ -31,8 +31,8 @@ */ #include "application_manager/rpc_protection_manager_impl.h" -#include "application_manager/message_helper.h" #include "application_manager/application.h" +#include "application_manager/message_helper.h" #include "utils/helpers.h" CREATE_LOGGERPTR_LOCAL(logger_, "RPCProtectionManagerImpl"); @@ -89,9 +89,9 @@ bool RPCProtectionManagerImpl::IsEncryptionRequiredByPolicy( auto it = encrypted_rpcs_.find(policy_app_id); if (encrypted_rpcs_.end() == it) { - LOG4CXX_WARN(logger_, - "App specific policies for app: " << policy_app_id - << " not found"); + LOG4CXX_WARN( + logger_, + "App specific policies for app: " << policy_app_id << " not found"); it = encrypted_rpcs_.find(policy_table::kDefaultApp); return encrypted_rpcs_.end() != it ? (*it).second.find(function_name) != (*it).second.end() @@ -197,7 +197,7 @@ RPCProtectionManagerImpl::GetEncryptedRPCsForApp( policy_encryption_flag_getter->GetFunctionGroupsForApp(policy_app_id); auto fill_encrypted_rpcs = [&encrypted_rpcs]( - const std::string& function_name) { + const std::string& function_name) { LOG4CXX_DEBUG(logger_, "Adding required encryprion rpc: " << function_name); encrypted_rpcs.insert(function_name); }; @@ -215,4 +215,4 @@ RPCProtectionManagerImpl::GetEncryptedRPCsForApp( return encrypted_rpcs; } -} // namespace protocol_handler +} // namespace application_manager diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h index 74690a0253..112de0fea5 100644 --- a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ -#include "gmock/gmock.h" #include "application_manager/rpc_protection_manager.h" +#include "gmock/gmock.h" namespace application_manager { class MockRPCProtectionManager : public RPCProtectionManager { @@ -60,6 +60,6 @@ class MockRPCProtectionManager : public RPCProtectionManager { MOCK_METHOD2(RemoveFromEncryptionNeededCache, void(const uint32_t app_id, const uint32_t correlation_id)); }; -} +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h index 32b17aabea..858673e3b3 100644 --- a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h @@ -1,7 +1,7 @@ #pragma once -#include "gmock/gmock.h" #include "application_manager/rpc_protection_mediator.h" +#include "gmock/gmock.h" namespace application_manager { class MockRPCProtectionMediator : public RPCProtectionMediator { @@ -19,4 +19,4 @@ class MockRPCProtectionMediator : public RPCProtectionMediator { const uint32_t function_id, const uint32_t conrrelation_id)); }; -} +} // namespace application_manager diff --git a/src/components/include/application_manager/policies/policy_encryption_flag_getter.h b/src/components/include/application_manager/policies/policy_encryption_flag_getter.h index f93f12c838..19c7620aae 100644 --- a/src/components/include/application_manager/policies/policy_encryption_flag_getter.h +++ b/src/components/include/application_manager/policies/policy_encryption_flag_getter.h @@ -40,13 +40,13 @@ using rpc::policy_table_interface_base::Strings; namespace policy { /* -* @brief PolicyEncryptionFlagGetterInterface interface -*/ + * @brief PolicyEncryptionFlagGetterInterface interface + */ class PolicyEncryptionFlagGetterInterface { public: /*! - * @brief virtual destructor PolicyEncryptionFlagGetterInterface - */ + * @brief virtual destructor PolicyEncryptionFlagGetterInterface + */ virtual ~PolicyEncryptionFlagGetterInterface() {} /* @@ -102,5 +102,5 @@ class PolicyEncryptionFlagGetterInterface { virtual const std::vector GetApplicationPolicyIDs() const = 0; }; -} // policy +} // namespace policy #endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_ENCRYPTION_FLAG_GETTER diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index a84c73d421..8e450edd49 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -41,6 +41,7 @@ #include "boost/optional.hpp" #include "application_manager/application.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" #include "application_manager/policies/policy_handler_observer.h" #include "interfaces/MOBILE_API.h" #include "policy/cache_manager_interface.h" @@ -51,7 +52,6 @@ #include "smart_objects/smart_object.h" #include "utils/callable.h" #include "utils/custom_string.h" -#include "application_manager/policies/policy_encryption_flag_getter.h" using namespace ::rpc::policy_table_interface_base; namespace policy { diff --git a/src/components/include/application_manager/policies/rpc_encryption_data_accessor_interface.h b/src/components/include/application_manager/policies/rpc_encryption_data_accessor_interface.h index 84bcc1ea57..b43f3778cd 100644 --- a/src/components/include/application_manager/policies/rpc_encryption_data_accessor_interface.h +++ b/src/components/include/application_manager/policies/rpc_encryption_data_accessor_interface.h @@ -40,13 +40,13 @@ using rpc::policy_table_interface_base::Strings; namespace policy { /* -* @brief RPCEncryptionDataAccessorInterface interface -*/ + * @brief RPCEncryptionDataAccessorInterface interface + */ class RPCEncryptionDataAccessorInterface { public: /*! - * @brief virtual destructor RPCEncryptionDataAccessorInterface - */ + * @brief virtual destructor RPCEncryptionDataAccessorInterface + */ virtual ~RPCEncryptionDataAccessorInterface() {} /* @@ -91,5 +91,5 @@ class RPCEncryptionDataAccessorInterface { const uint32_t function_id) const = 0; }; -} // policy +} // namespace policy #endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_RPC_ENCRYPTION_MANAGER diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index a639eb67c6..1242c7a460 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -44,11 +44,7 @@ #include "policy/policy_listener.h" #include "policy/policy_table/types.h" #include "policy/policy_types.h" -#include "policy/policy_table/types.h" -#include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/cache_manager_interface.h" -#include "policy/access_remote.h" namespace policy { class PolicySettings; diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 44cb8178dc..65f4cb69ff 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -42,8 +42,6 @@ #include "policy/policy_listener.h" #include "policy/policy_table/types.h" #include "policy/policy_types.h" -#include "policy/policy_table/types.h" -#include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" #include "utils/callable.h" #include "utils/optional.h" diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index ef1604c3f9..f5b6f28825 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -34,11 +34,11 @@ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_POLICIES_MOCK_POLICY_HANDLER_INTERFACE_H_ #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" #include "application_manager/policies/policy_handler_interface.h" #include "gmock/gmock.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" -#include "application_manager/policies/policy_encryption_flag_getter.h" namespace test { namespace components { diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index d21218f820..e451fc73e9 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -961,12 +961,12 @@ class CacheManagerInterface { const std::string& device_id_to) = 0; /** - * @brief GetAppEncryptionRequiredFlag retrieves encryption required flag + * @brief GetAppEncryptionRequiredFlag retrieves encryption required flag * for - * given application - * @param application policy application name - * @return optional object containing encryption required flag - */ + * given application + * @param application policy application name + * @return optional object containing encryption required flag + */ virtual rpc::Optional GetAppEncryptionRequiredFlag( const std::string& application_policy_name) const = 0; diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 6e981c880a..36abb47dd6 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -317,10 +317,10 @@ struct ProcessFunctionalGroup { private: GroupConsent GetGroupState(const std::string& group_name); /* - * @brief Fills encryption required flags for all rpcs in functional group - * @param encryption_required Optional object containing encryption required - * flag - */ + * @brief Fills encryption required flags for all rpcs in functional group + * @param encryption_required Optional object containing encryption required + * flag + */ void FillEncryptionFlagForRpcs( const policy::EncryptionRequired encryption_required); const policy_table::FunctionalGroupings& fg_; diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h index 09b318a03f..fcf6c33c1b 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -41,6 +41,7 @@ #include #include +#include "policy/policy_table/types.h" #include "transport_manager/common.h" #include "utils/helpers.h" diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 2eb7e4c6f0..b4d1b89848 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -550,40 +550,38 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( auto get_app_encryption_needed = [](const std::string& policy_app_id, policy_table::ApplicationPolicies& policies) - -> rpc::Optional { - auto it = policies.find(policy_app_id); - if (policies.end() == it) { - LOG4CXX_WARN(logger_, - "App is not present in policies" << policy_app_id); - return rpc::Optional(false); - } - return it->second.encryption_required; - }; + -> rpc::Optional { + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return rpc::Optional(false); + } + return it->second.encryption_required; + }; auto get_app_groups = [](const std::string& policy_app_id, policy_table::ApplicationPolicies& policies) -> policy_table::Strings { - policy_table::Strings result; - auto it = policies.find(policy_app_id); - if (policies.end() == it) { - LOG4CXX_WARN(logger_, - "App is not present in policies" << policy_app_id); - return result; - } - auto& groups = it->second.groups; - std::copy(groups.begin(), groups.end(), std::back_inserter(result)); - return result; - }; - - auto get_app_rpcs = - [](const std::string group_name, const FunctionalGroupings& groups) - -> rpc::Optional { - auto it = groups.find(group_name); - if (it == groups.end()) { - return rpc::Optional(); - } - return rpc::Optional(it->second); - }; + policy_table::Strings result; + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return result; + } + auto& groups = it->second.groups; + std::copy(groups.begin(), groups.end(), std::back_inserter(result)); + return result; + }; + + auto get_app_rpcs = [](const std::string group_name, + const FunctionalGroupings& groups) + -> rpc::Optional { + auto it = groups.find(group_name); + if (it == groups.end()) { + return rpc::Optional(); + } + return rpc::Optional(it->second); + }; const auto snapshot_groups = get_app_groups( app_policy.first, snapshot_->policy_table.app_policies_section.apps); @@ -594,7 +592,6 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( [this, &get_app_rpcs]( const rpc::policy_table_interface_base::Strings& app_groups, const std::shared_ptr pt) { - for (const auto& group : app_groups) { const auto rpcs = get_app_rpcs(group, pt->policy_table.functional_groupings); @@ -947,16 +944,16 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) { void ProcessFunctionalGroup::FillEncryptionFlagForRpcs( const EncryptionRequired encryption_required) { - auto update_encryption_required = - [](EncryptionRequired& current, const EncryptionRequired& incoming) { - if (!incoming.is_initialized()) { - return; - } - if (current.is_initialized() && *current) { - return; - } - current = incoming; - }; + auto update_encryption_required = [](EncryptionRequired& current, + const EncryptionRequired& incoming) { + if (!incoming.is_initialized()) { + return; + } + if (current.is_initialized() && *current) { + return; + } + current = incoming; + }; for (auto& item : data_) { update_encryption_required(item.second.require_encryption, encryption_required); diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h index d2858f3c59..2794615cb4 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -41,6 +41,7 @@ #include #include +#include "policy/policy_table/types.h" #include "transport_manager/common.h" #include "utils/helpers.h" diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 870c44a5c6..a54a44f97d 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -379,16 +379,16 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } } if (RESULT_NO_CHANGES == result) { - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " wasn't changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " wasn't changed."); AddResult(app_id, RESULT_NO_CHANGES); return true; } - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " have been changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " have been changed."); if (IsPredefinedApp(app_policy)) { LOG4CXX_DEBUG(logger_, "app id: " << app_id << " is predefined app"); @@ -568,40 +568,38 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( auto get_app_encryption_needed = [](const std::string& policy_app_id, policy_table::ApplicationPolicies& policies) - -> rpc::Optional { - auto it = policies.find(policy_app_id); - if (policies.end() == it) { - LOG4CXX_WARN(logger_, - "App is not present in policies" << policy_app_id); - return rpc::Optional(false); - } - return it->second.encryption_required; - }; + -> rpc::Optional { + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return rpc::Optional(false); + } + return it->second.encryption_required; + }; auto get_app_groups = [](const std::string& policy_app_id, policy_table::ApplicationPolicies& policies) -> policy_table::Strings { - policy_table::Strings result; - auto it = policies.find(policy_app_id); - if (policies.end() == it) { - LOG4CXX_WARN(logger_, - "App is not present in policies" << policy_app_id); - return result; - } - auto& groups = it->second.groups; - std::copy(groups.begin(), groups.end(), std::back_inserter(result)); - return result; - }; - - auto get_app_rpcs = - [](const std::string group_name, const FunctionalGroupings& groups) - -> rpc::Optional { - auto it = groups.find(group_name); - if (it == groups.end()) { - return rpc::Optional(); - } - return rpc::Optional(it->second); - }; + policy_table::Strings result; + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return result; + } + auto& groups = it->second.groups; + std::copy(groups.begin(), groups.end(), std::back_inserter(result)); + return result; + }; + + auto get_app_rpcs = [](const std::string group_name, + const FunctionalGroupings& groups) + -> rpc::Optional { + auto it = groups.find(group_name); + if (it == groups.end()) { + return rpc::Optional(); + } + return rpc::Optional(it->second); + }; const auto snapshot_groups = get_app_groups( app_policy.first, snapshot_->policy_table.app_policies_section.apps); @@ -612,7 +610,6 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( [this, &get_app_rpcs]( const rpc::policy_table_interface_base::Strings& app_groups, const std::shared_ptr pt) { - for (const auto& group : app_groups) { const auto rpcs = get_app_rpcs(group, pt->policy_table.functional_groupings); @@ -880,16 +877,16 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) { void ProcessFunctionalGroup::FillEncryptionFlagForRpcs( const EncryptionRequired encryption_required) { - auto update_encryption_required = - [](EncryptionRequired& current, const EncryptionRequired& incoming) { - if (!incoming.is_initialized()) { - return; - } - if (current.is_initialized() && *current) { - return; - } - current = incoming; - }; + auto update_encryption_required = [](EncryptionRequired& current, + const EncryptionRequired& incoming) { + if (!incoming.is_initialized()) { + return; + } + if (current.is_initialized() && *current) { + return; + } + current = incoming; + }; for (auto& item : data_) { update_encryption_required(item.second.require_encryption, diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 1f1243056d..d95c57f0cc 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1270,9 +1270,9 @@ RESULT_CODE ProtocolHandlerImpl::SendSingleFrameMessage( const bool is_final_message) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "Packet needs encryption: " << std::boolalpha - << needs_encryption); + LOG4CXX_DEBUG( + logger_, + "Packet needs encryption: " << std::boolalpha << needs_encryption); ProtocolFramePtr ptr( new protocol_handler::ProtocolPacket(connection_id, @@ -2127,9 +2127,9 @@ RESULT_CODE ProtocolHandlerImpl::EncryptFrame(ProtocolFramePtr packet) { security_manager::SSLContext* context = session_observer_.GetSSLContext( connection_key, ServiceTypeFromByte(packet->service_type())); - LOG4CXX_DEBUG(logger_, - "Protection flag is: " << packet->protection_flag() - << std::boolalpha); + LOG4CXX_DEBUG( + logger_, + "Protection flag is: " << packet->protection_flag() << std::boolalpha); if ((!context || !context->IsInitCompleted()) || !packet->protection_flag()) { LOG4CXX_DEBUG(logger_, "Ecryption is skipped!"); return RESULT_OK; diff --git a/src/components/security_manager/test/security_manager_test.cc b/src/components/security_manager/test/security_manager_test.cc index 5472e7d49c..7906ae7006 100644 --- a/src/components/security_manager/test/security_manager_test.cc +++ b/src/components/security_manager/test/security_manager_test.cc @@ -293,7 +293,8 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) { SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_NOT_SUPPORTED), false, - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, // It could be any query id SecurityQuery::INVALID_QUERY_ID); @@ -391,7 +392,8 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) { SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_ID), false, - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); times++; const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, SecurityQuery::INVALID_QUERY_ID); @@ -586,7 +588,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) { SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE), false, - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); EmulateMobileMessageHandshake(NULL, 0); @@ -618,7 +621,8 @@ TEST_F(SecurityManagerTest, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_SERVICE_NOT_PROTECTED), false, - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); times++; // Expect notifying listeners (unsuccess) -- cgit v1.2.1