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

Refactor ruleset management #4174

Merged
merged 88 commits into from
Sep 9, 2022
Merged

Conversation

asteriscos
Copy link
Member

@asteriscos asteriscos commented May 26, 2022

Description

This PR refactors the views related to the management of the ruleset:

  • To use standard / reusable Wazuh tables and flyouts to improve maintainability.
  • Removes the use of redux on a single ruleset view to determine whether it renders rules, decoders, or CDB lists.
  • Segregates the module's views in their own module folder to simplify the logic and improve maintainability.
  • Integrates the rules / decoders details as a flyout in the table view, improving consistency with other table-details behavior in the app.
  • Fixes redundant API requests in the reusable Wazuh API table component.
  • Enhances Wazuh API table component with custom action buttons.
  • Fixes a ruleset view pagination bug when the it parsed the rule id from the redirectRule query param. It could not retrieve the rule details if it was not in the first 500 results

Closes #4105

Screenshots

Table view

image

Details flyout

image

Test cases

Summary

All calls to action and navigation elements should be tested in Rules, Decoders, CDB Lists modules. When in doubt, compare the behavior of the feature with any 4.3.x Wazuh version

Tests:

  • All table features

    • Pagination
    • Sorting
    • Row clicking
    • Links within the table rows
    • Search input
    • Custom action buttons (Manage rule files, Add new rule file, Refresh, Export formatted, etc.)
      • Manage rule / decoder files button should clear previous filters before switching the table
    • Custom rules / decoders filter button
  • Clicking a row in the rules or decoders tables should open a flyout with the details of the selected item.

    • In the details flyout information accordion, there are "links" that should close the flyout and filter the property in the background table.
    • Clicking a row in the table within the details flyout should replace the information in the flyout with the selected item.
    • Clicking the rule / decoder filename in the tables should load the file content view.
  • Clicking a rule.id in the Events table should load the rules view with an open flyout showing the selected rule information
    image

@asteriscos asteriscos self-assigned this May 26, 2022
@github-actions
Copy link
Contributor

Jest Test Coverage % values
Statements 4.05% ( 1487 / 36690 )
Branches 1.62% ( 463 / 28551 )
Functions 2.97% ( 267 / 8978 )
Lines 4.1% ( 1439 / 35067 )

@AlexRuiz7 AlexRuiz7 linked an issue Jun 1, 2022 that may be closed by this pull request
@Desvelao Desvelao changed the base branch from 4.3-7.10 to 4.4-7.10 June 24, 2022 08:56
@AlexRuiz7 AlexRuiz7 changed the base branch from 4.4-7.10 to 4.4-7.10-test September 5, 2022 15:03
@asteriscos asteriscos changed the base branch from 4.4-7.10-test to 4.4-7.10 September 5, 2022 15:06
Copy link
Member

@AlexRuiz7 AlexRuiz7 left a comment

Choose a reason for hiding this comment

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

Great work so far, however, threre are a few things that need review!

Let's keep up the good work! 💪🏻

@AlexRuiz7 AlexRuiz7 changed the title Refactor management/rules Refactor ruleset management Sep 7, 2022
@Mayons95
Copy link
Contributor

Mayons95 commented Sep 7, 2022

Testing RBAC with the refactor

Read Only User:
Screenshot from 2022-09-07 15-17-08
Screenshot from 2022-09-07 15-17-00

Read - Delete:

Screenshot from 2022-09-07 15-17-19
Screenshot from 2022-09-07 15-17-08
Screenshot from 2022-09-07 15-17-00

Read - Write:
Screenshot from 2022-09-07 15-20-28
Screenshot from 2022-09-07 15-20-21
Screenshot from 2022-09-07 15-20-00

I need help checking the needed permissions to create/update a rule.
I try to test it and I got this error:
Screenshot from 2022-09-07 15-25-18

C.C @asteriscos @AlexRuiz7

@asteriscos
Copy link
Member Author

@Mayons95 could you please specify which roles/permissions were used in your tests?

I used a read-only rules test case and this was the outcome.
Peek 2022-09-08 13-57

Copy link
Member

@AlexRuiz7 AlexRuiz7 left a comment

Choose a reason for hiding this comment

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

LGTM!

@asteriscos
Copy link
Member Author

RBAC Tests

I tested this roles with each call to action and work as expected. With this we finish RBAC tests in this PR and is ready to merge.

Policies

Screenshot from 2022-09-09 17-33-27

Cases

Screenshot from 2022-09-09 17-43-37

Screenshot from 2022-09-09 17-42-59

@asteriscos asteriscos merged commit 5db8ae0 into 4.4-7.10 Sep 9, 2022
@asteriscos asteriscos deleted the refactor/management-rules-4105 branch September 9, 2022 16:01
github-actions bot pushed a commit that referenced this pull request Sep 9, 2022
* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Remove unused imports

* Fixed ResourcesHandler

* Added interfaces and fixed comments

* Add section contants

* Code styling

* Replaced string for constants

Co-authored-by: Alex Ruiz Becerra <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 5db8ae0)
github-actions bot pushed a commit that referenced this pull request Sep 9, 2022
* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Remove unused imports

* Fixed ResourcesHandler

* Added interfaces and fixed comments

* Add section contants

* Code styling

* Replaced string for constants

Co-authored-by: Alex Ruiz Becerra <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 5db8ae0)
asteriscos added a commit that referenced this pull request Sep 9, 2022
Refactor ruleset management (#4174)

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Remove unused imports

* Fixed ResourcesHandler

* Added interfaces and fixed comments

* Add section contants

* Code styling

* Replaced string for constants

Co-authored-by: Alex Ruiz Becerra <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 5db8ae0)

Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
asteriscos added a commit that referenced this pull request Sep 9, 2022
Refactor ruleset management (#4174)

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Refactored implementation of wazuh table

* Refactored action buttons

* Partial commit ruleset views segregation

* Added searchbar input custom filter buttons

* Added Custom Field Filter to table & removed redux from action buttons

* Segregated file tables

* set showingFiles locally

* Fixed details flyout

* Segregate views

* Removed redux from ruleset editor

* refactored Decoders section

* delete obsolete decoder-info

* Fixed decoder flyout

* Added decoder info.tsx

* Remove unused files

* Set CDBList views

* Dynamically build table custom action buttons

* Deleted hardcoded export csv filename

* Fix CDB List row click handler

* Fixed suggestions and custom actions responsive styles

* columns configuration fix

* wzApiTable optimization + obsolete redux cleaning

* Implemented Wazuh flyouts

* Convert to typescript

* Extracted tables components

* Fix mapStateToProps to null

* Removed ruleset redux files

* Removed Add CDB List button in ruleset and decoders views

* Fix missing updateListContent

* Added external reload to the tables

* Fixed redirectRule url cleaning

* Fix onClose modal preventDefault

* Fix reload props

* Fix onClick modal preventDefault

* Clean code comments

* Added error handling to tables columns

* removed deprecated code

* Fixed file description and objects destructuring

* Refactored class components to functional

* Changed file view state handling

* Remove unused imports

* Fixed ResourcesHandler

* Added interfaces and fixed comments

* Add section contants

* Code styling

* Replaced string for constants

Co-authored-by: Alex Ruiz Becerra <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 5db8ae0)

Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
@Mayons95 Mayons95 mentioned this pull request Dec 7, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError in Management/Rules
4 participants