Skip to content

Commit

Permalink
Ruleset test messages (#4244)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jun 14, 2022
1 parent 431c204 commit 92ed97d
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 - 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 a UI crash due to a query with syntax errors in `Modules/Security events` [#4237](https://github.com/wazuh/wazuh-kibana-app/pull/4237)
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 92ed97d

Please sign in to comment.