Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle omitted parameter permissions properly in OnVehicleData notification #3590

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,22 @@ void OnVehicleDataNotification::Run() {
mobile_api::FunctionID::OnVehicleDataID),
appSO[idx].enumerate(),
&params_permissions);

for (const auto& param : appSO[idx].enumerate()) {
const auto& allowed_params = params_permissions.allowed_params;
auto param_allowed = allowed_params.find(param);
if (allowed_params.end() == param_allowed) {
SDL_LOG_DEBUG("Param " << param << " is not allowed by policy for app "
<< notify_apps[idx]->app_id()
<< ". It will be ignored.");
appSO[idx].erase(param);
if (parameters_permissions_.allowed_params.empty() &&
parameters_permissions_.disallowed_params.empty() &&
parameters_permissions_.undefined_params.empty()) {
Comment on lines +116 to +117
Copy link
Collaborator

@iCollin iCollin Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i set these all to empty arrays, all params should be allowed, correct?

is there any way to differentiate between the case of all being defined as [] and the whole object missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the way that it is checked in CommandImpl::CheckAllowedParameters, I believe that all of the provided parameters would be in the disallowed_params list in the case that it is defined as [], so these lists would not be empty.

SDL_LOG_DEBUG(
"No parameter permissions provided, all params are allowed");
} else {
for (const auto& param : appSO[idx].enumerate()) {
const auto& allowed_params = params_permissions.allowed_params;
auto param_allowed = allowed_params.find(param);
if (allowed_params.end() == param_allowed) {
SDL_LOG_DEBUG("Param " << param
<< " is not allowed by policy for app "
<< notify_apps[idx]->app_id()
<< ". It will be ignored.");
appSO[idx].erase(param);
}
}
}

Expand Down