From: Sangwan Kwon Date: Thu, 24 Oct 2019 05:55:21 +0000 (+0900) Subject: Detach osquery dependency from client X-Git-Tag: submit/tizen/20200810.073515~174 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4485a3e05fb02be676747f070c3c8bda13dbbfa7;p=platform%2Fcore%2Fsecurity%2Fvist.git Detach osquery dependency from client Make logger as common Signed-off-by: Sangwan Kwon --- diff --git a/src/policyd/core/CMakeLists.txt b/src/policyd/core/CMakeLists.txt index 498ea52..4f73300 100644 --- a/src/policyd/core/CMakeLists.txt +++ b/src/policyd/core/CMakeLists.txt @@ -16,8 +16,7 @@ ADD_POLICYD_LIBRARY(policyd_core api.cpp policy-manager.cpp policy-loader.cpp - policy-storage.cpp - logger.cpp) + policy-storage.cpp) FILE(GLOB SDK_TESTS "tests/*.cpp") ADD_POLICYD_TEST(${SDK_TESTS}) diff --git a/src/policyd/core/logger.cpp b/src/policyd/core/logger.cpp deleted file mode 100644 index 927d83c..0000000 --- a/src/policyd/core/logger.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017 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 - */ - -#include "logger.h" - -#include - -namespace policyd { - -std::unique_ptr Logger::logSink = nullptr; -std::once_flag Logger::flag; - -audit::LogSink* Logger::GetLogSink(const std::string& tag) -{ - std::call_once(flag, [&]() { - auto dlogSink = new audit::DlogLogSink(tag); - logSink.reset(dynamic_cast(dlogSink)); - }); - - return logSink.get(); -} - -} // namespace policyd diff --git a/src/policyd/core/logger.h b/src/policyd/core/logger.h deleted file mode 100644 index 2589467..0000000 --- a/src/policyd/core/logger.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2017 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 - */ - -#pragma once - -#include - -#include -#include - -#define VIST Logger::GetLogSink("VIST") - -namespace policyd { - -class Logger { -public: - static audit::LogSink* GetLogSink(const std::string& tag); - -private: - static std::unique_ptr logSink; - static std::once_flag flag; -}; - -} // namespace policyd diff --git a/src/policyd/core/policy-manager.cpp b/src/policyd/core/policy-manager.cpp index 1b2b035..c08771e 100644 --- a/src/policyd/core/policy-manager.cpp +++ b/src/policyd/core/policy-manager.cpp @@ -16,7 +16,8 @@ #include "policy-manager.h" #include "policy-loader.h" -#include "logger.h" + +#include #include diff --git a/src/policyd/core/policy-storage.cpp b/src/policyd/core/policy-storage.cpp index 0029bf3..31cdc7f 100644 --- a/src/policyd/core/policy-storage.cpp +++ b/src/policyd/core/policy-storage.cpp @@ -15,7 +15,8 @@ */ #include "policy-storage.h" -#include "logger.h" + +#include #include #include diff --git a/src/vist/client/query.cpp b/src/vist/client/query.cpp index 2a012ce..81124a1 100644 --- a/src/vist/client/query.cpp +++ b/src/vist/client/query.cpp @@ -16,7 +16,8 @@ #include "query.h" -#include "ipc/client.h" +#include +#include namespace { const std::string SOCK_ADDR = "/tmp/.vist"; @@ -26,6 +27,7 @@ namespace vist { Rows Query::Execute(const std::string& statement) { + INFO(VIST_CLIENT, "Query execution: " << statement); auto& client = ipc::Client::Instance(SOCK_ADDR); return client->methodCall("Vist::query", statement); diff --git a/src/vist/client/tests/virtual_table_tests.cpp b/src/vist/client/tests/virtual_table_tests.cpp index b30a4e5..c3aaaec 100644 --- a/src/vist/client/tests/virtual_table_tests.cpp +++ b/src/vist/client/tests/virtual_table_tests.cpp @@ -16,15 +16,14 @@ #include -#include - #include "../virtual-table.h" #include "../schema/time.h" #include "../schema/policy.h" #include "../schema/processes.h" -using namespace osquery; +#include + using namespace vist; using namespace vist::schema; @@ -39,16 +38,16 @@ TEST_F(VirtualTableTests, time_row_at) { result.seconds = time.at(&Time::seconds); /// Once query execution - LOG(INFO) << "[Test] time table:"; - LOG(INFO) << "\t hour: " << result.hour; - LOG(INFO) << "\t minutes: " << result.minutes; - LOG(INFO) << "\t seconds: " << result.seconds; + INFO(VIST_CLIENT, "[Test] time table:"); + INFO(VIST_CLIENT, "\t hour: " << result.hour); + INFO(VIST_CLIENT, "\t minutes: " << result.minutes); + INFO(VIST_CLIENT, "\t seconds: " << result.seconds); /// Each query execution - LOG(INFO) << "[Test] time table:"; - LOG(INFO) << "\t hour: " << VirtualRow