diff --git a/src/actions/transformations/replace_nulls.cc b/src/actions/transformations/replace_nulls.cc index 3b158ca2..c3daca50 100644 --- a/src/actions/transformations/replace_nulls.cc +++ b/src/actions/transformations/replace_nulls.cc @@ -37,14 +37,18 @@ ReplaceNulls::ReplaceNulls(std::string action) std::string ReplaceNulls::evaluate(std::string value, Assay *assay) { - /** - * @todo Implement the transformation ReplaceNulls - */ - if (assay) { -#ifndef NO_LOGS - assay->debug(4, "Transformation ReplaceNulls is not implemented yet."); -#endif + int64_t i; + + i = 0; + while (i < value.size()) { + if (value.at(i) == '\0') { + value.erase(i, 1); + value.insert(i, " ", 1); + } else { + i++; + } } + return value; } diff --git a/src/actions/transformations/transformation.cc b/src/actions/transformations/transformation.cc index e1e3b866..aac22520 100644 --- a/src/actions/transformations/transformation.cc +++ b/src/actions/transformations/transformation.cc @@ -99,7 +99,7 @@ Transformation* Transformation::instantiate(std::string a) { IF_MATCH(remove_whitespace) { return new RemoveWhitespace(a); } IF_MATCH(compressWhitespace) { return new CompressWhitespace(a); } IF_MATCH(replaceComments) { return new ReplaceComments(a); } - IF_MATCH(replace_nulls) { return new ReplaceNulls(a); } + IF_MATCH(replaceNulls) { return new ReplaceNulls(a); } IF_MATCH(sha1) { return new Sha1(a); } IF_MATCH(sql_hex_decode) { return new SqlHexDecode(a); } IF_MATCH(transformation) { return new Transformation(a); } diff --git a/test/test-cases/secrules-language-tests b/test/test-cases/secrules-language-tests index 635d86d6..e363aa64 160000 --- a/test/test-cases/secrules-language-tests +++ b/test/test-cases/secrules-language-tests @@ -1 +1 @@ -Subproject commit 635d86d6f87d56de656da73e3026a6ef2cc9a5f1 +Subproject commit e363aa647abebe1be523f9bdd5ba4466ba20256e