From 8b82e9ff6ccf8442b91c8f8ff1acbdf51985bdbe Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Thu, 19 Aug 2021 23:03:21 +0200 Subject: [PATCH] ADD: initial version + data classification --- CMakeLists.txt | 90 +++++++++++++++++++++++++ include/Whisper/Data/Classification.hpp | 59 ++++++++++++++++ src/Whisper/Data/Classification.cpp | 0 tests/test_classification.cpp | 46 +++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 include/Whisper/Data/Classification.hpp create mode 100644 src/Whisper/Data/Classification.cpp create mode 100644 tests/test_classification.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..69d925f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,90 @@ +cmake_minimum_required (VERSION 3.1 FATAL_ERROR) +project (whisper-com VERSION 0.0.1 LANGUAGES CXX C) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) +include(compdb) +include(doxygen) + +build_docs(PROCESS_DOXYFILE DOXYFILE_PATH "docs/Doxyfile.in" ) + +IF(NOT TARGET loguru) + find_package (Threads REQUIRED) + add_library(loguru STATIC libs/loguru/loguru.cpp libs/loguru/loguru.hpp) + target_include_directories(loguru PUBLIC libs/loguru/) + target_compile_options(loguru PUBLIC -DLOGURU_WITH_STREAMS=1) + target_link_libraries(loguru PUBLIC dl Threads::Threads) + set_property(TARGET loguru PROPERTY POSITION_INDEPENDENT_CODE 1) +ENDIF() + + +set(WHISPER_SOURCES + include/Whisper/Data/Classification.hpp + src/Whisper/Data/Classification.cpp +) + +set(WHISPER_REQUIRED_LIBRARIES loguru) + +add_library(objlib OBJECT ${WHISPER_SOURCES}) +set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) +target_include_directories(objlib + PUBLIC + include + PRIVATE + src +) +target_link_libraries(objlib PUBLIC ${WHISPER_REQUIRED_LIBRARIES}) + +add_library(whisper SHARED $) +target_include_directories(whisper + PUBLIC + include + PRIVATE + src +) +target_link_libraries(whisper PUBLIC ${WHISPER_REQUIRED_LIBRARIES}) + +add_library(whisper-static STATIC $) +target_include_directories(whisper-static + PUBLIC + include + PRIVATE + src +) +target_link_libraries(whisper-static PUBLIC ${WHISPER_REQUIRED_LIBRARIES}) + + +# +# Everything test related +# + + +option(WHISPER_TESTS "ENABLE/DISABLE all tests for whisper-com" ON) +IF(${WHISPER_TESTS}) + message(STATUS "whisper-com tests enabled") + IF(NOT TARGET Catch2) + add_subdirectory(libs/Catch2) + include(libs/Catch2/contrib/Catch.cmake) + ENDIF() + include(CTest) +ELSE() + message(STATUS "whisper-com tests disabled") +ENDIF() + + +IF(${WHISPER_TESTS}) +# +# all tests +# +add_executable(test_classification tests/test_classification.cpp) +target_link_libraries(test_classification PUBLIC Catch2::Catch2 whisper-static) +catch_discover_tests(test_classification) +# +# add_executable(test_message tests/test_message.cpp) +# target_link_libraries(test_message PUBLIC Catch2::Catch2 bc-ng loguru) +# target_compile_definitions(test_message PRIVATE -DNDEBUG=1 -DNLOGGING_VERBOSE=1) +# catch_discover_tests(test_message) + +ENDIF() diff --git a/include/Whisper/Data/Classification.hpp b/include/Whisper/Data/Classification.hpp new file mode 100644 index 0000000..bb275eb --- /dev/null +++ b/include/Whisper/Data/Classification.hpp @@ -0,0 +1,59 @@ +#pragma once +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at https://mozilla.org/MPL/2.0/. +*/ +/** @file */ +/** @copyright 2021 MPLv2 */ +#include +#include + +/** +* @brief This is the main namespace for all whisper-com related datatypes and classed. +*/ +namespace Whisper +{ + + /** + * @brief namespace for all data related DataTypes, classes, etc. + */ + namespace Data + { + + /** + * \defgroup data_classifications Classification of Data within Messages + * Data in Message can be classified occording to the non-disclosure of its information. + * In whisper-com certain rules are enforced occording to data classification + * e.g. messages may be dropped or not routed through gateways. + * Furthermore, encryption of data may or may not be enforced. + */ + + + /** + * @brief Enumeration of different data classifications. + * \ingroup data_classifications + * Data classifications classify the data within the payload of a message + * according to six levels. We think six levels should be enough and + * fewer limits the flexibility of the user and more adds to the overall + * complexity. + */ + enum class classification : std::uint8_t + { + /// The data is public and may even be transmitted public to the Internet. + PUBLIC, + /// The data is classified open. Everyone with access to the network may read it + /// but the data is not allowed to be published to the internet or other non local networks. + OPEN, + /// The data is classified RESTRICTED + RESTRICTED, + /// the data is classified CONFIDENTIAL + CONFIDENTIAL, + /// The data is classified as SECRET + SECRET, + /// The data is classified as TOP SECRET. + TOP_SECRET + }; // enum class classification + + }; // namespace Data + +}; // namespace Whisper diff --git a/src/Whisper/Data/Classification.cpp b/src/Whisper/Data/Classification.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_classification.cpp b/tests/test_classification.cpp new file mode 100644 index 0000000..5e7d19b --- /dev/null +++ b/tests/test_classification.cpp @@ -0,0 +1,46 @@ +/* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + +/** @file */ + +/** +* \defgroup compile_data_tests Test that Whisper::Data datatypes compile +* All test cases for verifying comilation of Whisper::Data datatypes and classes +*/ + + +#define CATCH_CONFIG_MAIN +#include +#include + +/** +* \brief Verify that data classification compile and can be used +* \ingroup compile_data_tests +*/ +SCENARIO("Use Classification of Data","[classification,data]") +{ + GIVEN("nothing") + { + + + WHEN("instantiating some classifications") + { + + Whisper::Data::classification c0 = Whisper::Data::classification::PUBLIC; + Whisper::Data::classification c1 = Whisper::Data::classification::OPEN; + Whisper::Data::classification c2 = Whisper::Data::classification::RESTRICTED; + Whisper::Data::classification c3 = Whisper::Data::classification::CONFIDENTIAL; + Whisper::Data::classification c4 = Whisper::Data::classification::SECRET; + Whisper::Data::classification c5 = Whisper::Data::classification::TOP_SECRET; + + THEN("then everything is fine") + { + } + } + + } + +}