[Engine API Added] csre_cs_scan_app_on_cloud_supported 70/73170/3
authorKyungwook Tak <k.tak@samsung.com>
Tue, 7 Jun 2016 04:46:58 +0000 (13:46 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Tue, 7 Jun 2016 05:07:26 +0000 (14:07 +0900)
Change-Id: I032b90331cbcbf82dd3e3028b7abb393f92779db
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/cs-loader.cpp
src/framework/service/cs-loader.h
src/framework/service/cs-logic.cpp
src/include/csre/csre-content-screening-types.h
src/include/csre/csre-content-screening.h
test/engine/content-screening/sample-engine.cpp
test/internals/test-api-engine-content-screening.cpp
test/internals/test-cs-loader.cpp

index c9a3c93..cafda29 100644 (file)
@@ -105,6 +105,11 @@ int CsLoader::scanAppOnCloud(csre_cs_context_h c, const std::string &appdir,
        return this->m_pc.fpScanAppOnCloud(c, appdir.c_str(), pdetected);
 }
 
+bool CsLoader::scanAppOnCloudSupported(void)
+{
+       return this->m_pc.fpScanAppOnCloudSupported() == CSRE_CS_SUPPORTED;
+}
+
 int CsLoader::getSeverity(csre_cs_detected_h d,
                                                  csre_cs_severity_level_e *pseverity)
 {
@@ -271,6 +276,9 @@ void CsLoader::init(const std::string &enginePath, const std::string &roResDir,
                                                        "csre_cs_scan_file"));
        this->m_pc.fpScanAppOnCloud = reinterpret_cast<FpScanAppOnCloud>(dlsym(handle,
                                                                  "csre_cs_scan_app_on_cloud"));
+       this->m_pc.fpScanAppOnCloudSupported = reinterpret_cast<FpScanAppOnCloudSupported>(
+                                                                                  dlsym(handle,
+                                                                                                "csre_cs_scan_app_on_cloud_supported"));
        this->m_pc.fpGetSeverity = reinterpret_cast<FpGetSeverity>(dlsym(handle,
                                                           "csre_cs_detected_get_severity"));
        this->m_pc.fpGetMalwareName = reinterpret_cast<FpGetMalwareName>(dlsym(handle,
@@ -300,6 +308,7 @@ void CsLoader::init(const std::string &enginePath, const std::string &roResDir,
                        this->m_pc.fpContextDestroy == nullptr ||
                        this->m_pc.fpScanData == nullptr || this->m_pc.fpScanFile == nullptr  ||
                        this->m_pc.fpScanAppOnCloud == nullptr ||
+                       this->m_pc.fpScanAppOnCloudSupported == nullptr ||
                        this->m_pc.fpGetSeverity == nullptr ||
                        this->m_pc.fpGetMalwareName == nullptr ||
                        this->m_pc.fpGetErrorString == nullptr ||
index a237c90..048f92e 100644 (file)
@@ -45,6 +45,7 @@ public:
                                 csre_cs_detected_h *);
        int scanFile(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
        int scanAppOnCloud(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
+       bool scanAppOnCloudSupported(void);
 
        int getSeverity(csre_cs_detected_h, csre_cs_severity_level_e *);
        int getMalwareName(csre_cs_detected_h, std::string &);
@@ -71,6 +72,7 @@ private:
        using FpScanFile = int(*)(csre_cs_context_h, const char *,
                                                          csre_cs_detected_h *);
        using FpScanAppOnCloud = int(*)(csre_cs_context_h, const char *, csre_cs_detected_h *);
+       using FpScanAppOnCloudSupported = int(*)();
        using FpGetSeverity = int(*)(csre_cs_detected_h, csre_cs_severity_level_e *);
        using FpGetMalwareName = int(*)(csre_cs_detected_h, const char **);
        using FpGetDetailedUrl = int(*)(csre_cs_detected_h, const char **);
@@ -95,6 +97,7 @@ private:
                FpScanData fpScanData;
                FpScanFile fpScanFile;
                FpScanAppOnCloud fpScanAppOnCloud;
+               FpScanAppOnCloudSupported fpScanAppOnCloudSupported;
                FpGetSeverity fpGetSeverity;
                FpGetMalwareName fpGetMalwareName;
                FpGetDetailedUrl fpGetDetailedUrl;
index db8972c..dea0a56 100644 (file)
@@ -206,7 +206,7 @@ RawBuffer CsLogic::scanApp(const CsContext &context, const std::string &path)
        const auto &pkgPath = fileptr->getAppPkgPath();
        const auto &pkgId = fileptr->getAppPkgId();
 
-       if (context.isScanOnCloud)
+       if (context.isScanOnCloud && this->m_loader->scanAppOnCloudSupported())
                return this->scanAppOnCloud(context, pkgPath, pkgId);
 
        // old history
index e112629..df62237 100644 (file)
@@ -59,6 +59,11 @@ typedef enum {
        CSRE_CS_THREAT_GENERIC = 0x02   /**< Generic threat */
 } csre_cs_threat_type_e;
 
+typedef enum {
+       CSRE_CS_NOT_SUPPORTED  = 0x00,  /**< Cloud scan is not supported */
+       CSRE_CS_SUPPORTED      = 0x01,  /**< Cloud scan is supported */
+} csre_cs_cloud_supported_e;
+
 #ifdef __cplusplus
 }
 #endif
index a1db4e9..d5543e1 100644 (file)
@@ -195,11 +195,22 @@ int csre_cs_scan_file(csre_cs_context_h handle,
  *
  * @see csre_cs_context_create()
  * @see csre_cs_scan_data()
+ * @see csre_cs_scan_app_on_cloud_supported()
  */
 int csre_cs_scan_app_on_cloud(csre_cs_context_h handle,
                                                          const char *app_root_dir,
                                                          csre_cs_detected_h *pdetected);
 
+/**
+ * @brief Checks the engine supports scan on cloud feature.
+ *
+ * @return #CSRE_CS_SUPPORTED if scan app on cloud feature supported,
+ *         otherwise #CSRE_CS_NOT_SUPPORTED.
+ *
+ * @see csre_cs_scan_app_on_cloud()
+ */
+int csre_cs_scan_app_on_cloud_supported();
+
 //==============================================================================
 // Result related
 //==============================================================================
index 0322744..88cbeb2 100644 (file)
@@ -431,6 +431,12 @@ int csre_cs_scan_file(csre_cs_context_h handle,
 }
 
 API
+int csre_cs_scan_app_on_cloud_supported()
+{
+       return CSRE_CS_SUPPORTED;
+}
+
+API
 int csre_cs_scan_app_on_cloud(csre_cs_context_h handle,
                                                          const char *app_root_dir,
                                                          csre_cs_detected_h *pdetected)
index 72b8a4c..f30c6ec 100644 (file)
@@ -241,6 +241,19 @@ BOOST_AUTO_TEST_CASE(scan_app_on_cloud)
        EXCEPTION_GUARD_END
 }
 
+BOOST_AUTO_TEST_CASE(scan_app_on_cloud_supported)
+{
+       EXCEPTION_GUARD_START
+
+       auto ret = csre_cs_scan_app_on_cloud_supported();
+
+       BOOST_REQUIRE_MESSAGE(
+               ret == CSRE_CS_NOT_SUPPORTED || ret == CSRE_CS_SUPPORTED,
+               "invalid returned value from csre_cs_scan_app_on_cloud_supported: " << ret);
+
+       EXCEPTION_GUARD_END
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 
index 5478a9d..758ec06 100644 (file)
@@ -245,6 +245,17 @@ BOOST_AUTO_TEST_CASE(scan_app_on_cloud)
        EXCEPTION_GUARD_END
 }
 
+BOOST_AUTO_TEST_CASE(scan_app_on_cloud_supported)
+{
+       EXCEPTION_GUARD_START
+
+       Handle h;
+
+       BOOST_MESSAGE("scanAppOnCloudSupported: " << h.loader.scanAppOnCloudSupported());
+
+       EXCEPTION_GUARD_END
+}
+
 BOOST_AUTO_TEST_CASE(error_string_positive)
 {
        EXCEPTION_GUARD_START