diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt index bd8b7a1b9..1b969beac 100644 --- a/server/modules/filter/CMakeLists.txt +++ b/server/modules/filter/CMakeLists.txt @@ -13,3 +13,4 @@ add_subdirectory(tee) add_subdirectory(testfilter) add_subdirectory(topfilter) add_subdirectory(tpmfilter) +add_subdirectory(masking) diff --git a/server/modules/filter/masking/CMakeLists.txt b/server/modules/filter/masking/CMakeLists.txt new file mode 100644 index 000000000..221407789 --- /dev/null +++ b/server/modules/filter/masking/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(masking SHARED + maskingfilter.cc + maskingfiltersession.cc + ) + +target_link_libraries(masking maxscale-common) +set_target_properties(masking PROPERTIES VERSION "1.0.0") +set_target_properties(masking PROPERTIES LINK_FLAGS -Wl,-z,defs) +install_module(masking experimental) diff --git a/server/modules/filter/masking/maskingfilter.cc b/server/modules/filter/masking/maskingfilter.cc new file mode 100644 index 000000000..b1311d6de --- /dev/null +++ b/server/modules/filter/masking/maskingfilter.cc @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#define MXS_MODULE_NAME "masking" +#include "maskingfilter.hh" + +namespace +{ + +char VERSION_STRING[] = "V1.0.0"; + +} + +// +// Global symbols of the Module +// + +MODULE_INFO info = +{ + MODULE_API_FILTER, + MODULE_IN_DEVELOPMENT, + FILTER_VERSION, + "A masking filter that is capable of masking/obfuscating returned column values." +}; + +extern "C" char *version() +{ + return VERSION_STRING; +} + +extern "C" void ModuleInit() +{ + MXS_NOTICE("Initialized masking module %s.\n", VERSION_STRING); +} + +extern "C" FILTER_OBJECT *GetModuleObject() +{ + return &MaskingFilter::s_object; +}; + +// +// MaskingFilter +// + +MaskingFilter::MaskingFilter() +{ +} + +MaskingFilter::~MaskingFilter() +{ +} + +// static +MaskingFilter* MaskingFilter::create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams) +{ + MaskingFilter* pFilter = new MaskingFilter; + + if (!process_params(pzOptions, ppParams, pFilter->m_config)) + { + delete pFilter; + pFilter = NULL; + } + + return pFilter; +} + + +MaskingFilterSession* MaskingFilter::newSession(SESSION* pSession) +{ + return MaskingFilterSession::create(pSession); +} + +// static +void MaskingFilter::diagnostics(DCB* pDcb) +{ + dcb_printf(pDcb, "Hello, World!\n"); +} + +// static +uint64_t MaskingFilter::getCapabilities() +{ + return 0; +} + +// static +bool MaskingFilter::process_params(char **pzOptions, FILTER_PARAMETER **ppParams, Config& config) +{ + return true; +} diff --git a/server/modules/filter/masking/maskingfilter.hh b/server/modules/filter/masking/maskingfilter.hh new file mode 100644 index 000000000..d23ce544f --- /dev/null +++ b/server/modules/filter/masking/maskingfilter.hh @@ -0,0 +1,45 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include +#include "maskingfilterconfig.hh" +#include "maskingfiltersession.hh" + + +class MaskingFilter : public maxscale::Filter +{ +public: + typedef MaskingFilterConfig Config; + + ~MaskingFilter(); + static MaskingFilter* create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams); + + MaskingFilterSession* newSession(SESSION* pSession); + + void diagnostics(DCB* pDcb); + + static uint64_t getCapabilities(); + +private: + MaskingFilter(); + + MaskingFilter(const MaskingFilter&); + MaskingFilter& operator = (const MaskingFilter&); + + static bool process_params(char **pzOptions, FILTER_PARAMETER **ppParams, Config& config); + +private: + Config m_config; +}; diff --git a/server/modules/filter/masking/maskingfilterconfig.hh b/server/modules/filter/masking/maskingfilterconfig.hh new file mode 100644 index 000000000..db58c6cb0 --- /dev/null +++ b/server/modules/filter/masking/maskingfilterconfig.hh @@ -0,0 +1,20 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include + +class MaskingFilterConfig +{ + // Placeholder +}; diff --git a/server/modules/filter/masking/maskingfiltersession.cc b/server/modules/filter/masking/maskingfiltersession.cc new file mode 100644 index 000000000..e172971d5 --- /dev/null +++ b/server/modules/filter/masking/maskingfiltersession.cc @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include "maskingfiltersession.hh" +#include + + +MaskingFilterSession::MaskingFilterSession(SESSION* pSession) + : maxscale::FilterSession(pSession) +{ +} + +MaskingFilterSession::~MaskingFilterSession() +{ +} + +//static +MaskingFilterSession* MaskingFilterSession::create(SESSION* pSession) +{ + return new MaskingFilterSession(pSession); +} diff --git a/server/modules/filter/masking/maskingfiltersession.hh b/server/modules/filter/masking/maskingfiltersession.hh new file mode 100644 index 000000000..11e8dfc2d --- /dev/null +++ b/server/modules/filter/masking/maskingfiltersession.hh @@ -0,0 +1,30 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include + +class MaskingFilterSession : public maxscale::FilterSession +{ +public: + ~MaskingFilterSession(); + + static MaskingFilterSession* create(SESSION* pSession); + +private: + MaskingFilterSession(SESSION* pSession); + + MaskingFilterSession(const MaskingFilterSession&); + MaskingFilterSession& operator = (const MaskingFilterSession&); +};