#include <dpl/utils/wrt_global_settings.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/wrt-dao-rw/feature_dao.h>
#include <libiriwrapper.h>
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <widget_parser.h>
+#include <web_provider_plugin_info.h>
+#include <web_provider_livebox_info.h>
+#include <manifest.h>
namespace { // anonymous
const DPL::String BR = DPL::FromUTF8String("<br>");
const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
+
+const char WRT_WIDGETS_XML_SCHEMA[] = "/usr/etc/wrt-installer/widgets.xsd";
}
namespace Jobs {
AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath);
AddStep(&TaskWidgetConfig::ProcessAppControlInfo);
+ AddStep(&TaskWidgetConfig::ProcessSecurityModel);
AddStep(&TaskWidgetConfig::StepVerifyFeatures);
AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
}
return;
}
-
-
struct stat statStruct;
struct dirent dirent;
struct dirent *result;
}
}
+void TaskWidgetConfig::ProcessSecurityModel()
+{
+ // 0104. If the "required_version" specified in the Web Application's
+ // configuration is 2.2 or higher and if the Web Application's
+ // configuration is "CSP-compatible configuration", then the WRT MUST be
+ // set to "CSP-based security mode". Otherwise, the WRT MUST be set to
+ // "WARP-based security mode".
+ // 0105. A Web Application configuration is "CSP-compatible configuration"
+ // if the configuration includes one or more of
+ // <tizen:content-security-policy> /
+ // <tizen:content-security-policy-report-only> /
+ // <tizen:allow-navigation> elements.
+
+ bool isSecurityModelV1 = false;
+ bool isSecurityModelV2 = false;
+ std::string securityModelV2supportedVersion = "2.2";
+ WrtDB::ConfigParserData &data = m_installContext.widgetConfig.configInfo;
+
+ // Parse required version
+ long majorWidget = 0, minorWidget = 0, microWidget = 0;
+ if (!parseVersionString(DPL::ToUTF8String(*data.tizenMinVersionRequired),
+ majorWidget,
+ minorWidget,
+ microWidget))
+ {
+ ThrowMsg(Exceptions::NotAllowed, "Wrong version string");
+ }
+
+ // Parse since version (CSP & allow-navigation start to support since 2.2)
+ long majorSupported = 0, minorSupported = 0, microSupported = 0;
+ if (!parseVersionString(securityModelV2supportedVersion,
+ majorSupported,
+ minorSupported,
+ microSupported))
+ {
+ ThrowMsg(Exceptions::NotAllowed, "Wrong version string");
+ }
+
+ if (majorWidget < majorSupported ||
+ (majorWidget == majorSupported && minorWidget < minorSupported) ||
+ (majorWidget == majorSupported && minorWidget == minorSupported
+ && microWidget < microSupported))
+ {
+ // Under 2.2, clear v2 data
+ data.cspPolicy = DPL::OptionalString::Null;
+ data.cspPolicyReportOnly = DPL::OptionalString::Null;
+ data.allowNavigationInfoList.clear();
+ } else {
+ // More than 2.2, if v2 is defined, clear v1 data
+ if (!data.cspPolicy.IsNull() ||
+ !data.cspPolicyReportOnly.IsNull() ||
+ !data.allowNavigationInfoList.empty())
+ {
+ data.accessInfoSet.clear();
+ }
+ }
+
+ // WARP is V1
+ if (!data.accessInfoSet.empty()) {
+ isSecurityModelV1 = true;
+ }
+
+ // CSP & allow-navigation is V2
+ if (!data.cspPolicy.IsNull() ||
+ !data.cspPolicyReportOnly.IsNull() ||
+ !data.allowNavigationInfoList.empty())
+ {
+ isSecurityModelV2 = true;
+ }
+
+ if (isSecurityModelV1 && isSecurityModelV2) {
+ LogError("Security model is conflict");
+ ThrowMsg(Exceptions::NotAllowed, "Security model is conflict");
+ } else if (isSecurityModelV1) {
+ data.securityModelVersion =
+ WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V1;
+ } else if (isSecurityModelV2) {
+ data.securityModelVersion =
+ WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V2;
+ } else {
+ data.securityModelVersion =
+ WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V1;
+ }
+
+ m_installContext.job->UpdateProgress(
+ InstallerContext::INSTALL_WIDGET_CONFIG2,
+ "Finished process security model");
+}
+
void TaskWidgetConfig::StepCheckMinVersionInfo()
{
if (!isMinVersionCompatible(
"Widget Config step2 Finished");
}
+void TaskWidgetConfig::StepVerifyLivebox()
+{
+ using namespace WrtDB;
+ ConfigParserData &data = m_installContext.widgetConfig.configInfo;
+ ConfigParserData::LiveboxList liveBoxList = data.m_livebox;
+
+ if (liveBoxList.size() <= 0) {
+ return;
+ }
+
+ FOREACH (it, liveBoxList) {
+ std::string boxType;
+
+ if ((**it).m_type.empty()) {
+ boxType = web_provider_livebox_get_default_type();
+ } else {
+ boxType = DPL::ToUTF8String((**it).m_type);
+ }
+
+ LogInfo("livebox type: " << boxType);
+
+ ConfigParserData::LiveboxInfo::BoxSizeList boxSizeList =
+ (**it).m_boxInfo.m_boxSize;
+ char** boxSize = static_cast<char**>(
+ malloc(sizeof(char*)* boxSizeList.size()));
+
+ int boxSizeCnt = 0;
+ FOREACH (m, boxSizeList) {
+ boxSize[boxSizeCnt++] = strdup(DPL::ToUTF8String((*m).m_size).c_str());
+ }
+
+ bool chkSize = web_provider_plugin_check_supported_size(
+ boxType.c_str(), boxSize, boxSizeCnt);
+
+ for(int i = 0; i < boxSizeCnt; i++) {
+ free(boxSize[i]);
+ }
+ free(boxSize);
+
+ if(!chkSize) {
+ LogError("Invalid boxSize");
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Invalid boxSize");
+ }
+ }
+}
+
bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
DPL::String featureName)
{
Try
{
ParserRunner parser;
+#ifdef SCHEMA_VALIDATION_ENABLED
+ if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
+ {
+ LogError("Invalid configuration file - schema validation failed");
+ return false;
+ }
+#endif
parser.Parse(configFilePath,
ElementParserPtr(new RootParser<WidgetParser>(
configInfo,