ADD: initial version + data classification

This commit is contained in:
Dominik Meyer 2021-08-19 23:03:21 +02:00
parent b3a6dd5906
commit 8b82e9ff6c
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
4 changed files with 195 additions and 0 deletions

90
CMakeLists.txt Normal file
View File

@ -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_OBJECTS:objlib>)
target_include_directories(whisper
PUBLIC
include
PRIVATE
src
)
target_link_libraries(whisper PUBLIC ${WHISPER_REQUIRED_LIBRARIES})
add_library(whisper-static STATIC $<TARGET_OBJECTS:objlib>)
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()

View File

@ -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 <cstdint>
#include <vector>
/**
* @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

View File

View File

@ -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<catch2/catch.hpp>
#include<Whisper/Data/Classification.hpp>
/**
* \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")
{
}
}
}
}