Add skeleton masking filter

This commit is contained in:
Johan Wikman
2016-12-22 19:00:59 +02:00
parent 65ca6a4be8
commit c186956e0e
7 changed files with 235 additions and 0 deletions

View File

@ -13,3 +13,4 @@ add_subdirectory(tee)
add_subdirectory(testfilter)
add_subdirectory(topfilter)
add_subdirectory(tpmfilter)
add_subdirectory(masking)

View 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)

View 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;
}

View 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;
};

View 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
};

View 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);
}

View 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&);
};