Skip to content

Commit

Permalink
[Backport 4.3-1.2-wzd] Ruleset test messages (#4258)
Browse files Browse the repository at this point in the history
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 <alejandro.ruiz.becerra@wazuh.com>
Co-authored-by: Antonio David Gutiérrez <antonio.gutierrez@wazuh.com>
(cherry picked from commit 92ed97d)

Co-authored-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and yenienserrano authored Jun 14, 2022
1 parent bb4dec7 commit a44eae1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the Wazuh app project will be documented in this file.

## Wazuh v4.3.5 - OpenSearch Dashboards 1.2.0 - 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)
Expand Down
11 changes: 9 additions & 2 deletions public/directives/wz-logtest/components/logtest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a44eae1

Please sign in to comment.