SET(${TARGET_CSR_SERVER}_SRCS
framework/main/csr-main.cpp
framework/service/logic.cpp
+ framework/service/type-converter.cpp
framework/service/server-service.cpp
framework/service/thread-pool.cpp
framework/service/core-usage.cpp
#include "common/cs-detected.h"
#include "common/wp-result.h"
#include "common/audit/logger.h"
+#include "service/type-converter.h"
#include "ui/askuser.h"
#include "csr/error.h"
{
DEBUG("convert engine result handle to WpResult start");
+ WpResult wr;
+
+ // getting risk level
csre_wp_risk_level_e elevel;
int eret = m_wp->getRiskLevel(r, &elevel);
if (eret != CSRE_ERROR_NONE)
throw std::runtime_error(FORMAT("Converting wp result. ret: " << eret));
- DEBUG("Get engine risk level: " << static_cast<int>(elevel));
-
- csr_wp_risk_level_e level;
-
- switch (elevel) {
- case CSRE_WP_RISK_LOW:
- level = CSR_WP_RISK_LOW;
- break;
-
- case CSRE_WP_RISK_UNVERIFIED:
- level = CSR_WP_RISK_UNVERIFIED;
- break;
-
- case CSRE_WP_RISK_MEDIUM:
- level = CSR_WP_RISK_MEDIUM;
- break;
-
- case CSRE_WP_RISK_HIGH:
- level = CSR_WP_RISK_HIGH;
- break;
-
- default:
- throw std::logic_error(FORMAT("Invalid elevel: " << static_cast<int>(elevel)));
- }
+ wr.riskLevel = Csr::convert(elevel);
- std::string detailedUrl;
- eret = m_wp->getDetailedUrl(r, detailedUrl);
+ // getting detailed url
+ eret = m_wp->getDetailedUrl(r, wr.detailedUrl);
if (eret != CSRE_ERROR_NONE)
throw std::runtime_error(FORMAT("Converting wp result. ret: " << eret));
- DEBUG("Get detailed url from engine: " << detailedUrl);
-
- WpResult wr;
-
- wr.detailedUrl = detailedUrl;
- wr.riskLevel = level;
-
return wr;
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file type-converter.cpp
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Converts types of engine interface to capi interface
+ */
+#include "service/type-converter.h"
+
+#include <stdexcept>
+
+#include "common/audit/logger.h"
+
+namespace Csr {
+
+csr_cs_severity_level_e convert(const csre_cs_severity_level_e &e)
+{
+ switch (e) {
+ case CSRE_CS_SEVERITY_LOW:
+ return CSR_CS_SEVERITY_LOW;
+
+ case CSRE_CS_SEVERITY_MEDIUM:
+ return CSR_CS_SEVERITY_MEDIUM;
+
+ case CSRE_CS_SEVERITY_HIGH:
+ return CSR_CS_SEVERITY_HIGH;
+
+ default:
+ throw std::logic_error(FORMAT("Invalid eseverity: " << static_cast<int>(e)));
+ }
+}
+
+csr_cs_threat_type_e convert(const csre_cs_threat_type_e &e)
+{
+ switch (e) {
+ case CSRE_CS_THREAT_MALWARE:
+ return CSR_CS_THREAT_MALWARE;
+
+ case CSRE_CS_THREAT_RISKY:
+ return CSR_CS_THREAT_RISKY;
+
+ case CSRE_CS_THREAT_GENERIC:
+ return CSR_CS_THREAT_GENERIC;
+
+ default:
+ throw std::logic_error(FORMAT("Invalid ethreat: " << static_cast<int>(e)));
+ }
+}
+
+csr_wp_risk_level_e convert(const csre_wp_risk_level_e &e)
+{
+ switch (e) {
+ case CSRE_WP_RISK_LOW:
+ return CSR_WP_RISK_LOW;
+
+ case CSRE_WP_RISK_UNVERIFIED:
+ return CSR_WP_RISK_UNVERIFIED;
+
+ case CSRE_WP_RISK_MEDIUM:
+ return CSR_WP_RISK_MEDIUM;
+
+ case CSRE_WP_RISK_HIGH:
+ return CSR_WP_RISK_HIGH;
+
+ default:
+ throw std::logic_error(FORMAT("Invalid elevel: " << static_cast<int>(e)));
+ }
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file type-converter.h
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Converts types of engine interface to capi interface
+ */
+#pragma once
+
+#include "csre/content-screening-types.h"
+#include "csr/content-screening-types.h"
+#include "csre/web-protection-types.h"
+#include "csr/web-protection-types.h"
+
+namespace Csr {
+
+csr_cs_severity_level_e convert(const csre_cs_severity_level_e &);
+csr_cs_threat_type_e convert(const csre_cs_threat_type_e &);
+
+csr_wp_risk_level_e convert(const csre_wp_risk_level_e &);
+
+}