summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2019-01-23 12:44:31 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2019-01-23 12:44:46 -0500
commitec5457edb06cf971b820b7fc79e7f25694dd0829 (patch)
tree6dd97e5103a3c45f75542f87abe3b2fc08a12d24 /src/components
parent61d292140068510f8a5602170b02a7a777678f4a (diff)
downloadsdl_core-ec5457edb06cf971b820b7fc79e7f25694dd0829.tar.gz
Add validation of app service manifest
Diffstat (limited to 'src/components')
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc23
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc22
4 files changed, 46 insertions, 3 deletions
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h
index b21f99885a..0c7f222c1d 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h
@@ -69,6 +69,8 @@ class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI {
virtual void Run();
private:
+ bool ValidateManifest(smart_objects::SmartObject& manifest);
+
AppServiceRpcPlugin* plugin_;
DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h
index a798bed613..ac5caa4e6d 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h
@@ -70,6 +70,8 @@ class PublishAppServiceRequest
virtual void Run();
private:
+ bool ValidateManifest(smart_objects::SmartObject& manifest);
+
AppServiceRpcPlugin* plugin_;
DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
index 9acc8c3146..835762f78a 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
@@ -59,14 +59,35 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest(
ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {}
+bool ASPublishAppServiceRequest::ValidateManifest(
+ smart_objects::SmartObject& manifest) {
+ if (manifest.keyExists(strings::uri_scheme)) {
+ Json::Value value;
+ Json::Reader reader;
+ if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) {
+ SendResponse(
+ false,
+ (*message_)[strings::params][strings::correlation_id].asUInt(),
+ hmi_apis::FunctionID::AppService_PublishAppService,
+ hmi_apis::Common_Result::INVALID_DATA);
+ return false;
+ }
+ }
+ return true;
+}
+
void ASPublishAppServiceRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject response_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
smart_objects::SmartObject service_record =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- service_record[strings::service_manifest] =
+ smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
+ if (!ValidateManifest(manifest)) {
+ return;
+ }
+ service_record[strings::service_manifest] = manifest;
service_record[strings::service_id] = "This is a service ID";
service_record[strings::service_published] = true;
service_record[strings::service_active] = true;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
index e5f7c40471..b22d0a8c6e 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
@@ -62,6 +62,21 @@ PublishAppServiceRequest::PublishAppServiceRequest(
PublishAppServiceRequest::~PublishAppServiceRequest() {}
+bool PublishAppServiceRequest::ValidateManifest(
+ smart_objects::SmartObject& manifest) {
+ if (manifest.keyExists(strings::uri_scheme)) {
+ Json::Value value;
+ Json::Reader reader;
+ if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) {
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Provided uriScheme was not valid JSON");
+ return false;
+ }
+ }
+ return true;
+}
+
void PublishAppServiceRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Received a PublishAppService");
@@ -69,11 +84,14 @@ void PublishAppServiceRequest::Run() {
smart_objects::SmartObject response_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
-
smart_objects::SmartObject service_record =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- service_record[strings::service_manifest] =
+ smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
+ if (!ValidateManifest(manifest)) {
+ return;
+ }
+ service_record[strings::service_manifest] = manifest;
service_record[strings::service_id] = "This is a service ID";
service_record[strings::service_published] = true;
service_record[strings::service_active] = true;