wazuh-dashboard-plugins icon indicating copy to clipboard operation
wazuh-dashboard-plugins copied to clipboard

Refactor management/rules

Open asteriscos opened this issue 2 years ago • 3 comments

Description

This PR refactors Management Rules views:

  • 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 modules 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 to improve 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 call 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 in the tables rule / decoder filename 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 avatar May 26 '22 14:05 asteriscos

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

github-actions[bot] avatar May 26 '22 15:05 github-actions[bot]

:warning: This issue should be taken into account when resolving this PR.

There is an open PR to fix it, but the changes will conflict with this PR. We should secure the functionality is the same.

Desvelao avatar Jul 05 '22 13:07 Desvelao

warning This issue should be taken into account when resolving this PR.

There is an open PR to fix it, but the changes will conflict with this PR. We should secure the functionality is the same.

Applied the same solution to the columns actions in this commit: https://github.com/wazuh/wazuh-kibana-app/pull/4174/commits/7822cc52218377a1158f1873282efa1f966082b6

asteriscos avatar Jul 12 '22 10:07 asteriscos

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

Mayons95 avatar Sep 07 '22 18:09 Mayons95

@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

asteriscos avatar Sep 08 '22 12:09 asteriscos

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 avatar Sep 09 '22 15:09 asteriscos