add/remove/modify APIs. 40/66340/1
authorDongsun Lee <ds73.lee@samsung.com>
Tue, 22 Mar 2016 11:15:02 +0000 (20:15 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 18 Apr 2016 11:11:59 +0000 (20:11 +0900)
- added: csre_wp_result_get_detailed_url
- added: csre_cs_scan_app_on_cloud
- added: csr_engine_get_lastest_update_time
- added: csr_engine_destroy
- added: csre_wp_engine_get_lastest_update_time
- added: csre_cs_engine_get_lastest_update_time
- removed: csre_cs_scan_file_by_fd
- removed: csre_cs_set_scan_on_cloud

Change-Id: I23820255cab0c8ae748d81640b622fded9d76efd
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
17 files changed:
engine/content-screening/resources/csret_cs_virus_signatures
engine/content-screening/sample-engine.cpp
engine/web-protection/resources/csret_wp_risky_urls
engine/web-protection/sample-engine.cpp
src/framework/client/engine-manager.cpp
src/include/csr/content-screening.h
src/include/csr/engine-manager.h
src/include/csr/error.h
src/include/csr/web-protection.h
src/include/csre/content-screening-engine-info.h
src/include/csre/content-screening.h
src/include/csre/web-protection-engine-info.h
src/include/csre/web-protection.h
test/resources/test_app/data/test_malware_file [new file with mode: 0644]
test/test-api-engine-content-screening.cpp
test/test-api-engine-manager.cpp
test/test-api-engine-web-protection.cpp

index e04a0d4..989d1fd 100644 (file)
@@ -9,11 +9,11 @@ severity=HIGH
 # MALWARE/RISKY/GENERIC
 threat_type=MALWARE
 # detailed_url can be null
-detailed_url=http://detailedinfo.malware.com
+detailed_url=http://high.malware.com
 signature=X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
 
 name=test_risk
 severity=MEDIUM
 threat_type=RISKY
-detailed_url=
+detailed_url=http://medium.malware.com
 signature=RISKY_MALWARE
index c3d8dd1..1e8145d 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <limits.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -37,7 +41,7 @@ extern "C" {
 
 #define PRIVATE_DB_NAME   "csret_cs_virus_signatures"
 #define PRIVATE_LOGO_FILE "vendor_logo.bmp"
-#define MAX_FILE_PATH_LEN 256
+#define MAX_FILE_PATH_LEN PATH_MAX
 #define MAX_NAME_LEN      64
 #define MAX_VERSION_LEN   32
 #define MAX_URL_LEN       256
@@ -47,11 +51,6 @@ extern "C" {
 #define ENGINE_NAME       "TEST_LOCAL_TCS_ENGINE"
 #define ENGINE_VERSION    "0.0.1"
 
-typedef enum  __csret_cs_scan_on_cloud {
-       TCSE_SCAN_ON_CLOUD_OFF = 0,
-       TCSE_SCAN_ON_CLOUD_ON  = 1
-} csret_cs_scan_on_cloud_e;
-
 typedef struct __csret_cs_malware {
        csre_cs_severity_level_e severity;
        csre_cs_threat_type_e threat_type;
@@ -87,6 +86,7 @@ typedef struct __csret_cs_engine {
        unsigned int image_size;
        char engine_version[MAX_VERSION_LEN];
        char data_version[MAX_VERSION_LEN];
+       time_t latest_update;
 } csret_cs_engine_s;
 
 typedef enum __csret_cs_internal_error {
@@ -111,7 +111,7 @@ char *csret_cs_extract_value(char *line, const char *key)
                return nullptr;
 
        auto found = strstr(line, key);
-       if (found == nullptr)
+       if (found != line)
                return nullptr;
 
        auto value = found + strlen(key);
@@ -136,13 +136,13 @@ int csret_cs_read_virus_signatures(const char *path)
        // name=test_malware // this starts a description of a new malware
        // severity=HIGH  // LOW/MEDIUM/HIGH
        // threat_type=MALWARE  // MALWARE/RISKY/GENERIC
-       // detailed_url=        // It can be null
+       // detailed_url=http://high.malware.com
        // signature=X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
        //
        // name=test_risk
        // severity=MEDIUM
        // threat_type=RISKY
-       // detailed_url=
+       // detailed_url=http://medium.malware.com
        // signature=RISKY_MALWARE
 
        csret_cs_malware_list_s *curr_sig = nullptr;
@@ -280,7 +280,9 @@ long csret_cs_get_timestamp()
 int csret_cs_init_engine(const char *root_dir)
 {
        int ret = CSRE_ERROR_NONE;
+       char db_file_name[MAX_FILE_PATH_LEN] = {0, };
        char logo_file_name[MAX_FILE_PATH_LEN] = {0, };
+       struct stat attrib;
        engine_info = (csret_cs_engine_s *) calloc(sizeof(csret_cs_engine_s), 1);
 
        if (engine_info == nullptr)
@@ -289,6 +291,7 @@ int csret_cs_init_engine(const char *root_dir)
        snprintf(engine_info->vendor_name, MAX_NAME_LEN, "%s", VENDOR_NAME);
        snprintf(engine_info->engine_name, MAX_NAME_LEN, "%s", ENGINE_NAME);
        snprintf(engine_info->engine_version, MAX_VERSION_LEN, "%s", ENGINE_VERSION);
+       snprintf(db_file_name, MAX_FILE_PATH_LEN, "%s/%s", root_dir, PRIVATE_DB_NAME);
        snprintf(logo_file_name, MAX_FILE_PATH_LEN, "%s/%s", root_dir, PRIVATE_LOGO_FILE);
        ret = csret_cs_read_binary(logo_file_name, &(engine_info->vendor_logo_image),
                                                        &(engine_info->image_size));
@@ -299,6 +302,9 @@ int csret_cs_init_engine(const char *root_dir)
                ret = CSRE_ERROR_NONE;
        }
 
+       stat(db_file_name, &attrib);
+       engine_info->latest_update = attrib.st_mtime;
+
        return ret;
 }
 
@@ -460,17 +466,6 @@ int csre_cs_context_destroy(csre_cs_context_h handle)
 }
 
 API
-int csre_cs_set_scan_on_cloud(csre_cs_context_h handle)
-{
-       if (handle == nullptr)
-               return CSRE_ERROR_INVALID_HANDLE;
-
-       csret_cs_context_s *context = (csret_cs_context_s *)handle;
-       context->scan_on_data = TCSE_SCAN_ON_CLOUD_ON;
-       return CSRE_ERROR_NONE;
-}
-
-API
 int csre_cs_scan_data(csre_cs_context_h handle,
                                          const unsigned char *data,
                                          size_t length,
@@ -484,10 +479,6 @@ int csre_cs_scan_data(csre_cs_context_h handle,
 
        csret_cs_context_s *context = (csret_cs_context_s *)handle;
 
-       if (context->scan_on_data == TCSE_SCAN_ON_CLOUD_ON) {
-               //ignored in this engine implementation.
-       }
-
        ret = csret_cs_detect_malware(context, data, length, &detected);
 
        if (ret != CSRE_ERROR_NONE)
@@ -502,37 +493,24 @@ int csre_cs_scan_file(csre_cs_context_h handle,
                                          const char *file_path,
                                          csre_cs_detected_h *pdetected)
 {
-       int fd = open(file_path, O_RDONLY);
-
-       if (fd < 0)
-               return CSRE_ERROR_FILE_NOT_FOUND;
-
-       return csre_cs_scan_file_by_fd(handle, fd, pdetected);
-}
-
-API
-int csre_cs_scan_file_by_fd(csre_cs_context_h handle,
-                                                       int file_descriptor,
-                                                       csre_cs_detected_h *pdetected)
-{
        csret_cs_detected_s *detected = nullptr;
        unsigned char *data;
        unsigned int data_len;
        int ret = CSRE_ERROR_NONE;
 
+       if (file_path == nullptr)
+               return CSRE_ERROR_INVALID_PARAMETER;
+
+       int fd = open(file_path, O_RDONLY);
+       if (fd < 0)
+               return CSRE_ERROR_FILE_NOT_FOUND;
+
        if (handle == nullptr)
                return CSRE_ERROR_INVALID_HANDLE;
 
-       if (file_descriptor < 0)
-               return CSRE_ERROR_INVALID_PARAMETER;
-
        csret_cs_context_s *context = (csret_cs_context_s *)handle;
 
-       if (context->scan_on_data == TCSE_SCAN_ON_CLOUD_ON) {
-               //ignored in this engine implementation.
-       }
-
-       ret = csret_cs_read_binary_by_fd(file_descriptor, &data, &data_len);
+       ret = csret_cs_read_binary(file_path, &data, &data_len);
        if (ret != CSRE_ERROR_NONE)
                return ret;
 
@@ -549,6 +527,63 @@ int csre_cs_scan_file_by_fd(csre_cs_context_h handle,
        return CSRE_ERROR_NONE;
 }
 
+API
+int csre_cs_scan_app_on_cloud(csre_cs_context_h handle,
+                                                         const char *app_root_dir,
+                                                         csre_cs_detected_h *pdetected)
+{
+       int ret;
+       DIR *dir;
+       struct dirent entry;
+       struct dirent *result;
+       csret_cs_detected_s *detected = nullptr;
+       csret_cs_detected_s *most_severe= nullptr;
+       int path_length;
+       char path[MAX_FILE_PATH_LEN] = {0 };
+
+       dir = opendir(app_root_dir);
+       if(!dir)
+               return CSRE_ERROR_FILE_NOT_FOUND;
+
+       while ((!readdir_r(dir, &entry, &result))) {
+               if(result == nullptr) // when the end of the directory stread is reached
+                       break;
+
+               path_length = snprintf(path, MAX_FILE_PATH_LEN, "%s/%s", app_root_dir, entry.d_name);
+               if(path_length >= MAX_FILE_PATH_LEN) {
+                       ret = CSRE_ERROR_UNKNOWN;
+                       goto error;
+               }
+
+               if( (entry.d_type & DT_REG) || (entry.d_type & DT_LNK) ) {
+                       ret = csre_cs_scan_file(handle, path, (csre_cs_detected_h *)(&detected) );
+               } else if( (entry.d_type & DT_DIR)
+                               && (strcmp(entry.d_name,"..") != 0)
+                               && (strcmp(entry.d_name,".") != 0) ) {
+                       ret = csre_cs_scan_app_on_cloud(handle, path, (csre_cs_detected_h *)(&detected) );
+               } else {
+                       continue;
+               }
+
+               if(ret != CSRE_ERROR_NONE)
+                       goto error;
+               if(detected != nullptr) { // detected
+                       if(most_severe == nullptr || detected->malware.severity > most_severe->malware.severity)
+                               most_severe = detected;
+                       else
+                               detected = nullptr;
+               }
+       }
+
+error:
+       if(dir != nullptr)
+               closedir(dir);
+
+       *pdetected = (csre_cs_detected_h) detected;
+
+       return ret;
+}
+
 //==============================================================================
 // Result related
 //==============================================================================
@@ -724,6 +759,21 @@ int csre_cs_engine_get_data_version(csre_cs_engine_h engine, const char **versio
 }
 
 API
+int csre_cs_engine_get_latest_update_time(csre_cs_engine_h engine, time_t *time)
+{
+       csret_cs_engine_s *eng = (csret_cs_engine_s *) engine;
+
+       if (eng == nullptr)
+               return CSRE_ERROR_INVALID_HANDLE;
+
+       if (time == nullptr)
+               return CSRE_ERROR_INVALID_PARAMETER;
+
+       *time = eng->latest_update;
+       return CSRE_ERROR_NONE;
+}
+
+API
 int csre_cs_engine_get_activated(csre_cs_engine_h engine, csre_cs_activated_e *pactivated)
 {
        csret_cs_engine_s *eng = (csret_cs_engine_s *) engine;
index 0b5ad1a..a12b1f8 100644 (file)
@@ -6,9 +6,11 @@ data_version=1.0.0
 url=highrisky.test.com
 # LOW/MEDIUM/HIGH
 risk_level=HIGH
+detailed_url=http://high.risky.com
 
 url=mediumrisky.test.com
 risk_level=MEDIUM
+detailed_url=http://medium.risky.com
 
 url=lowrisky.test.com
 risk_level=LOW
index ec35f71..f53f685 100644 (file)
 #include <cstdlib>
 #include <cstdio>
 #include <cstring>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #define API __attribute__((visibility("default")))
 
@@ -42,6 +46,7 @@
 typedef struct __csret_wp_risky_url {
        char url[MAX_URL_LEN];
        csre_wp_risk_level_e risk_level;
+       char detailed_url[MAX_URL_LEN];
 } csret_wp_risky_url_s;
 
 typedef struct __csret_wp_risky_url_list {
@@ -60,6 +65,7 @@ typedef struct __csret_wp_engine {
        unsigned int   image_size;
        char           engine_version[MAX_VERSION_LEN];
        char           data_version[MAX_VERSION_LEN];
+       time_t         latest_update;
 } csret_wp_engine_s;
 
 typedef enum __csret_wp_internal_error {
@@ -82,7 +88,7 @@ char *csret_wp_extract_value(char *line, const char *key)
                return nullptr;
 
        auto found = strstr(line, key);
-       if (found == nullptr)
+       if (found != line)
                return nullptr;
 
        auto value = found + strlen(key);
@@ -106,9 +112,11 @@ int csret_wp_read_risky_urls(const char *path)
        //
        // url=highrisky.test.com // this starts a description of a new risky url
        // risk_level=HIGH  // LOW/MEDIUM/HIGH
+       // detailed_url=http://high.risky.com
        //
        // url=midiumrisky.test.com
        // risk_level=MEDIUM
+       // detailed_url=http://medium.risky.com
        FILE *fp;
        char *line = nullptr;
        size_t len = 0;
@@ -155,6 +163,11 @@ int csret_wp_read_risky_urls(const char *path)
                        else
                                curr_url->risky_url->risk_level = CSRE_WP_RISK_UNVERIFIED;
                }
+
+               value = csret_wp_extract_value(line, "detailed_url=");
+
+               if (value != nullptr)
+                       strncpy(curr_url->risky_url->detailed_url, value, sizeof(curr_url->risky_url->detailed_url) - 1);
        }
 
        free(line);
@@ -213,7 +226,9 @@ int csret_wp_read_binary(const char *path, unsigned char **data, unsigned int *l
 int csret_wp_init_engine(const char *root_dir)
 {
        int ret = CSRE_ERROR_NONE;
+       char db_file_name[MAX_FILE_PATH_LEN] = {0, };
        char logo_file_name[MAX_FILE_PATH_LEN] = {0, };
+       struct stat attrib;
        engine_info = (csret_wp_engine_s *) calloc(sizeof(csret_wp_engine_s), 1);
 
        if (engine_info == nullptr)
@@ -222,6 +237,7 @@ int csret_wp_init_engine(const char *root_dir)
        snprintf(engine_info->vendor_name, MAX_NAME_LEN, "%s", VENDOR_NAME);
        snprintf(engine_info->engine_name, MAX_NAME_LEN, "%s", ENGINE_NAME);
        snprintf(engine_info->engine_version, MAX_VERSION_LEN, "%s", ENGINE_VERSION);
+       snprintf(db_file_name, MAX_FILE_PATH_LEN, "%s/%s", root_dir, PRIVATE_DB_NAME);
        snprintf(logo_file_name, MAX_FILE_PATH_LEN, "%s/%s", root_dir, PRIVATE_LOGO_FILE);
        ret = csret_wp_read_binary(logo_file_name, &(engine_info->vendor_logo_image),
                                                        &(engine_info->image_size));
@@ -232,6 +248,9 @@ int csret_wp_init_engine(const char *root_dir)
                ret = CSRE_ERROR_NONE;
        }
 
+       stat(db_file_name, &attrib);
+       engine_info->latest_update = attrib.st_mtime;
+
        return ret;
 }
 
@@ -342,6 +361,7 @@ int csre_wp_check_url(csre_wp_context_h handle, const char *url, csre_wp_check_r
 
                if (strstr(url, risky_url) != nullptr) { // found
                        detected->risk_level = curr_url->risky_url->risk_level;
+                       snprintf(detected->detailed_url, MAX_URL_LEN, "%s", curr_url->risky_url->detailed_url);
                        break; // return the first risky url info in test engine
                }
 
@@ -375,6 +395,22 @@ int csre_wp_result_get_risk_level(csre_wp_check_result_h result, csre_wp_risk_le
        return CSRE_ERROR_NONE;
 }
 
+API
+int csre_wp_result_get_detailed_url(csre_wp_check_result_h result, const char** detailed_url)
+{
+       csret_wp_risky_url_s *detected = nullptr;
+
+       if (result == nullptr)
+               return CSRE_ERROR_INVALID_HANDLE;
+
+       if (detailed_url == nullptr)
+               return CSRE_ERROR_INVALID_PARAMETER;
+
+       detected = (csret_wp_risky_url_s *) result;
+       *detailed_url = detected->detailed_url;
+       return CSRE_ERROR_NONE;
+}
+
 //==============================================================================
 // Engine information related
 //==============================================================================
@@ -465,6 +501,23 @@ int csre_wp_engine_get_data_version(csre_wp_engine_h engine, const char **versio
        return CSRE_ERROR_NONE;
 }
 
+
+API
+int csre_wp_engine_get_latest_update_time(csre_wp_engine_h engine, time_t *time)
+{
+       csret_wp_engine_s *eng = (csret_wp_engine_s *) engine;
+
+       if (eng == nullptr)
+               return CSRE_ERROR_INVALID_HANDLE;
+
+       if (time == nullptr)
+               return CSRE_ERROR_INVALID_PARAMETER;
+
+       *time = eng->latest_update;
+       return CSRE_ERROR_NONE;
+}
+
+
 API
 int csre_wp_engine_get_activated(csre_wp_engine_h engine, csre_wp_activated_e *pactivated)
 {
index f4a3c91..9a3a013 100644 (file)
@@ -26,7 +26,7 @@
 #define API __attribute__((visibility("default")))
 
 API
-int csr_get_selected_engine(csr_engine_id_e id, csr_engine_h *engine)
+int csr_get_current_engine(csr_engine_id_e id, csr_engine_h *engine)
 {
        (void) id;
        (void) engine;
@@ -79,3 +79,11 @@ int csr_engine_get_activated(csr_engine_h engine, csr_activated_e *pactivated)
        DEBUG("start");
        return CSR_ERROR_NONE;
 }
+
+API
+int csr_engine_destroy(csr_engine_h engine)
+{
+       (void) engine;
+       DEBUG("start");
+       return CSR_ERROR_NONE;
+}
index 8055f12..b58dc7e 100644 (file)
@@ -55,8 +55,6 @@ int csr_cs_context_create(csr_cs_context_h* phandle);
 /**
  * @brief Releases all system resources associated with a Malware Screening API handle.
  *
- * @details The handle is one returned by the csr_cs_context_create() function.
- *
  * @param[in] handle CSR CS context handle returned by csr_cs_context_create().
  *
  * @return #CSR_ERROR_NONE on success, otherwise a negative error value
@@ -164,7 +162,7 @@ int csr_cs_set_scan_on_cloud(csr_cs_context_h handle);
  * @retval #CSR_ERROR_INVALID_PARAMETER     data or presult is invalid
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
@@ -193,7 +191,7 @@ int csr_cs_scan_data(csr_cs_context_h handle,
  * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
@@ -311,7 +309,7 @@ int csr_cs_set_callback_on_file_scanned(csr_cs_context_h handle, csr_cs_on_file_
  * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
@@ -342,7 +340,7 @@ int csr_cs_scan_files_async(csr_cs_context_h handle,
  * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
@@ -375,7 +373,7 @@ int csr_cs_scan_dir_async(csr_cs_context_h handle,
  * @retval #CSR_ERROR_FILE_NOT_FOUND        File not found
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
index 4099dd8..3bd50dc 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef __CSR_ENGINE_MANAGER_H_
 #define __CSR_ENGINE_MANAGER_H_
 
+#include <time.h>
 #include "csr/content-screening-types.h"
 #include "csr/web-protection-types.h"
 #include "csr/error.h"
@@ -47,7 +48,7 @@ typedef enum {
 } csr_activated_e;
 
 /**
- * @brief Gets the handle of a selected engine information.
+ * @brief Gets the handle of a current engine information.
  *
  * @param[in]  id       Engine identifier to get handle.
  * @param[out] pengine  A pointer of the engine information handle.
@@ -55,14 +56,13 @@ typedef enum {
  * @return #CSR_ERROR_NONE on success, otherwise a negative error value
  *
  * @retval #CSR_ERROR_NONE                 Successful
- * @retval #CSR_ERROR_INVALID_HANDLE       Invalid handle
  * @retval #CSR_ERROR_INVALID_PARAMETER    pengine is invalid
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED  No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST     No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  */
-int csr_get_selected_engine(csr_engine_id_e id, csr_engine_h *engine);
+int csr_get_current_engine(csr_engine_id_e id, csr_engine_h *pengine);
 
 /**
  * @brief Extracts an vendor name from the engine information handle.
@@ -78,7 +78,7 @@ int csr_get_selected_engine(csr_engine_id_e id, csr_engine_h *engine);
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  *
- * @see csr_get_selected_engine()
+ * @see csr_get_current_engine()
  */
 int csr_engine_get_vendor(csr_engine_h engine, char **vendor);
 
@@ -96,7 +96,7 @@ int csr_engine_get_vendor(csr_engine_h engine, char **vendor);
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  *
- * @see csr_get_selected_engine()
+ * @see csr_get_current_engine()
  */
 int csr_engine_get_name(csr_engine_h engine, char **name);
 
@@ -111,11 +111,10 @@ int csr_engine_get_name(csr_engine_h engine, char **name);
  * @retval #CSR_ERROR_NONE                 Successful
  * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
  * @retval #CSR_ERROR_INVALID_PARAMETER    engine_version is invalid
- * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  *
- * @see csr_get_selected_engine()
+ * @see csr_get_current_engine()
  */
 int csr_engine_get_version(csr_engine_h engine, char **version);
 
@@ -130,15 +129,32 @@ int csr_engine_get_version(csr_engine_h engine, char **version);
  * @retval #CSR_ERROR_NONE                 Successful
  * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
  * @retval #CSR_ERROR_INVALID_PARAMETER    engine_version is invalid
- * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  *
- * @see csr_get_selected_engine()
+ * @see csr_get_current_engine()
  */
 int csr_engine_get_data_version(csr_engine_h engine, char **version);
 
 /**
+ * @brief Extracts the latest update time of an engine from the engine information handle.
+ *
+ * @param[in]  engine   The engine information handle.
+ * @param[out] time     A pointer of lasted update time.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    time is invalid
+ * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_get_current_engine()
+ */
+int csr_engine_get_latest_update_time(csr_engine_h engine, time_t *time);
+
+/**
  * @brief Extracts the state of engine activation from the engine information handle.
  *
  * @param[in]  engine      The engine information handle.
@@ -152,10 +168,26 @@ int csr_engine_get_data_version(csr_engine_h engine, char **version);
  * @retval #CSR_ERROR_ENGINE_INTERNAL      Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
  *
- * @see csr_get_selected_engine()
+ * @see csr_get_current_engine()
  */
 int csr_engine_get_activated(csr_engine_h engine, csr_activated_e *pactivated);
 
+/**
+ * @brief Releases all system resources associated with a engine information handle.
+ *
+ * @param[in]  engine      The engine information handle.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                  Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE        Invalid handle
+ * @retval #CSR_ERROR_SOCKET                Socket error between client and server
+ * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
+ * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
+ * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
+ */
+int csr_engine_destroy(csr_engine_h engine);
+
 #ifdef __cplusplus
 }
 #endif
index 8665ee0..8f95d80 100644 (file)
@@ -47,7 +47,7 @@ typedef enum {
        CSR_ERROR_SERVER                = TIZEN_ERROR_CSR | 0x03,        /**< Server has been failed for some reason */
        CSR_ERROR_NO_TASK               = TIZEN_ERROR_CSR | 0x04,        /**< No Task exists*/
        CSR_ERROR_ENGINE_PERMISSION     = TIZEN_ERROR_CSR | 0x11,        /**< Insufficient permission of engine */
-       CSR_ERROR_ENGINE_NOT_SELECTED   = TIZEN_ERROR_CSR | 0x12,        /**< No engine is selected*/
+       CSR_ERROR_ENGINE_NOT_EXIST      = TIZEN_ERROR_CSR | 0x12,        /**< No engine exists*/
        CSR_ERROR_ENGINE_NOT_ACTIVATED  = TIZEN_ERROR_CSR | 0x13,        /**< Engine is not activated*/
        CSR_ERROR_ENGINE_INTERNAL       = TIZEN_ERROR_CSR | 0x19,        /**< Engine Internal error*/
        CSR_ERROR_UNKNOWN               = TIZEN_ERROR_CSR | 0xFF,        /**< The error with unknown reason */
index f4ec2ac..4bd6aec 100644 (file)
@@ -60,8 +60,6 @@ int csr_wp_context_create(csr_wp_context_h* phandle);
 /**
  * @brief Releases all system resources associated with a CSR Web Protection API handle.
  *
- * @details The handle is one returned by the csr_wp_context_create().
- *
  * @param[in] handle CSR WP context handle returned by csr_wp_context_create().
  *
  * @return #CSR_ERROR_NONE on success, otherwise a negative error value
@@ -141,7 +139,7 @@ int csr_wp_set_popup_message(csr_wp_context_h handle, const char* message);
  * @retval #CSR_ERROR_INVALID_PARAMETER     URL or presult is invalid
  * @retval #CSR_ERROR_SOCKET                Socket error between client and server
  * @retval #CSR_ERROR_SERVER                Server has been failed for some reason
- * @retval #CSR_ERROR_ENGINE_NOT_SELECTED   No engine selected
+ * @retval #CSR_ERROR_ENGINE_NOT_EXIST      No engine exists
  * @retval #CSR_ERROR_ENGINE_NOT_ACTIVATED  Engine is not activated
  * @retval #CSR_ERROR_ENGINE_INTERNAL       Engine Internal error
  * @retval #CSR_ERROR_UNKNOWN               Error with unknown reason
@@ -173,6 +171,27 @@ int csr_wp_check_url(csr_wp_context_h handle, const char *url, csr_wp_check_resu
 int csr_wp_result_get_risk_level(csr_wp_check_result_h result, csr_wp_risk_level_e* plevel);
 
 /**
+ * @brief Extracts an url of vendor's web site that contains detailed information about the risk
+ *        from the result handle.
+ *
+ * @param[in]  result  A result handle returned by csr_wp_check_url().
+ * @param[out] detailed_url  A pointer of an url that contains detailed information about the risk.
+ *                           If the risk level is CSR_WP_RISK_MEDIUM or CSR_WP_RISK_HIGH,
+ *                           this url should be provided by the engine.
+ *                           A caller should not free this string.
+ *
+ * @return #CSR_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSR_ERROR_NONE                 Successful
+ * @retval #CSR_ERROR_INVALID_HANDLE       Invalid result handle
+ * @retval #CSR_ERROR_INVALID_PARAMETER    detailed_url is invalid
+ * @retval #CSR_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csr_wp_check_url()
+ */
+int csr_wp_result_get_detailed_url(csr_wp_check_result_h result, const char** detailed_url);
+
+/**
  * @brief Extracts a user reponse of a popup from the result handle.
  *
  * @param[in]  result     A result handle returned by csr_wp_check_url().
index aa3bd7b..e6394c5 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef __CSRE_CS_ENGINE_INFO_H_
 #define __CSRE_CS_ENGINE_INFO_H_
 
+#include <time.h>
 #include "csre/error.h"
 
 #ifdef __cplusplus
@@ -149,6 +150,25 @@ int csre_cs_engine_get_version(csre_cs_engine_h engine, const char **version);
 int csre_cs_engine_get_data_version(csre_cs_engine_h engine, const char **version);
 
 /**
+ * @brief Extracts the latest update time of an engine from the engine information handle.
+ *
+ * @param[in]  engine   The engine information handle.
+ * @param[out] time     A pointer of lasted update time.
+ *
+ * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSRE_ERROR_NONE                 Successful
+ * @retval #CSRE_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER    time is invalid
+ * @retval #CSRE_ERROR_UNKNOWN              Error with unknown reason
+ * @retval #CSRE_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSRE_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csre_cs_get_engine_info()
+ */
+int csre_cs_engine_get_latest_update_time(csre_cs_engine_h engine, time_t *time);
+
+/**
  * @brief Extracts the state of engine activation from the engine information handle.
  *
  * @param[in]  engine      The engine information handle.
index 7b17f0b..e3c6341 100644 (file)
@@ -79,22 +79,6 @@ int csre_cs_context_create(const char *engine_root_dir, csre_cs_context_h* phand
 int csre_cs_context_destroy(csre_cs_context_h handle);
 
 /**
- * @brief Sets a database which is used in scanning.
- *
- * @details If a database is not set or an engine does not support "scanning on cloud",
- *          the scanning will be done in a local device.
- *
- * @param[in] handle    CSR CS context handle returned by csre_cs_context_create().
- *
- * @return #CSRE_CS_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #CSRE_CS_ERROR_NONE                  Successful
- * @retval #CSRE_CS_ERROR_INVALID_HANDLE        Invalid handle
- * @retval #CSRE_CS_ERROR_UNKNOWN               Error with unknown reason
- */
-int csre_cs_set_scan_on_cloud(csre_cs_context_h handle);
-
-/**
  * @brief Main function for caller to scan a data buffer for malware.
  *
  * @param[in]  handle     CSR CS Engine context handle returned by
@@ -116,7 +100,6 @@ int csre_cs_set_scan_on_cloud(csre_cs_context_h handle);
  *
  * @see csre_cs_context_create()
  * @see csre_cs_scan_file()
- * @see csre_cs_scan_file_by_fd()
  */
 int csre_cs_scan_data(csre_cs_context_h handle,
                     const unsigned char *data,
@@ -146,33 +129,28 @@ int csre_cs_scan_data(csre_cs_context_h handle,
  *
  * @see csre_cs_context_create()
  * @see csre_cs_scan_data()
- * @see csre_cs_scan_file_by_fd()
  */
 int csre_cs_scan_file(csre_cs_context_h handle,
                   const char *file_path,
                   csre_cs_detected_h *pdetected);
 
 /**
- * @brief Main function for caller to scan a file specified by file descriptor for malware.
+ * @brief Main function for caller to scan an application specified 
+ *        by an application's root directory for malware.
+ *        The detection of a malware is done on the vendor's clould server.
  *
- * @details  The file is opened in readonly by another processe and its file descriptor
- *           is delivered to the engine. This is useful in case of an insufficient
- *           permission of a server process with scanning function. The client with
- *           permission to a file opens the file and deliver its descriptor to a server
- *           with an insufficient permission.
- *
- * @param[in]  handle           CSR CS Engine context handle returned by
- *                              csre_cs_context_create().
- * @param[in]  file_descriptor  A file descriptor of scan target file.
- * @param[out] pdetected        A pointer of the detected malware handle. It can be null
- *                              when no malware detected.
+ * @param[in]  handle       CSR CS Engine context handle returned by
+ *                          csre_cs_context_create().
+ * @param[in]  app_root_dir A absolute root path of scan target application.
+ * @param[out] pdetected    A pointer of the detected malware handle. It can be null when
+ *                          no malware detected.
  *
  * @return #CSRE_CS_ERROR_NONE on success, otherwise a negative error value
  *
  * @retval #CSRE_CS_ERROR_NONE                 Successful
  * @retval #CSRE_CS_ERROR_INVALID_HANDLE       Invalid handle
  * @retval #CSRE_CS_ERROR_OUT_OF_MEMORY        Not enough memory
- * @retval #CSRE_CS_ERROR_INVALID_PARAMETER    presult is invalid
+ * @retval #CSRE_CS_ERROR_INVALID_PARAMETER    app_root_dir or presult is invalid
  * @retval #CSRE_CS_ERROR_ENGINE_NOT_ACTIVATED Engine is not activated
  * @retval #CSRE_CS_ERROR_PERMISSION_DENIED    Access denied
  * @retval #CSRE_CS_ERROR_FILE_NOT_FOUND       File not found
@@ -181,10 +159,8 @@ int csre_cs_scan_file(csre_cs_context_h handle,
  *
  * @see csre_cs_context_create()
  * @see csre_cs_scan_data()
- * @see csre_cs_scan_file()
  */
-int csre_cs_scan_file_by_fd(csre_cs_context_h handle,
-                  int file_descriptor,
+int csre_cs_scan_app_on_cloud(csre_cs_context_h handle, const char* app_root_dir,
                   csre_cs_detected_h *pdetected);
 
 //==============================================================================
@@ -247,13 +223,12 @@ int csre_cs_detected_get_threat_type(csre_cs_detected_h detected, csre_cs_threat
 int csre_cs_detected_get_malware_name(csre_cs_detected_h detected, const char** name);
 
 /**
- * @brief Extracts an url that contains detailed information on vendor's web site from the
- *        detected malware handle.
+ * @brief Extracts an url of the vendor's web site that contains detailed information 
+ *      about the detected malware from the detected malware handle.
  *
  * @param[in]  detected      A detected malware handle.
  * @param[out] detailed_url  A pointer of an url that contains detailed information on
- *                           vendor's web site. It can be null if a vendor doesn't provide
- *                           this information. A caller should not free this string.
+ *                           vendor's web site. A caller should not free this string.
  *
  * @return #CSRE_CS_ERROR_NONE on success, otherwise a negative error value
  *
index cade082..2343462 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef __CSRE_WEB_PROTECTION_ENGINE_INFO_H_
 #define __CSRE_WEB_PROTECTION_ENGINE_INFO_H_
 
+#include <time.h>
 #include "csre/error.h"
 
 #ifdef __cplusplus
@@ -149,6 +150,25 @@ int csre_wp_engine_get_version(csre_wp_engine_h engine, const char **version);
 int csre_wp_engine_get_data_version(csre_wp_engine_h engine, const char **version);
 
 /**
+ * @brief Extracts the latest update time of an engine from the engine information handle.
+ *
+ * @param[in]  engine   The engine information handle.
+ * @param[out] time     A pointer of lasted update time.
+ *
+ * @return #CSRE_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSRE_ERROR_NONE                 Successful
+ * @retval #CSRE_ERROR_INVALID_HANDLE       Invalid engine information handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER    time is invalid
+ * @retval #CSRE_ERROR_UNKNOWN              Error with unknown reason
+ * @retval #CSRE_ERROR_ENGINE_INTERNAL      Engine Internal error
+ * @retval #CSRE_ERROR_UNKNOWN              Error with unknown reason
+ *
+ * @see csre_wp_get_engine_info()
+ */
+int csre_wp_engine_get_latest_update_time(csre_wp_engine_h engine, time_t *time);
+
+/**
  * @brief Extracts the state of engine activation from the engine information handle.
  *
  * @param[in]  engine      The engine information handle.
index e4cf560..9db4c08 100644 (file)
@@ -120,6 +120,26 @@ int csre_wp_check_url(csre_wp_context_h handle, const char *url, csre_wp_check_r
 int csre_wp_result_get_risk_level(csre_wp_check_result_h result, csre_wp_risk_level_e* plevel);
 
 /**
+ * @brief Extracts an url of vendor's web site that contains detailed information about the risk
+ *        from the result handle.
+ *
+ * @param[in]  result  A result handle returned by csre_wp_check_url().
+ * @param[out] detailed_url  A pointer of an url that contains detailed information about the risk.
+ *                           If the risk level is CSRE_WP_RISK_MEDIUM or CSRE_WP_RISK_HIGH,
+ *                           this url should be provided by the engine.
+ *                           A caller should not free this string.
+ *
+ * @return #CSRE_CS_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #CSRE_CS_ERROR_NONE                 Successful
+ * @retval #CSRE_ERROR_INVALID_HANDLE       Invalid result handle
+ * @retval #CSRE_ERROR_INVALID_PARAMETER    detailed_url is invalid
+ * @retval #CSRE_ERROR_UNKNOWN              Error with unknown reason
+ * @retval -0x0100~-0xFF00                  Engine defined error
+ */
+int csre_wp_result_get_detailed_url(csre_wp_check_result_h result, const char** detailed_url);
+
+/**
  * @brief Get the error string for a given engine-defined error code.
  *
  * @details The error strings are managed by the engine, therefore a caller should not
diff --git a/test/resources/test_app/data/test_malware_file b/test/resources/test_app/data/test_malware_file
new file mode 100644 (file)
index 0000000..0591f12
--- /dev/null
@@ -0,0 +1 @@
+aabbccX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*112233
index ad61b5e..68e2d0f 100644 (file)
@@ -37,6 +37,7 @@
 #define TEST_FILE_NORMAL   TEST_DIR "/test_normal_file"
 #define TEST_FILE_MALWARE  TEST_DIR "/test_malware_file"
 #define TEST_FILE_RISKY    TEST_DIR "/test_risky_file"
+#define TEST_APP_ROOT      TEST_DIR "/test_app"
 
 namespace {
 
@@ -236,7 +237,7 @@ BOOST_AUTO_TEST_CASE(scan_data_high)
                CSRE_CS_SEVERITY_HIGH,
                CSRE_CS_THREAT_MALWARE,
                "test_malware",
-               "http://detailedinfo.malware.com",
+               "http://high.malware.com",
                0);
 }
 
@@ -279,22 +280,6 @@ BOOST_AUTO_TEST_CASE(scan_file_normal)
        CHECK_IS_NULL(detected);
 }
 
-BOOST_AUTO_TEST_CASE(scan_file_normal_on_cloud)
-{
-       int ret = CSRE_ERROR_UNKNOWN;
-       auto contextPtr = getContextHandle();
-       auto context = contextPtr->get();
-
-       BOOST_REQUIRE_NO_THROW(ret = csre_cs_set_scan_on_cloud(context));
-       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
-
-       csre_cs_detected_h detected;
-       BOOST_REQUIRE_NO_THROW(ret = csre_cs_scan_file(context, TEST_FILE_NORMAL, &detected));
-
-       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
-       CHECK_IS_NULL(detected);
-}
-
 BOOST_AUTO_TEST_CASE(scan_file_malware)
 {
        int ret = CSRE_ERROR_UNKNOWN;
@@ -311,7 +296,7 @@ BOOST_AUTO_TEST_CASE(scan_file_malware)
                CSRE_CS_SEVERITY_HIGH,
                CSRE_CS_THREAT_MALWARE,
                "test_malware",
-               "http://detailedinfo.malware.com",
+               "http://high.malware.com",
                0);
 }
 
@@ -331,35 +316,18 @@ BOOST_AUTO_TEST_CASE(scan_file_risky)
                CSRE_CS_SEVERITY_MEDIUM,
                CSRE_CS_THREAT_RISKY,
                "test_risk",
-               nullptr,
+               "http://medium.malware.com",
                0);
 }
 
-BOOST_AUTO_TEST_CASE(scan_file_by_fd_normal)
+BOOST_AUTO_TEST_CASE(scan_app_on_cloud)
 {
        int ret = CSRE_ERROR_UNKNOWN;
        auto contextPtr = getContextHandle();
        auto context = contextPtr->get();
 
-       ScopedFile f(TEST_FILE_NORMAL);
-
        csre_cs_detected_h detected;
-       BOOST_REQUIRE_NO_THROW(ret = csre_cs_scan_file_by_fd(context, f.getFd(), &detected));
-
-       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
-       CHECK_IS_NULL(detected);
-}
-
-BOOST_AUTO_TEST_CASE(scan_file_by_fd_malware)
-{
-       int ret = CSRE_ERROR_UNKNOWN;
-       auto contextPtr = getContextHandle();
-       auto context = contextPtr->get();
-
-       ScopedFile f(TEST_FILE_MALWARE);
-
-       csre_cs_detected_h detected;
-       BOOST_REQUIRE_NO_THROW(ret = csre_cs_scan_file_by_fd(context, f.getFd(), &detected));
+       BOOST_REQUIRE_NO_THROW(ret = csre_cs_scan_app_on_cloud(context, TEST_APP_ROOT,&detected));
 
        BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
        CHECK_IS_NOT_NULL(detected);
@@ -368,31 +336,10 @@ BOOST_AUTO_TEST_CASE(scan_file_by_fd_malware)
                CSRE_CS_SEVERITY_HIGH,
                CSRE_CS_THREAT_MALWARE,
                "test_malware",
-               "http://detailedinfo.malware.com",
+               "http://high.malware.com",
                0);
 }
 
-BOOST_AUTO_TEST_CASE(scan_file_by_fd_risky)
-{
-       int ret = CSRE_ERROR_UNKNOWN;
-       auto contextPtr = getContextHandle();
-       auto context = contextPtr->get();
-
-       ScopedFile f(TEST_FILE_RISKY);
-
-       csre_cs_detected_h detected;
-       BOOST_REQUIRE_NO_THROW(ret = csre_cs_scan_file_by_fd(context, f.getFd(), &detected));
-
-       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
-       CHECK_IS_NOT_NULL(detected);
-
-       checkDetected(detected,
-               CSRE_CS_SEVERITY_MEDIUM,
-               CSRE_CS_THREAT_RISKY,
-               "test_risk",
-               nullptr,
-               0);
-}
 
 BOOST_AUTO_TEST_SUITE_END()
 
@@ -465,6 +412,17 @@ BOOST_AUTO_TEST_CASE(get_data_version)
        CHECK_IS_NOT_NULL(version);
 }
 
+BOOST_AUTO_TEST_CASE(get_latest_update_time)
+{
+       int ret = CSRE_ERROR_UNKNOWN;
+       auto handle = getEngineHandle();
+
+       time_t time = 0;
+       BOOST_REQUIRE_NO_THROW(ret = csre_cs_engine_get_latest_update_time(handle, &time));
+       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
+       BOOST_REQUIRE(time > 0);
+}
+
 BOOST_AUTO_TEST_CASE(get_engine_activated)
 {
        int ret = CSRE_ERROR_UNKNOWN;
index 2765339..8d3dd73 100644 (file)
 
 BOOST_AUTO_TEST_SUITE(API_ENGINE_MANAGER)
 
-BOOST_AUTO_TEST_CASE(get_selected_engine)
+BOOST_AUTO_TEST_CASE(get_current_engine)
 {
        int ret = CSR_ERROR_UNKNOWN;
 
        csr_engine_h handle;
-       BOOST_REQUIRE_NO_THROW(ret = csr_get_selected_engine(CSR_ENGINE_CS, &handle));
+       BOOST_REQUIRE_NO_THROW(ret = csr_get_current_engine(CSR_ENGINE_CS, &handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_engine_destroy(handle));
        BOOST_REQUIRE(ret == CSR_ERROR_NONE);
 }
 
@@ -40,12 +43,15 @@ BOOST_AUTO_TEST_CASE(get_name)
        int ret = CSR_ERROR_UNKNOWN;
 
        csr_engine_h handle;
-       BOOST_REQUIRE_NO_THROW(ret = csr_get_selected_engine(CSR_ENGINE_CS, &handle));
+       BOOST_REQUIRE_NO_THROW(ret = csr_get_current_engine(CSR_ENGINE_CS, &handle));
        BOOST_REQUIRE(ret == CSR_ERROR_NONE);
 
        char *name = nullptr;
        BOOST_REQUIRE_NO_THROW(ret = csr_engine_get_name(handle, &name));
        BOOST_REQUIRE(ret == CSR_ERROR_NONE);
+
+       BOOST_REQUIRE_NO_THROW(ret = csr_engine_destroy(handle));
+       BOOST_REQUIRE(ret == CSR_ERROR_NONE);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
index a5fcef7..73d204a 100644 (file)
@@ -34,15 +34,16 @@ namespace {
 
 struct Result {
        csre_wp_risk_level_e risk_level;
+       std::string detailed_url;
 
-       Result(csre_wp_risk_level_e r) : risk_level(r) {}
+       Result(csre_wp_risk_level_e r, const char* durl) : risk_level(r), detailed_url(durl) {}
 };
 
 std::unordered_map<std::string, Result> ExpectedResult = {
-       {"http://normal.test.com",      Result(CSRE_WP_RISK_UNVERIFIED)},
-       {"http://highrisky.test.com",   Result(CSRE_WP_RISK_HIGH)},
-       {"http://mediumrisky.test.com", Result(CSRE_WP_RISK_MEDIUM)},
-       {"http://lowrisky.test.com",    Result(CSRE_WP_RISK_LOW)}
+       {"http://normal.test.com",      Result(CSRE_WP_RISK_UNVERIFIED, "")},
+       {"http://highrisky.test.com",   Result(CSRE_WP_RISK_HIGH, "http://high.risky.com")},
+       {"http://mediumrisky.test.com", Result(CSRE_WP_RISK_MEDIUM, "http://medium.risky.com")},
+       {"http://lowrisky.test.com",    Result(CSRE_WP_RISK_LOW, "")}
 };
 
 inline void checkResult(csre_wp_check_result_h &result, const Result &expected)
@@ -57,6 +58,14 @@ inline void checkResult(csre_wp_check_result_h &result, const Result &expected)
        BOOST_REQUIRE_MESSAGE(risk_level == expected.risk_level,
                "risk level isn't expected value. "
                        "val: " << risk_level << " expected: " << expected.risk_level);
+
+       const char *detailed_url = nullptr;
+       BOOST_REQUIRE_NO_THROW(ret = csre_wp_result_get_detailed_url(result, &detailed_url));
+
+       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
+       BOOST_REQUIRE_MESSAGE(expected.detailed_url.compare(detailed_url) == 0,
+               "detailed url isn't expected value. "
+                       "val: " << detailed_url <<" expected: " << expected.detailed_url);
 }
 
 class ContextPtr {
@@ -210,6 +219,17 @@ BOOST_AUTO_TEST_CASE(get_data_version)
        CHECK_IS_NOT_NULL(version);
 }
 
+BOOST_AUTO_TEST_CASE(get_latest_update_time)
+{
+       int ret = CSRE_ERROR_UNKNOWN;
+       auto handle = getEngineHandle();
+
+       time_t time = 0;
+       BOOST_REQUIRE_NO_THROW(ret = csre_wp_engine_get_latest_update_time(handle, &time));
+       BOOST_REQUIRE(ret == CSRE_ERROR_NONE);
+       BOOST_REQUIRE(time > 0);
+}
+
 BOOST_AUTO_TEST_CASE(get_engine_activated)
 {
        int ret = CSRE_ERROR_UNKNOWN;