From dc6bc222371dd10b72f568105d59353bb0adf41e Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 24 Jul 2017 09:47:40 +0200 Subject: [PATCH] Masking Filter: removed extra constraints which cause some tests to fail Masking Filter: removed extra constraints which cause some tests to fail --- server/modules/filter/masking/maskingrules.cc | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/server/modules/filter/masking/maskingrules.cc b/server/modules/filter/masking/maskingrules.cc index d51bc3329..9db41b714 100644 --- a/server/modules/filter/masking/maskingrules.cc +++ b/server/modules/filter/masking/maskingrules.cc @@ -848,9 +848,9 @@ bool rule_get_value_fill(json_t* pRule, // Get value from 'with' object json_t* pTheValue = json_object_get(pWith, KEY_VALUE); - // Check values - if ((!pTheFill || !json_is_string(pTheFill)) || - (!pTheValue || !json_is_string(pTheValue))) + // Check Json strings + if ((pTheFill && !json_is_string(pTheFill)) || + (pTheValue && !json_is_string(pTheValue))) { MXS_ERROR("A masking '%s' rule has '%s' and/or '%s' " "invalid Json strings.", @@ -859,13 +859,18 @@ bool rule_get_value_fill(json_t* pRule, KEY_FILL); return false; } - else + + // Update the string values + if (pTheFill) { - // Update the string buffers pFill->assign(json_string_value(pTheFill)); - pValue->assign(json_string_value(pTheValue)); - return true; } + if (pTheValue) + { + pValue->assign(json_string_value(pTheValue)); + } + + return true; } //static @@ -889,26 +894,14 @@ auto_ptr MaskingRules::ReplaceRule::create_from(json_t* pRul KEY_REPLACE) && rule_get_value_fill(pRule, &value, &fill)) // get value/fill { - if (!value.empty() && !fill.empty()) - { - // Apply value/fill: instantiate the ReplaceRule class - sRule = auto_ptr(new MaskingRules::ReplaceRule(column, - table, - database, - applies_to, - exempted, - value, - fill)); - } - else - { - MXS_ERROR("Key '%s' or '%s' of masking '%s' rule object '%s' " - "has a non-string value or empty value.", - KEY_VALUE, - KEY_FILL, - KEY_REPLACE, - KEY_WITH); - } + // Apply value/fill: instantiate the ReplaceRule class + sRule = auto_ptr(new MaskingRules::ReplaceRule(column, + table, + database, + applies_to, + exempted, + value, + fill)); } return sRule;