apply new csr apis 58/74358/2 accepted/tizen/ivi/20160615.070405 accepted/tizen/mobile/20160615.070401 accepted/tizen/wearable/20160615.070353 submit/tizen/20160615.015941
authorKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 14 Jun 2016 04:30:11 +0000 (13:30 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 14 Jun 2016 05:31:30 +0000 (14:31 +0900)
Change-Id: I3627e7fef4de0f13778041400b49467d8e0c1faf
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
packaging/msg-service.spec
utils/CMakeLists.txt
utils/MsgUtilFile.cpp

index ca0855e..fcdd7c7 100755 (executable)
@@ -31,6 +31,7 @@ BuildRequires: pkgconfig(capi-network-connection)
 BuildRequires: pkgconfig(capi-system-device)
 BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(capi-telephony)
+BuildRequires: pkgconfig(csr)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-creds-commons)
 BuildRequires: pkgconfig(cynara-creds-socket)
index 31d6df4..776bac3 100755 (executable)
@@ -46,7 +46,7 @@ INCLUDE_DIRECTORIES(
 
 INCLUDE(FindPkgConfig)
 
-SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 boost json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login libsmack)
+SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 boost json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login libsmack csr)
 pkg_check_modules(utils_pkgs REQUIRED ${PKG_MODULES})
 
 FOREACH(flag ${utils_pkgs_CFLAGS})
index b2710f7..83a0b50 100755 (executable)
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <libgen.h>
 
+#include <csr-content-screening.h>
 #include <thumbnail_util.h>
 #include <image_util.h>
 
@@ -1232,11 +1233,9 @@ void MsgGetMimeType(char *filePath, char *mimeType, int size)
 int MsgTcsScanFile(const char *filepath, int *bLevel)
 {
        MSG_BEGIN();
-#if 0
-       TCSLIB_HANDLE hLib;
-       TCSScanResult result;
-       TCSDetected* pDetected;
-       int rtn, i;
+       csr_cs_context_h csr_handle = NULL;
+       csr_cs_malware_h detected = NULL;
+       int ret = 0;
        int ret_b_level = -1;
 
        if (MsgAccessFile(filepath, R_OK) == false) {
@@ -1246,52 +1245,50 @@ int MsgTcsScanFile(const char *filepath, int *bLevel)
 
        MSG_SEC_DEBUG("Scanning file name : %s\n", filepath);
 
-       hLib = TCSLibraryOpen();
-       if(hLib == INVALID_TCSLIB_HANDLE) {
-               MSG_DEBUG("TCSLibraryOpen error\n");
+       ret = csr_cs_context_create(&csr_handle);
+       if (ret != CSR_ERROR_NONE) {
+               MSG_DEBUG("csr_cs_context_create error: err = %d\n", ret);
                return -1;
        }
 
-       rtn = TCSScanFile(hLib, filepath, TCS_DTYPE_UNKNOWN, TCS_SA_SCANONLY, 1, &result);
-       if(rtn == 0)
-       {
-               MSG_DEBUG("Detected malware number: %d\n", result.iNumDetected);
-               i = result.iNumDetected;
-               pDetected = result.pDList;
-               while(i && pDetected)
-               {
-                       int temp_b_level;
-                       int temp_s_class;
-                       MSG_SEC_DEBUG(" +-- Malware [%d] Name: %s\n", i, pDetected->pszName);
-                       MSG_DEBUG(" +-- Malware [%d] uAction: %u : 0x%04x\n", i, pDetected->uAction, pDetected->uAction);
-
-                       temp_b_level  = (pDetected->uAction & 0xFF00) >> 8;
-                       MSG_DEBUG(" +-- Malware [%d] Behavior level: %u\n", i, temp_b_level);
-
-                       if (ret_b_level == -1 || ret_b_level < temp_b_level) {
-                               ret_b_level = temp_b_level;
+       ret = csr_cs_scan_file(csr_handle, filepath, &detected);
+       if (ret == CSR_ERROR_NONE) {
+               if (detected) {
+                       csr_cs_severity_level_e severity;
+                       char *name = NULL;
+
+                       ret = csr_cs_malware_get_severity(detected, &severity);
+                       if (ret != CSR_ERROR_NONE) {
+                               MSG_DEBUG("csr_cs_malware_get_severity error: err = %d\n", ret);
                        }
 
-                       temp_s_class  = (pDetected->uAction & 0x00FF);
-                       MSG_DEBUG(" +-- Malware [%d] Severity class: %u\n", i, temp_s_class);
+                       ret = csr_cs_malware_get_name(detected, &name);
+                       if (ret != CSR_ERROR_NONE) {
+                               MSG_DEBUG("csr_cs_malware_get_name error: err = %d\n", ret);
+                       }
 
-                       pDetected = pDetected->pNext;
-                       i --;
-               }
+                       MSG_SEC_DEBUG(" +-- Malware Name: [%s]\n", name);
+                       MSG_DEBUG(" +-- Malware Severity class: %d\n", severity);
+
+                       ret_b_level = (int)severity;
 
-               result.pfFreeResult(&result);
+                       if (name) {
+                               free(name);
+                               name = NULL;
+                       }
+               }
        } else {
-               MSG_DEBUG("TCSScanFile fail: err = %d\n", rtn);
+               MSG_DEBUG("csr_cs_scan_file fail: err = %d\n", ret);
        }
 
-       TCSLibraryClose(hLib);
+       ret = csr_cs_context_destroy(csr_handle);
+       if (ret != CSR_ERROR_NONE) {
+               MSG_DEBUG("csr_cs_context_destroy error: err = %d\n", ret);
+       }
 
        if (bLevel)
                *bLevel = ret_b_level;
-#else
-       if (bLevel)
-               *bLevel = -1;
-#endif
+
        MSG_END();
 
        return 0;