From: Sangwan Kwon Date: Thu, 7 Nov 2019 05:16:12 +0000 (+0900) Subject: Rename file extension from .h to .hpp X-Git-Tag: submit/tizen/20200810.073515~166 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0367e11eabfd3d8163311ead0e1481e443b51c31;p=platform%2Fcore%2Fsecurity%2Fvist.git Rename file extension from .h to .hpp Signed-off-by: Sangwan Kwon --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..166e74e --- /dev/null +++ b/AUTHORS @@ -0,0 +1,13 @@ +# This is the official list of ViST authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. +# +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. +# +# Please keep the list sorted. + +Jaemin Ryu +Samsung Electronics Co. +Sangwan Kwon diff --git a/plugins/bluetooth/bluetooth.cpp b/plugins/bluetooth/bluetooth.cpp index eafbc65..0caa39e 100644 --- a/plugins/bluetooth/bluetooth.cpp +++ b/plugins/bluetooth/bluetooth.cpp @@ -18,8 +18,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/plugins/wifi/wifi.cpp b/plugins/wifi/wifi.cpp index b8d8aa5..95ca32e 100644 --- a/plugins/wifi/wifi.cpp +++ b/plugins/wifi/wifi.cpp @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/src/osquery/tables/tizen/policy.cpp b/src/osquery/tables/tizen/policy.cpp index 5301071..313ac14 100644 --- a/src/osquery/tables/tizen/policy.cpp +++ b/src/osquery/tables/tizen/policy.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include namespace osquery { namespace tables { diff --git a/src/osquery/tables/tizen/policy_admin.cpp b/src/osquery/tables/tizen/policy_admin.cpp index a831701..00d7a35 100644 --- a/src/osquery/tables/tizen/policy_admin.cpp +++ b/src/osquery/tables/tizen/policy_admin.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include namespace { diff --git a/src/osquery/tables/tizen/tests/policy.cpp b/src/osquery/tables/tizen/tests/policy.cpp new file mode 100644 index 0000000..983b693 --- /dev/null +++ b/src/osquery/tables/tizen/tests/policy.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 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 + +#include + +using namespace vist; + +class PolicyTests : public testing::Test {}; + +TEST_F(PolicyTests, get_all) { + auto policies = policy::API::GetAll(); + + EXPECT_TRUE(policies.size() > 0); +} + +TEST_F(PolicyTests, get_admin_all) { + auto admins = policy::API::Admin::GetAll(); + EXPECT_EQ(admins.size(), 0); + + policy::API::Admin::Enroll("testAdmin"); + admins = policy::API::Admin::GetAll(); + EXPECT_EQ(admins.size(), 1); + + policy::API::Admin::Enroll("testAdmin1"); + admins = policy::API::Admin::GetAll(); + EXPECT_EQ(admins.size(), 2); + + policy::API::Admin::Disenroll("testAdmin"); + admins = policy::API::Admin::GetAll(); + EXPECT_EQ(admins.size(), 1); + + policy::API::Admin::Disenroll("testAdmin1"); + admins = policy::API::Admin::GetAll(); + EXPECT_EQ(admins.size(), 0); +} diff --git a/src/osquery/tables/tizen/tests/policy_tests.cpp b/src/osquery/tables/tizen/tests/policy_tests.cpp deleted file mode 100644 index e7cb5b2..0000000 --- a/src/osquery/tables/tizen/tests/policy_tests.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2019 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 - -#include - -using namespace vist; - -class PolicyTests : public testing::Test {}; - -TEST_F(PolicyTests, get_all) { - auto policies = policy::API::GetAll(); - - EXPECT_TRUE(policies.size() > 0); -} - -TEST_F(PolicyTests, get_admin_all) { - auto admins = policy::API::Admin::GetAll(); - EXPECT_EQ(admins.size(), 0); - - policy::API::Admin::Enroll("testAdmin"); - admins = policy::API::Admin::GetAll(); - EXPECT_EQ(admins.size(), 1); - - policy::API::Admin::Enroll("testAdmin1"); - admins = policy::API::Admin::GetAll(); - EXPECT_EQ(admins.size(), 2); - - policy::API::Admin::Disenroll("testAdmin"); - admins = policy::API::Admin::GetAll(); - EXPECT_EQ(admins.size(), 1); - - policy::API::Admin::Disenroll("testAdmin1"); - admins = policy::API::Admin::GetAll(); - EXPECT_EQ(admins.size(), 0); -} diff --git a/src/vist/CMakeLists.txt b/src/vist/CMakeLists.txt index 73f9be1..4d7cf18 100644 --- a/src/vist/CMakeLists.txt +++ b/src/vist/CMakeLists.txt @@ -29,7 +29,6 @@ ADD_DEFINITIONS(-DDB_PATH="${DB_INSTALL_DIR}/.vist.db" -DSCRIPT_INSTALL_DIR="${SCRIPT_INSTALL_DIR}") ADD_SUBDIRECTORY(client) -ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(notification) ADD_SUBDIRECTORY(policy) ADD_SUBDIRECTORY(service) @@ -54,6 +53,9 @@ INSTALL(TARGETS ${TARGET_VIST_DAEMON} WORLD_READ WORLD_EXECUTE) +FILE(GLOB COMMON_TESTS "tests/*.cpp") +ADD_VIST_TEST(${COMMON_TESTS}) + ADD_EXECUTABLE(${TARGET_VIST_TEST} main/tests.cpp ${${TARGET_VIST_LIB}_TESTS}) TARGET_LINK_LIBRARIES(${TARGET_VIST_TEST} ${TARGET_VIST_LIB} diff --git a/src/vist/client/query.cpp b/src/vist/client/query.cpp index 81124a1..29fb8fd 100644 --- a/src/vist/client/query.cpp +++ b/src/vist/client/query.cpp @@ -14,10 +14,10 @@ * limitations under the License */ -#include "query.h" +#include "query.hpp" -#include -#include +#include +#include namespace { const std::string SOCK_ADDR = "/tmp/.vist"; diff --git a/src/vist/client/query.h b/src/vist/client/query.h deleted file mode 100644 index ccce173..0000000 --- a/src/vist/client/query.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 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 - -namespace vist { - -using Row = std::map; -using Rows = std::vector; - -struct Query final { - static Rows Execute(const std::string& statement); -}; - -} // namespace vist diff --git a/src/vist/client/query.hpp b/src/vist/client/query.hpp new file mode 100644 index 0000000..ccce173 --- /dev/null +++ b/src/vist/client/query.hpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 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 + +namespace vist { + +using Row = std::map; +using Rows = std::vector; + +struct Query final { + static Rows Execute(const std::string& statement); +}; + +} // namespace vist diff --git a/src/vist/client/schema/policy.h b/src/vist/client/schema/policy.h deleted file mode 100644 index 17d4a3e..0000000 --- a/src/vist/client/schema/policy.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2019 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 processes.h - * @brief The scheme of policy - */ - - -#pragma once - -#include - -namespace vist { -namespace schema { - -struct Policy { - std::string name; - std::string value; -}; - -} // namesapce schema -} // namesapce vist diff --git a/src/vist/client/schema/policy.hpp b/src/vist/client/schema/policy.hpp new file mode 100644 index 0000000..2d33fc4 --- /dev/null +++ b/src/vist/client/schema/policy.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 + +namespace vist { +namespace schema { + +struct Policy { + std::string name; + std::string value; +}; + +} // namesapce schema +} // namesapce vist diff --git a/src/vist/client/schema/processes.h b/src/vist/client/schema/processes.h deleted file mode 100644 index 9e9325c..0000000 --- a/src/vist/client/schema/processes.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019 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 processes.h - * @brief The scheme of processes (sync with osquery/tables/spec/x/processes.table) - */ - - -#pragma once - -#include - -namespace vist { -namespace schema { - -struct Processes { - long long int pid; - std::string name; - std::string path; - std::string cmdline; - long long int uid; - long long int gid; - long long int euid; - long long int egid; - int on_disk; - long long int resident_size; - long long int parent; -}; - -} // namesapce schema -} // namesapce vist diff --git a/src/vist/client/schema/processes.hpp b/src/vist/client/schema/processes.hpp new file mode 100644 index 0000000..764cd2d --- /dev/null +++ b/src/vist/client/schema/processes.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 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 + +namespace vist { +namespace schema { + +struct Processes { + long long int pid; + std::string name; + std::string path; + std::string cmdline; + long long int uid; + long long int gid; + long long int euid; + long long int egid; + int on_disk; + long long int resident_size; + long long int parent; +}; + +} // namesapce schema +} // namesapce vist diff --git a/src/vist/client/schema/time.h b/src/vist/client/schema/time.h deleted file mode 100644 index 02258df..0000000 --- a/src/vist/client/schema/time.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019 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 time.h - * @brief The scheme of time (sync with osquery/tables/spec/time.table) - */ - - -#pragma once - -namespace vist { -namespace schema { - -struct Time { - int hour; - int minutes; - int seconds; -}; - -} // namesapce schema -} // namesapce vist diff --git a/src/vist/client/schema/time.hpp b/src/vist/client/schema/time.hpp new file mode 100644 index 0000000..18a655d --- /dev/null +++ b/src/vist/client/schema/time.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 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 + +namespace vist { +namespace schema { + +struct Time { + int hour; + int minutes; + int seconds; +}; + +} // namesapce schema +} // namesapce vist diff --git a/src/vist/client/tests/client-tests.cpp b/src/vist/client/tests/client-tests.cpp deleted file mode 100644 index f7bc148..0000000 --- a/src/vist/client/tests/client-tests.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019 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 - -#include "../query.h" - -#include -#include - -using namespace vist; - -class ClientTests : public testing::Test {}; - -TEST_F(ClientTests, query) { - auto rows = Query::Execute("SELECT * FROM policy"); - - EXPECT_TRUE(rows.size() > 0); -} - -TEST_F(ClientTests, admin_enrollment) { - auto rows = Query::Execute("INSERT INTO policy_admin (name) VALUES ('testAdmin')"); - EXPECT_EQ(rows.size(), 0); - - rows = Query::Execute("SELECT * FROM policy_admin"); - EXPECT_EQ(rows.size(), 1); - - Query::Execute("INSERT INTO policy_admin (name) VALUES ('testAdmin2')"); - rows = Query::Execute("SELECT * FROM policy_admin"); - EXPECT_EQ(rows.size(), 2); - - rows = Query::Execute("DELETE FROM policy_admin WHERE name = 'testAdmin'"); - EXPECT_EQ(rows.size(), 0); - - rows = Query::Execute("SELECT * FROM policy_admin"); - EXPECT_EQ(rows.size(), 1); - - Query::Execute("DELETE FROM policy_admin WHERE name = 'testAdmin2'"); - rows = Query::Execute("SELECT * FROM policy_admin"); - EXPECT_EQ(rows.size(), 0); -} diff --git a/src/vist/client/tests/client.cpp b/src/vist/client/tests/client.cpp new file mode 100644 index 0000000..e45c60b --- /dev/null +++ b/src/vist/client/tests/client.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 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 + +#include + +#include +#include + +using namespace vist; + +class ClientTests : public testing::Test {}; + +TEST(ClientTests, query) { + auto rows = Query::Execute("SELECT * FROM policy"); + + EXPECT_TRUE(rows.size() > 0); +} + +TEST(ClientTests, admin_enrollment) { + auto rows = Query::Execute("INSERT INTO policy_admin (name) VALUES ('testAdmin')"); + EXPECT_EQ(rows.size(), 0); + + rows = Query::Execute("SELECT * FROM policy_admin"); + EXPECT_EQ(rows.size(), 1); + + Query::Execute("INSERT INTO policy_admin (name) VALUES ('testAdmin2')"); + rows = Query::Execute("SELECT * FROM policy_admin"); + EXPECT_EQ(rows.size(), 2); + + rows = Query::Execute("DELETE FROM policy_admin WHERE name = 'testAdmin'"); + EXPECT_EQ(rows.size(), 0); + + rows = Query::Execute("SELECT * FROM policy_admin"); + EXPECT_EQ(rows.size(), 1); + + Query::Execute("DELETE FROM policy_admin WHERE name = 'testAdmin2'"); + rows = Query::Execute("SELECT * FROM policy_admin"); + EXPECT_EQ(rows.size(), 0); +} diff --git a/src/vist/client/tests/virtual-table-tests.cpp b/src/vist/client/tests/virtual-table-tests.cpp deleted file mode 100644 index c3aaaec..0000000 --- a/src/vist/client/tests/virtual-table-tests.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2019 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 - -#include "../virtual-table.h" - -#include "../schema/time.h" -#include "../schema/policy.h" -#include "../schema/processes.h" - -#include - -using namespace vist; -using namespace vist::schema; - -class VirtualTableTests : public testing::Test {}; - -TEST_F(VirtualTableTests, time_row_at) { - Time result = { -1, -1, -1 }; - - VirtualRow