diff options
author | Andrii Kalinich <AKalinich@luxoft.com> | 2018-08-06 14:29:59 +0300 |
---|---|---|
committer | Andrii Kalinich <AKalinich@luxoft.com> | 2018-08-06 14:29:59 +0300 |
commit | 80291097033c8a6cd44a95f2ff4ff4def57e5e8e (patch) | |
tree | 20bb14a4e40210696ea07c12eb286a9dcd16c9a4 /src/components/policy | |
parent | c71899ecf9d1be292646b80704a91fea97bb18d3 (diff) | |
download | sdl_core-80291097033c8a6cd44a95f2ff4ff4def57e5e8e.tar.gz |
Updated permissions calc logic according to comments
Diffstat (limited to 'src/components/policy')
-rw-r--r-- | src/components/policy/policy_external/include/policy/policy_helper.h | 2 | ||||
-rw-r--r-- | src/components/policy/policy_external/src/policy_helper.cc | 43 |
2 files changed, 22 insertions, 23 deletions
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 bdb9ba76b6..6f916b7cd0 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -273,7 +273,7 @@ struct FillNotificationData { * @return true if at least one parameter is allowed for the specified * permissions otherwise returns false */ - bool IsSomeParametersAllowed(const ParameterPermissions& permissions) const; + bool IsSomeParameterAllowed(const ParameterPermissions& permissions) const; std::string current_key_; Permissions& data_; diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index e1a72c3f6a..98546ef318 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -630,26 +630,24 @@ void FillNotificationData::UpdateParameters( // amongst all of the possible allowed permissions scenarios for the RPC (and // parameter/or HMI level) defined by each of the functional groups. - if (!IsSomeParametersAllowed(out_parameter)) { - // Due to APPLINK-24201 SDL must consider cases when 'parameters' section is - // not present for RPC or present, but is empty. - - // If 'parameters' section is like: 'parameters' : [] - if (in_parameters.is_initialized() && in_parameters.empty()) { - if (!does_require_user_consent_) { - out_parameter.any_parameter_disallowed_by_policy = true; - } - if (does_require_user_consent_ && kAllowedKey == current_key_) { - out_parameter.any_parameter_disallowed_by_user = true; - } + // Due to requirements SDL must consider cases when 'parameters' section is + // not present for RPC or present, but is empty. + + // If 'parameters' section is like: 'parameters' : [] + if (in_parameters.is_initialized() && in_parameters.empty()) { + if (!does_require_user_consent_) { + out_parameter.any_parameter_disallowed_by_policy = true; } + if (does_require_user_consent_ && kAllowedKey == current_key_) { + out_parameter.any_parameter_disallowed_by_user = true; + } + } - // If 'parameters' section is omitted - if (!in_parameters.is_initialized()) { - if (!does_require_user_consent_ || - (does_require_user_consent_ && kAllowedKey == current_key_)) { - out_parameter.any_parameter_allowed = true; - } + // If 'parameters' section is omitted + if (!in_parameters.is_initialized()) { + if (!does_require_user_consent_ || + (does_require_user_consent_ && kAllowedKey == current_key_)) { + out_parameter.any_parameter_allowed = true; } } @@ -660,7 +658,7 @@ void FillNotificationData::UpdateParameters( // We should reset ALL DISALLOWED flags if at least one parameter is allowed // due to a logical OR permissions check - if (IsSomeParametersAllowed(out_parameter)) { + if (IsSomeParameterAllowed(out_parameter)) { out_parameter.any_parameter_disallowed_by_policy = false; out_parameter.any_parameter_disallowed_by_user = false; } @@ -796,11 +794,12 @@ bool FillNotificationData::IsSectionEmpty( return true; } -bool FillNotificationData::IsSomeParametersAllowed( +bool FillNotificationData::IsSomeParameterAllowed( const ParameterPermissions& permissions) const { + const bool are_any_consented_parameters_allowed = + kAllowedKey == current_key_ && !IsSectionEmpty(permissions, current_key_); return permissions.any_parameter_allowed || - (kAllowedKey == current_key_ && - !IsSectionEmpty(permissions, kAllowedKey)); + are_any_consented_parameters_allowed; } ProcessFunctionalGroup::ProcessFunctionalGroup( |