diff --git a/server/modules/filter/masking/maskingrules.cc b/server/modules/filter/masking/maskingrules.cc index fac2ff6d3..ad868fef6 100644 --- a/server/modules/filter/masking/maskingrules.cc +++ b/server/modules/filter/masking/maskingrules.cc @@ -468,6 +468,19 @@ MaskingRules::ObfuscateRule::ObfuscateRule(const std::string& column, { } +MaskingRules::CaptureRule::CaptureRule(const std::string& column, + const std::string& table, + const std::string& database, + const std::vector& applies_to, + const std::vector& exempted, + const std::string& regexp, + const std::string& fill) + : MaskingRules::Rule::Rule(column, table, database, applies_to, exempted) + , m_regexp(regexp) + , m_fill(fill) +{ +} + MaskingRules::Rule::~Rule() { } @@ -480,6 +493,10 @@ MaskingRules::ObfuscateRule::~ObfuscateRule() { } +MaskingRules::CaptureRule::~CaptureRule() +{ +} + /** Check the Json array for user rules * * @param pApplies_to The array of users the rule is applied to @@ -817,6 +834,10 @@ static inline char maxscale_basic_obfuscation(const char c) return c; } +void MaskingRules::CaptureRule::rewrite(LEncString& s) const +{ +} + void MaskingRules::ObfuscateRule::rewrite(LEncString& s) const { // Basic Obfuscation routine diff --git a/server/modules/filter/masking/maskingrules.hh b/server/modules/filter/masking/maskingrules.hh index f499f1e56..e27386f05 100644 --- a/server/modules/filter/masking/maskingrules.hh +++ b/server/modules/filter/masking/maskingrules.hh @@ -243,6 +243,68 @@ public: ObfuscateRule& operator = (const ObfuscateRule&); }; + class CaptureRule : public Rule + { + public: + /** + * Constructor of CaptureRule + * + * @param column The column value from the json file. + * @param table The table value from the json file. + * @param database The database value from the json file. + * @param applies_to Account instances corresponding to the + * accounts listed in 'applies_to' in the json file. + * @param exempted Account instances corresponding to the + * accounts listed in 'exempted' in the json file. + * @param regexp The capture regexp from the json file. + * @param fill The fill value from the json file. + */ + CaptureRule(const std::string& column, + const std::string& table, + const std::string& database, + const std::vector& applies_to, + const std::vector& exempted, + const std::string& regexp, + const std::string& fill); + + ~CaptureRule(); + + const std::string& capture() const + { + return m_regexp; + } + + const std::string& fill() const + { + return m_fill; + } + + /** + * Create a CaptureRule instance + * + * @param pRule A json object corresponding to a single + * rule in the rules json file. + * + * @return A Rule instance or NULL. + */ + static std::auto_ptr create_from(json_t* pRule); + + /** + * Rewrite the column value based on rules + * + * @param s The column value to rewrite. + */ + void rewrite(LEncString& s) const; + + private: + std::string m_regexp; + std::string m_fill; + + private: + CaptureRule(const CaptureRule&); + CaptureRule& operator = (const CaptureRule&); + }; + ~MaskingRules(); /**