Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3209/improving and removing WUI error logs #3260

Merged
merged 11 commits into from May 25, 2021

Conversation

CPAlejandro
Copy link
Contributor

Hi guys,
In this PR we solve the problem that several records of the same type are shown when starting the app, we improve the message that is shown for the errors of the Response Error and security_exception type.

To test it, you will have to create an environment, delete the wazuh folder from / kibana / data and see the logs that appear in the app /Configuration/Logs section.

The tests must be done with ODFE, X-Pack and without security.

Closes #3209

@CPAlejandro CPAlejandro added the type/enhancement Enhancement issue label May 19, 2021
@CPAlejandro CPAlejandro self-assigned this May 19, 2021
Copy link
Contributor

@gabiwassan gabiwassan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

import { log } from '../lib/logger';

export const tryCatchForIndexPermissionError = (wazuhIndex: string, logLocation?: string, context?) => (functionToTryCatch) => async () => {
console.log("HOAL QUE PASA NENE", logLocation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this console.log correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks you!

case 'security_exception':
error.message = (((((error.meta || error.message).body || error.message).error || error.message).root_cause[0] || error.message).reason || error.message);
break;
case 'Response Error':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would pass this string 'security_exception' and 'Response Error' to constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it, thank you!

Copy link
Contributor

@pablomarga pablomarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! LGTM

log('wazuh-api:getToken', errorMessage);
log('wazuh-api:getToken', errorMessage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the identation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -43,7 +44,7 @@ export class SaveDocument {

private async checkIndexAndCreateIfNotExists(index, shards, replicas) {
try {
try {
tryCatchForIndexPermissionError(index, this.logPath) (async() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an await.

export * from './queue';
export * from './tryCatchForIndexPermissionError'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon ;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you!

@@ -18,6 +18,7 @@ import fs from 'fs';
import { ManageHosts } from '../../lib/manage-hosts';
import { WAZUH_ALERTS_PATTERN, WAZUH_DATA_CONFIG_REGISTRY_PATH, WAZUH_INDEX, WAZUH_VERSION_INDEX, WAZUH_KIBANA_TEMPLATE_NAME, WAZUH_DATA_KIBANA_BASE_ABSOLUTE_PATH } from '../../../common/constants';
import { createDataDirectoryIfNotExists } from '../../lib/filesystem';
import { tryCatchForIndexPermissionError } from '../tryCatchForIndexPermissionError'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon ;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you!

Comment on lines 360 to 362
if(error.name !== 'ResponseError')
log('initialize:checkKibanaStatus', error.message || error);
context.wazuh.logger.error(error.message || error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is only affecting the log function and no to Kibana logger. Should it be of this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, if it could be interesting to try to control the kibana loggers

@@ -26,6 +26,7 @@ import {
WAZUH_MONITORING_DEFAULT_ENABLED,
WAZUH_MONITORING_DEFAULT_FREQUENCY,
} from '../../../common/constants';
import { tryCatchForIndexPermissionError } from '../tryCatchForIndexPermissionError'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon ;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you!

@@ -0,0 +1,44 @@
/*
* Wazuh app - React HOCs to manage the message when elastic show a Response error
Copy link
Member

@Desvelao Desvelao May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a HOC and isn't not related to React, it is a HOF (High order function)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thta's true, thanks you!

await functionToTryCatch();
}
catch (error) {
enum error_types{
Copy link
Member

@Desvelao Desvelao May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could name it in uppercase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@Desvelao Desvelao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the suggetions

@Desvelao
Copy link
Member

Testing ✅
image

@Desvelao Desvelao linked an issue May 19, 2021 that may be closed by this pull request
@pablomarga pablomarga self-requested a review May 24, 2021 08:17
Copy link
Contributor

@pablomarga pablomarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested X-Pack: ✔️
Tested ODFE: ✔️
Tested no security: ✔️

Copy link
Member

@Desvelao Desvelao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
CR: ✅
Testing: ✅

@Desvelao Desvelao merged commit afd2084 into 4.2-7.10 May 25, 2021
@Desvelao Desvelao deleted the fix-3209/Improving-and-removing-WUI-error-logs branch May 25, 2021 08:31
frankeros added a commit that referenced this pull request Jun 22, 2021
* Feature/remove module titles (#3160)

* Remove module titles

* Add popover to breadcrumb

* Update changelog

* Fix errors

* Fix the broken links when using server.basePath Kibana setting (#3161)

* fix(frontend): Fix broken link when use 'server.basePath` Kibana setting
  - Fix links in Wazuh breadcrumb
  - Fix some redirection links

* feat(prettier): Added prettierrc config file. (#3168)

* [Feature]: Add Wazuh help links as extension in Kibana help menu (#3170)

* feat(frontend): Add Wazuh help links as an extension in Kibana help menu

* fix(changelog): Add PR to changelog

* fix(changelog): Fix PR number and link

* fix(help-links): Replace component and removed color styles from Wazuh lunk in the Kibana help button

* Fixing filter in reports (#3173)

* Removed sha1 data and correct date format (#3189)

* [FEATURE] Add redirect to group details using the URL (#3184)

* feat(groups): Add redirect to group details using the URL
  - Redirect to group details when the URL contains group query param

* doc(changelog): add missing changelog for #3189

* Fixed screen flickers in Cluster Visualization (#3159)

* Modify the default settings related to monitoring indices creation (#3174)

* fix(configuration): Changed WAZUH_MONITORING_DEFAULT_CREATION app setting from 'd' to 'w' (weekly)

* fix(configuration): Replace wazuh.monitorin.creation from d to w (weekly)
  - Fixed cron.prefix setting

* fix(monitoring): Set monitoring default indices shards to 1. Another fixes in configurations

* fix(monitoring): fix wazuh.monitoring.shards value in the initail app configuration

* doc(changelog): add missing changelogs

* doc(changelog): remove duplicated changelogs

* Bugfix default index patterns [Health-check] - 4.2 (#3232)

* bugfix(health-check): Fixed creation of default index and added all section create and refresh index in heath-check.

* fix: some bad behaviors

* doc(changelog): add fix to changelog

* fix: reject promise on error and refactor

* fix: refactor required fields

* feat: refactor const

* Update CHANGELOG.md

Co-authored-by: Franco Charriol <francocharriol@gmail.com>
Co-authored-by: Franco Charriol <franco.charriol@wazuh.com>

* Fix validation of list of valid index patterns for alerts (#3236)

* Last changes from Tag 4.2.0 4201 (#3246)

* Fixed fields overlap in the agent summary screen (#3217)

* [Refactor] Health check (#3197)

* refactor(healthcheck): Adapt the refactorized health check component to last changes
  - Added monitoring and statistics index patterns checks
  - Added logic to retry the checks with a refresh button
    - Apply the retry to API connection check
  - Export react services in index file
  - Create appConfig in the Redux store

* feat(healtcheck): Replace health check initial state to waiting

* fet(healthcheck): Add can retry to healthcheck checks

* fix(menu): Fix error in toast from WzMenu and revome unnecessary return in PatternHandler

* fix(health-check): Fix create index pattern when change the setting in
Settings > Configuration and loop in health check

* fix(health-check): renamed files from appConfig Redux actions and reducer

* fix(frontend): Replace config singleton saving to Redux

* fix(health-check): Fix infinite loop rendering component when a check is disabled in the configuration

* fix(health-check): Rename health checks titles

* fix(health-check): Fix the tests for Health check

* refactor(health-check): Request changes, add max buckets check and some improvements
  - Request changes
  - Added the max buckets check when the component is mounted
  - Created the `useRootScope` hook
  - Improved the export in the HOCs and hooks index files
  - Removed the `lib` folder
  - Removed the `health-check` old component

* Add modal to different sections (#3221)

* Roles Mapping

* Investigating problem with lifecylce

* Created new mask and fix role mapping

* Create and edit user

* Create and edit roles

* Edit policy

* Polices edit and create

* Management

* Update Changelog

* Change copyright

* Fix errors

* Feature Disable Wazuh by roles (#3222)

* fix package name in add new agent (#3233)

* fix index typo settings (#3234)

* [Fix] Visualize button on Events (Discover component) (#3237)

* fix(discover) Ser UiActions of the Discover plugin
  - This fixes the Visualize button was missing in the Discover sidebar when expanding a index field

* add error when add sample data fails (#3241)

* fix(navbar): Hide navbar wazuh label. (#3240)

* Vulnerabilities inventory cleanup 3242 (#3243)

* Removed check for active agent
Now a list of vulnerabilities will be shown regardless of agent activity

* Removed name from the top of the flyout
Now only the CVE remains

* added missing modules in agent menu (#3244)

* Removed tooltip in last breadcrumb in header breadcrumb (#3250)

* Improve api selector (#3175)

* error adding selectors

* added select api and select index pattern on menu

* remove unused variables

* error adding selectors

* added select api and select index pattern on menu

* remove unused variables

* bugfix(apiSelector): Fixed index pattern selection, bad behavior when switching from navbar.

* Added Popover when screen width is small

* Changed popover icon

* Resolved requested changes

* Removed selectors in wazuh menu, removed margin in breadcrumb

* Removed margins style in breadcrumb

* Added tooltip in popover selectors button

* fixed marginLeft syntax in breadcrumb

* Fixed conditions to show selectors in popover

* Fixed change API selector

* Fixed selectors sizes

* Update CHANGELOG.md

Co-authored-by: gabiwassan <gabriel.wassan@wazuh.com>
Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>
Co-authored-by: Franco Charriol <francocharriol@gmail.com>
Co-authored-by: Franco Charriol <franco.charriol@wazuh.com>

* Bugfix/3273 error check wazuh no security (#3292)

* Fixed error in check-wazuh

* updated CHANGELOG

* fix(changelog): Moved PR number to a existent change

Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>
Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>

* Add validation form creating new rule/decoder (#3274)

* Add modal when creating new rule

* Update changelog

* Change if/else

* Change rest of if/else

* Change flyout title

* Fix error when saving a rule

* Fix errors in PDF reports (#3272)

* Remove dupicate subsection

* Fix duplicate Who data

* fix date format pdf

* Fix width columns

* Add changelog

* Remove unused variable

* Translate comments

* Use camelCase

* Removed unnecessary tabs

* Transalate comments

* fix(reporting): Replace array constructor

* fix(changelog): Removed spaces in markdown links

Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>

* Fix typerror deploy new agent Safari 12 (#3289)

* Fix unsupported function in Safari 12

* Update changelog

Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>

* Fix 3209/improving and removing WUI error logs (#3260)

* Improving and removing WUI error logs

* Fix

* Added Changelog

* Comment upgrades

* Adding contant to tryCatchForIndexPermissionError

* Fixes

* More fixes and upgrades

* fix(server): Moved a server log in /api/check-stored endpoint
  - Moved a server log in endpoint
  - Renamed variable in monitoring job

* fix(monitoring): Replaced multiple try/catch block by one.

Co-authored-by: Desvelao <iamdesvelao@gmail.com>
Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>

* Fix/graph single api 3239 (#3256)

* Added filter for current api in kibana-vis
The Evolution graph in agents/ should display only the status of agents that belong to the selected API

* Fixed partial matches
Fixed issue where a manager whose name is a substring of another's would show data from both

* Added a getManagers method to agents preview
This method requests the managers from the current API and extracts the unique occurence of each of the managers, returning a list of the names of all the managers the agents in the current API have.

Also modified the filter in kibana-vis so it makes use of an array of managers instead of a single one.

* Updated CHANGELOG

* Changed the filter parameters from manager to cluster name
Seeing how the only way to find the complete list of managers is getting the complete list of agents, and this being possibly taxing on the API, the filter dependency has been switched to `cluster.name`
Now the graph will conflict if 2 clusters share the same name instead of 2 managers.

* Applied formating and adjusted filter metadata

* Added logic to pick a filter for manager or cluster when appropriate

* fix(monitoring): Moved the filter of agents evolution visualization to
KibanaVis

Co-authored-by: Desvelao <iamdesvelao@gmail.com>

* changelog: Fix changes in revision 4202

* [SCA] Fix the render of the checks in a SCA check (#3297)

* fix(sca): Fix the render of the checks in a SCA check
  - Now display each check.rule

* changelog: Add PR to changelog

* add session token to rulest (#3257)

* add session token to rulest

* add changelog

* fix code

* fix packge json

* bufix(logtest): Replaced request to get token. We have a token for this session on the return of the PUT logtest.

* docs(changelog): Fixed format and messages

* bugfix(logtest): Replaced promise.all, we need take token for the next request.

* fix(logtest): Use the same token generated in the first request to another logs

* fix(logtest): Add control when the token was gotten

* fix(logtest): Fix variable when got the token

* Added buttom to clear session in logtest and add control of logtest token to Redux

* Update logtest.tsx

* [Health check] Add logs with the details about the check (#3258)

* feat(health-check): Add logs to the check of Health check
  - Add logs to checks
  - Add button to open/close the check logs
  - Add new section to Settings: Miscellaneous
  - Add control when the health chekc is run in `debug` mode (no redirection after cheks are ready)
  - Refactor some functions
  - Some ajustments to Settins secions related to spaces

* fix(health-check): Fix health check redirection and update tests
  - Fix health check redirection when all checks are ready
  - Update health check tests

* feat(health-check): Remove notification when opening the check logs and there is some check action

* fix(health-check): Fix unknown error and added improvements to notifications

  - Fix unknown error after restart the cluster and try to pass the health check
  - Remove the notification dot of check details when open for first
time
  - Display the check details button when there are logs
  - Updated the tests (snapshot and tests)

* Remove status text. Improve styles. Small log text fix

* Added animated codeblock transition

* Fixed react warnings

* Fixed animation style

* Fixed unit test

* Only show log button when error or debug mode

* updated unit test snapshots

* Fix typo

* Update CHANGELOG.md

* Adapt kibana integrations to public interfaces of saved objects for 7.11/7.12 (#3309)

* fix: update kibana-discover and kibana-vis to 7.11 public interfaces

* update[changelog]: add to changelog

* fix: remove comment code

* Fix alerts summary reports (#3303)

* Fix some alerts summary reports

* Fix date CIS CAT module

* Disabled index pattern checks in Healthcheck (#3311)

* feat(health-check): Add logs to the check of Health check
  - Add logs to checks
  - Add button to open/close the check logs
  - Add new section to Settings: Miscellaneous
  - Add control when the health chekc is run in `debug` mode (no redirection after cheks are ready)
  - Refactor some functions
  - Some ajustments to Settins secions related to spaces

* fix(health-check): Fix health check redirection and update tests
  - Fix health check redirection when all checks are ready
  - Update health check tests

* feat(health-check): Remove notification when opening the check logs and there is some check action

* fix(health-check): Fix unknown error and added improvements to notifications

  - Fix unknown error after restart the cluster and try to pass the health check
  - Remove the notification dot of check details when open for first
time
  - Display the check details button when there are logs
  - Updated the tests (snapshot and tests)

* Remove status text. Improve styles. Small log text fix

* Added animated codeblock transition

* Fixed react warnings

* Fixed animation style

* Fixed unit test

* Only show log button when error or debug mode

* updated unit test snapshots

* Fix typo

* Disabled index pattern checks

* Updated CHANGELOG

* Removed awaitFor, fixed title, and label

* Changed some services names

* fix: refactor architecture and remove unnecessary checks

* fix error agent view does not render correctly (#3306)

* fix error agent view does not render correctly

* update CHANGELOG.md

* add new file .scss and functions declarations

* prettier

* Fix visualizations with dark mode background in PDF report (#3315)

* Normalize visData table property for 7.12 retro-compatibility (#3323)

* Use the longest value in column to get column width in PDF report tables (#3326)

* Use the longest value in column to get column width

* Added changelog

* Improved code readability

* New attributes added for integration testing (#3331)

* New attributes added for integration testing

* New constants added for integration testing

* Added new constants files for cypress

* updated selectors and atributes

* Hide Wazuh breadcrumb label and Wazuh api selector css fix (#3347)

* Change css breadcrumb selector + Wazuh api selector css fix

* Fix/elastic UI upgrade breaking changes in 7.11 and 7.12 3318 (#3345)

* Added required legend to EuiButtonGroup component

* Removed deprecated withTitle on EuiPopover component

* Added changelog

* Improved code readability

* Fix error due short graphs (#3349)

* Changed the way of hiding unloaded charts by setting them to display: none instead of height

* Updated changelog

* Applied prettier and moved logical operations outside render return to improve legibility

* Fixed a typo in changelog

* Fix/3320 visualization label overlap (#3355)

* Refactor of visualization definitions
For each visualization, for each attribute that was a string of a JSON object, they were converted to an object inside a `JSON.stringify()` and applied the formatter in order to make them easier to read and maintain.

* Added a filter true to all the line, area and histogram visualizations
This should prevent any labels from ever overlapping at low widths

* Fix export to csv table button 7.11 & 7.12 (#3358)

* Refactor of visualization definitions
For each visualization, for each attribute that was a string of a JSON object, they were converted to an object inside a `JSON.stringify()` and applied the formatter in order to make them easier to read and maintain.

* Added a filter true to all the line, area and histogram visualizations
This should prevent any labels from ever overlapping at low widths

* Updated changelog

* Added toolbar buttons to tables

* Added changelog

* Added changelog

* Fixed changelog

Co-authored-by: Manuel Gómez Castro <manuel.gomez@wazuh.com>

* doc: add missing changelog for revision 4108

* doc: change 4.2.1 for revision 4202

* fix: move createGetter to common-services.ts

* fix: update import for getErrorOrchestrator

* fix: add Copyright comment in the new file

Co-authored-by: Pablo Martínez <pablomarga@hotmail.com>
Co-authored-by: Toni <34042064+Desvelao@users.noreply.github.com>
Co-authored-by: Gabriel Wassan <gabriel.wassan@wazuh.com>
Co-authored-by: Alejandro Cuéllar Peinado <alejandro.cuellar@wazuh.com>
Co-authored-by: sortizowlh <47242022+sortizowlh@users.noreply.github.com>
Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
Co-authored-by: Ezequiel Airaudo <36004787+eze9252@users.noreply.github.com>
Co-authored-by: mpRegalado <80431234+mpRegalado@users.noreply.github.com>
Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>
Co-authored-by: Pablo Martínez <pablo.martinez@wazuh.com>
Co-authored-by: Desvelao <iamdesvelao@gmail.com>
Co-authored-by: Matias Ezequiel Moreno <49887871+matiasmoreno876@users.noreply.github.com>
Co-authored-by: Manuel Gómez Castro <manuel.gomez@wazuh.com>
@MauGaP MauGaP mentioned this pull request Sep 1, 2021
46 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WUI error logs
5 participants