summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyeonghun Lee <kh9090.lee@samsung.com>2016-06-14 13:30:11 +0900
committerKyeonghun Lee <kh9090.lee@samsung.com>2016-06-14 14:31:30 +0900
commit6c38abca382be40d32d9cfa9869797df049bf373 (patch)
tree19a946440a88d82c2e384d5a19414f04a6ab811e
parent5b0788c40ee2b580333a10e21045e30b1529540a (diff)
downloadmsg-service-6c38abca382be40d32d9cfa9869797df049bf373.tar.gz
msg-service-6c38abca382be40d32d9cfa9869797df049bf373.tar.bz2
msg-service-6c38abca382be40d32d9cfa9869797df049bf373.zip
Change-Id: I3627e7fef4de0f13778041400b49467d8e0c1faf Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
-rwxr-xr-xpackaging/msg-service.spec1
-rwxr-xr-xutils/CMakeLists.txt2
-rwxr-xr-xutils/MsgUtilFile.cpp73
3 files changed, 37 insertions, 39 deletions
diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec
index ca0855e..fcdd7c7 100755
--- a/packaging/msg-service.spec
+++ b/packaging/msg-service.spec
@@ -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)
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 31d6df4..776bac3 100755
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -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})
diff --git a/utils/MsgUtilFile.cpp b/utils/MsgUtilFile.cpp
index b2710f7..83a0b50 100755
--- a/utils/MsgUtilFile.cpp
+++ b/utils/MsgUtilFile.cpp
@@ -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;