X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=utils%2FMsgUtilFile.cpp;h=0467c11b2a9c2967d3c5b43063ddee6afdb6f52c;hb=refs%2Ftags%2Faccepted%2Ftizen%2Fcommon%2F20160325.135924;hp=3c9c9f8333fdba080771985b530e9320736e4920;hpb=82028c8dd5061b42e20fea83c59d296ca2202ac3;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git diff --git a/utils/MsgUtilFile.cpp b/utils/MsgUtilFile.cpp index 3c9c9f8..0467c11 100755 --- a/utils/MsgUtilFile.cpp +++ b/utils/MsgUtilFile.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "MsgStorageTypes.h" #include "MsgDebug.h" @@ -1260,6 +1262,71 @@ void MsgGetMimeType(char *filePath, char *mimeType, int size) } +int MsgTcsScanFile(const char *filepath, int *bLevel) +{ + MSG_BEGIN(); + TCSLIB_HANDLE hLib; + TCSScanResult result; + TCSDetected* pDetected; + int rtn, i; + int ret_b_level = -1; + + if (MsgAccessFile(filepath, R_OK) == false) { + MSG_SEC_DEBUG("not exist source file [%s]", filepath); + return -1; + } + + MSG_SEC_DEBUG("Scanning file name : %s\n", filepath); + + hLib = TCSLibraryOpen(); + if(hLib == INVALID_TCSLIB_HANDLE) { + MSG_DEBUG("TCSLibraryOpen error\n"); + 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; + } + + temp_s_class = (pDetected->uAction & 0x00FF); + MSG_DEBUG(" +-- Malware [%d] Severity class: %u\n", i, temp_s_class); + + pDetected = pDetected->pNext; + i --; + } + + result.pfFreeResult(&result); + } else { + MSG_DEBUG("TCSScanFile fail: err = %d\n", rtn); + } + + TCSLibraryClose(hLib); + + if (bLevel) + *bLevel = ret_b_level; + + MSG_END(); + + return 0; +} + + bool MsgAclInit() { /* ACL */