Skip to content

Commit

Permalink
[BUG] Plugin crash when searching with a query with syntax errors in …
Browse files Browse the repository at this point in the history
…Modules/Security events (#4237)

* fix: fixed plugin UI crash when there is an error related to wrong query syntax in Modules/Security events

Replaced the error level from `CRITICAL` to `BUSINESS`. With this
change, a toast will be displayed with the error.

Removed the storing of the error in the plugin logs related to UI.

Removed unused variable

* changelog: Add PR entry

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
  • Loading branch information
Desvelao and AlexRuiz7 committed Jun 17, 2022
1 parent 6b5f321 commit 2a18f61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Fixed type error when changing screen size in agents section [#4233](https://github.com/wazuh/wazuh-kibana-app/pull/4233)
- Removed a logged error that appeared when the `statistics` tasks tried to create an index with the same name, causing the second task to fail on the creation of the index because it already exists [#4235](https://github.com/wazuh/wazuh-kibana-app/pull/4235)
- 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)
- Fixed an error when generating a module report after changing the selected agent [#4240](https://github.com/wazuh/wazuh-kibana-app/pull/4240)

## Wazuh v4.3.4 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4305
Expand Down
13 changes: 4 additions & 9 deletions public/components/common/modules/discover/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const Discover = compose(
sortField: string;
sortDirection: Direction;
isLoading: boolean;
requestFilters: object;
requestSize: number;
requestOffset: number;
query: { language: 'kuery' | 'lucene'; query: string };
Expand Down Expand Up @@ -127,7 +126,6 @@ export const Discover = compose(
sortField: 'timestamp',
sortDirection: 'desc',
isLoading: false,
requestFilters: {},
requestSize: 500,
requestOffset: 0,
itemIdToExpandedRowMap: {},
Expand Down Expand Up @@ -171,8 +169,7 @@ export const Discover = compose(
const options = {
context: `${Discover.name}.componentDidMount`,
level: UI_LOGGER_LEVELS.ERROR,
severity: UI_ERROR_SEVERITIES.CRITICAL,
store: true,
severity: UI_ERROR_SEVERITIES.BUSINESS,
error: {
error: error,
message: error.message || error,
Expand Down Expand Up @@ -231,8 +228,7 @@ export const Discover = compose(
const options = {
context: `${Discover.name}.componentDidUpdate`,
level: UI_LOGGER_LEVELS.ERROR,
severity: UI_ERROR_SEVERITIES.CRITICAL,
store: true,
severity: UI_ERROR_SEVERITIES.BUSINESS,
error: {
error: error,
message: error.message || error,
Expand Down Expand Up @@ -421,9 +417,9 @@ export const Discover = compose(
async getAlerts() {
if (!this.indexPattern || this.state.isLoading) return;
//compare filters so we only make a request into Elasticsearch if needed
const newFilters = this.buildFilter();
try {
this.setState({ isLoading: true });
const newFilters = this.buildFilter();
const alerts = await GenericRequest.request('POST', `/elastic/alerts`, {
index: this.indexPattern.title,
body: newFilters,
Expand All @@ -433,13 +429,12 @@ export const Discover = compose(
alerts: alerts.data.hits.hits,
total: alerts.data.hits.total.value,
isLoading: false,
requestFilters: newFilters,
});
this.props.updateTotalHits(alerts.data.hits.total.value);
}
} catch (error) {
if (this._isMount) {
this.setState({ alerts: [], total: 0, isLoading: false, requestFilters: newFilters });
this.setState({ alerts: [], total: 0, isLoading: false });
this.props.updateTotalHits(0);
}
throw error;
Expand Down

0 comments on commit 2a18f61

Please sign in to comment.