Add skeleton masking filter
This commit is contained in:
@ -13,3 +13,4 @@ add_subdirectory(tee)
|
||||
add_subdirectory(testfilter)
|
||||
add_subdirectory(topfilter)
|
||||
add_subdirectory(tpmfilter)
|
||||
add_subdirectory(masking)
|
||||
|
||||
9
server/modules/filter/masking/CMakeLists.txt
Normal file
9
server/modules/filter/masking/CMakeLists.txt
Normal file
@ -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)
|
||||
99
server/modules/filter/masking/maskingfilter.cc
Normal file
99
server/modules/filter/masking/maskingfilter.cc
Normal file
@ -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;
|
||||
}
|
||||
45
server/modules/filter/masking/maskingfilter.hh
Normal file
45
server/modules/filter/masking/maskingfilter.hh
Normal file
@ -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 <maxscale/cppdefs.hh>
|
||||
#include <maxscale/filter.hh>
|
||||
#include "maskingfilterconfig.hh"
|
||||
#include "maskingfiltersession.hh"
|
||||
|
||||
|
||||
class MaskingFilter : public maxscale::Filter<MaskingFilter, MaskingFilterSession>
|
||||
{
|
||||
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;
|
||||
};
|
||||
20
server/modules/filter/masking/maskingfilterconfig.hh
Normal file
20
server/modules/filter/masking/maskingfilterconfig.hh
Normal file
@ -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 <maxscale/cppdefs.hh>
|
||||
|
||||
class MaskingFilterConfig
|
||||
{
|
||||
// Placeholder
|
||||
};
|
||||
31
server/modules/filter/masking/maskingfiltersession.cc
Normal file
31
server/modules/filter/masking/maskingfiltersession.cc
Normal file
@ -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 <maxscale/filter.hh>
|
||||
|
||||
|
||||
MaskingFilterSession::MaskingFilterSession(SESSION* pSession)
|
||||
: maxscale::FilterSession(pSession)
|
||||
{
|
||||
}
|
||||
|
||||
MaskingFilterSession::~MaskingFilterSession()
|
||||
{
|
||||
}
|
||||
|
||||
//static
|
||||
MaskingFilterSession* MaskingFilterSession::create(SESSION* pSession)
|
||||
{
|
||||
return new MaskingFilterSession(pSession);
|
||||
}
|
||||
30
server/modules/filter/masking/maskingfiltersession.hh
Normal file
30
server/modules/filter/masking/maskingfiltersession.hh
Normal file
@ -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 <maxscale/cppdefs.hh>
|
||||
#include <maxscale/filter.hh>
|
||||
|
||||
class MaskingFilterSession : public maxscale::FilterSession
|
||||
{
|
||||
public:
|
||||
~MaskingFilterSession();
|
||||
|
||||
static MaskingFilterSession* create(SESSION* pSession);
|
||||
|
||||
private:
|
||||
MaskingFilterSession(SESSION* pSession);
|
||||
|
||||
MaskingFilterSession(const MaskingFilterSession&);
|
||||
MaskingFilterSession& operator = (const MaskingFilterSession&);
|
||||
};
|
||||
Reference in New Issue
Block a user