CSP-report-only support enabled
authorAndrzej Surdej <a.surdej@samsung.com>
Wed, 27 Feb 2013 14:06:23 +0000 (15:06 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 11 Mar 2013 16:10:06 +0000 (17:10 +0100)
[Issue#] N/A
[Problem] csp-report-only policy was not supported by wrt
[Cause] N/A
[Solution] Pasing policy from xml to webkit provided.
[Verification] To verif build repo, run any widget (to check
if anything wrong not happens), run manual csp tests from wrt-extra

This commit requres: https://tizendev.org/gerrit/#/c/48887/
                     https://tizendev.org/gerrit/#/c/48888/

Change-Id: Id32c7f6c027bcde976467769cc006148bfc50feb

src/domain/widget_model.cpp
src/domain/widget_model.h
src/view/webkit/view_logic.cpp

index ba92b4c..b378da4 100644 (file)
@@ -57,6 +57,8 @@ WidgetModel::WidgetModel(const std::string &tizenId) :
                                 &WidgetDAOReadOnly::getWidgetType>::Get),
     CspPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
                                      &WidgetDAOReadOnly::getCspPolicy>::Get),
+    CspReportOnlyPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
+                        &WidgetDAOReadOnly::getCspPolicyReportOnly>::Get),
     ActualSize(this),
     PreferredSize(this,
                   &BindToWidgetDAO<WidgetSize,
index 431c6b6..496383d 100644 (file)
@@ -78,6 +78,14 @@ class WidgetModel : public DPL::Event::Model
                          DPL::Event::PropertyStorageDynamicCached> CspPolicy;
 
     /**
+     * @brief Config file based csp policy - report only
+     */
+    DPL::Event::Property<DPL::OptionalString,
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    CspReportOnlyPolicy;
+
+    /**
      * @brief Current widget actual size
      */
     DPL::Event::Property<WidgetSize> ActualSize;
index 701ab6b..55d04c2 100755 (executable)
@@ -610,10 +610,14 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
     Assert(wkView);
 
 #ifdef CSP_ENABLED
+    ewk_context_tizen_extensible_api_set(
+        m_ewkContext, EWK_EXTENSIBLE_API_CSP, true);
     LogInfo("Setting CSP default policy");
     // setting CSP policy rules
     ewk_view_content_security_policy_set(
-        wkView, "default-src 'self';", EWK_ENFORCE_POLICY);
+        wkView,
+        "default-src '*'; script-src 'self'; style-src 'self'; object-src 'none';",
+        EWK_ENFORCE_POLICY);
     LogInfo("Default policy set");
 
     DPL::OptionalString policy = m_model->CspPolicy.Get();
@@ -627,7 +631,15 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
         LogDebug("Config CSP policy is not present");
     }
 
-    //TODO: support report only csp will be added soon
+    policy = m_model->CspReportOnlyPolicy.Get();
+    if (!(policy.IsNull()))
+    {
+        LogDebug("CSP report only policy present in manifest: " << *policy);
+        ewk_view_content_security_policy_set(
+            wkView, DPL::ToUTF8String(*policy).c_str(), EWK_REPORT_ONLY);
+    } else {
+        LogDebug("Config CSP report only policy is not present");
+    }
 
     LogInfo("CSP set.");
 #endif