From 8654687722963078c67f849f41d5a04f2f13143a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Jun 2022 09:14:13 +0200 Subject: [PATCH] [Backport 4.3-7.16] Ruleset test messages (#4257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ruleset test messages (#4244) * 2 proposals * cleaning * add changelog * suggested changes * fix(logtest): changed Array.prototype.reduce by Array.prototype.forEach to display the messages Co-authored-by: Álex Co-authored-by: Antonio David Gutiérrez (cherry picked from commit 92ed97d94692e1ecc576b1bdc2cd7bd4cea4f134) Co-authored-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ public/directives/wz-logtest/components/logtest.tsx | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e38b88370..99585e4109 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to the Wazuh app project will be documented in this file. ## Wazuh v4.3.5 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4306 +### Added + +- Added to the interface API messages in the Ruleset test module [#4244](https://github.com/wazuh/wazuh-kibana-app/pull/4244) + ### Fixed - Fixed type error when changing screen size in agents section [#4233](https://github.com/wazuh/wazuh-kibana-app/pull/4233) diff --git a/public/directives/wz-logtest/components/logtest.tsx b/public/directives/wz-logtest/components/logtest.tsx index 6e20a31f11..eb376f1bbb 100644 --- a/public/directives/wz-logtest/components/logtest.tsx +++ b/public/directives/wz-logtest/components/logtest.tsx @@ -71,7 +71,7 @@ export const Logtest = compose( }; // Format the result of the Wazuh API response to an output similar one to the `wazuh-logtest` utility - const formatResult = (result, alert) => { + const formatResult = (result, alert, messages) => { // How to the `wazuh-logtest` utility logs the output: // https://github.com/wazuh/wazuh/blob/master/framework/scripts/wazuh-logtest.py#L359-L397 @@ -100,6 +100,13 @@ export const Logtest = compose( }); } + // Output messages + if (messages) { + logging.push('**Messages:'); + messages.forEach(message => logging.push(`\t${message}`)); + logging.push(''); + } + // Pre-decoding phase logging.push('**Phase 1: Completed pre-decoding.'); // Check in case rule has no_full_log attribute @@ -171,7 +178,7 @@ export const Logtest = compose( } const testResults = responses.map((response) => { return response.data.data.output || '' - ? formatResult(response.data.data.output, response.data.data.alert) + ? formatResult(response.data.data.output, response.data.data.alert, response.data.data.messages) : `No result found for: ${response.data.data.output.full_log}`; }).join('\n\n'); setTestResult(testResults);