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

Added pagination to SCA table #4653

Merged
merged 13 commits into from
Oct 19, 2022
Merged

Conversation

chantal-kelm
Copy link
Member

@chantal-kelm chantal-kelm commented Oct 6, 2022

Description

This pull request adds pagination to the table used in the SCA section. This refactor required new endpoints, or new endpoints options (distinct and select) from the Wazuh API.

Issues Resolved

@chantal-kelm chantal-kelm linked an issue Oct 6, 2022 that may be closed by this pull request
@AlexRuiz7 AlexRuiz7 changed the title pagination SCA table Add pagination to the SCA table Oct 7, 2022
@Machi3mfl
Copy link
Member

Machi3mfl commented Oct 12, 2022

Researching the current issue

Researching the behavior of the search bar and table in the SCA > Inventory view.

  1. The search bar builds the suggestions list calling to the /sca/AGENT_ID/checks/POLICY_ID endpoint, retrieving all the checks by policy and making a distinct manually in the loadScaPolicy and buildSuggestionSearchBar methods.
  2. The view uses de TableWzAPI to render the table.

Steps

  • Use the SCA endpoint with the distinct parameters to prevent requesting all the data needlessly.
  • Improve the inventory.tsx file because have too much logic and is incomprehensible. It's better to create more files (components) to make the component more readable and reusable.

@Machi3mfl
Copy link
Member

I found and resolved an error in the Vulnerabilities > Inventory. This error was generated by the removed beautifyDate function.

Selection_067.

@AlexRuiz7 AlexRuiz7 changed the title Add pagination to the SCA table Add pagination to SCA table Oct 13, 2022
@Machi3mfl
Copy link
Member

Machi3mfl commented Oct 13, 2022

Tasks in progress

  • Reorder and removed unnecessary code in sca inventory.tsx file
  • Use the sca endpoint with the distinct parameter in the search bar.

Selection_071

  • Rebased current branch from 4.4-7.10 to launch the unit test workflow.
  • Resolve error when is clicked field and doesn't have suggestions. This issue was resolved before we need to adapt it.

Selection_070

  • Created a new component InventoryPolicyChecksTable to separate the checks table and search bar from the inventory main component
  • Resolve unit tests errors

Current endpoints workflow

  • Load inventory policies table (initialize): load all policies by agent ID /sca/agent_id
  • Click and show policy checks: check if specific policy exists /sca/agent_id?policy_id=id and get all policy checks /sca/agent_id/checks/policy_id
  • Generate suggestions check search bar: generate the suggestions using all the checks retrieved before.

@Machi3mfl Machi3mfl marked this pull request as ready for review October 17, 2022 17:36
@Machi3mfl Machi3mfl requested a review from a team as a code owner October 17, 2022 17:36
Copy link
Contributor

@Mayons95 Mayons95 left a comment

Choose a reason for hiding this comment

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

After testing this feature, we can identify that the search bar has some problems.

image

Here I applied a tittle filter and it's ignored by the filter bar.
@Machi3mfl There is a possibility to check this ?

@Mayons95
Copy link
Contributor

After reviewing the functionallity with @Machi3mfl we found that the environment API was outdated, after download the changes we could check that the filter bar it's working fine.
I left here the evidence

Screenshot from 2022-10-19 10-42-57

Copy link
Contributor

@Mayons95 Mayons95 left a comment

Choose a reason for hiding this comment

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

LGTM
TR: ✔️

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!

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

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

Test: ✔️
CR: ✔️

@Machi3mfl Machi3mfl changed the title Add pagination to SCA table Fixed pagination to SCA table Oct 19, 2022
@Machi3mfl Machi3mfl merged commit 8ec037c into 4.4-7.10 Oct 19, 2022
@Machi3mfl Machi3mfl deleted the enhance/4314-SCA-table-paging branch October 19, 2022 15:04
@github-actions
Copy link
Contributor

The backport to 4.4-7.16 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-7.16 4.4-7.16
# Navigate to the new working tree
cd .worktrees/backport-4.4-7.16
# Create a new branch
git switch --create backport-4653-to-4.4-7.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8ec037c685d5d5747920dd36c2d0d8052ea294d0
# Push it to GitHub
git push --set-upstream origin backport-4653-to-4.4-7.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-7.16

Then, create a pull request where the base branch is 4.4-7.16 and the compare/head branch is backport-4653-to-4.4-7.16.

github-actions bot pushed a commit that referenced this pull request Oct 19, 2022
* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* Refactored sca inventory sca and added some types

* Solved some eslint warnings

* Solved review comments

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 8ec037c)
AlexRuiz7 pushed a commit that referenced this pull request Oct 19, 2022
Fixed pagination to SCA table (#4653)

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* Refactored sca inventory sca and added some types

* Solved some eslint warnings

* Solved review comments

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 8ec037c)

Co-authored-by: Chantal Belén kelm <99441266+chantal-kelm@users.noreply.github.com>
@github-actions
Copy link
Contributor

Code coverage (Jest) % values
Statements 7.19% ( 2608 / 36280 )
Branches 3.03% ( 846 / 27948 )
Functions 5.02% ( 444 / 8845 )
Lines 7.27% ( 2524 / 34732 )

@AlexRuiz7 AlexRuiz7 changed the title Fixed pagination to SCA table Added pagination to SCA table Oct 20, 2022
AlexRuiz7 pushed a commit that referenced this pull request Oct 20, 2022
* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* Refactored sca inventory sca and added some types

* Solved some eslint warnings

* Solved review comments

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 8ec037c)
AlexRuiz7 added a commit that referenced this pull request Oct 20, 2022
Fixed pagination to SCA table (#4653)

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* pagination SCA table

* Resolved beautifyDate is not a function

* Used sca checks with distinct and value in search bar

* Refactored sca inventory sca and added some types

* Solved some eslint warnings

* Solved review comments

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 8ec037c)

Co-authored-by: Chantal Belén kelm <99441266+chantal-kelm@users.noreply.github.com>
Machi3mfl pushed a commit that referenced this pull request Nov 11, 2022
…ed beautifyDate is not a function * Used sca checks with distinct and value in search bar * pagination SCA table * Resolved beautifyDate is not a function * Used sca checks with distinct and value in search bar * Refactored sca inventory sca and added some types * Solved some eslint warnings * Solved review comments Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 8ec037c)

# Conflicts:
#	CHANGELOG.md
#	public/components/agents/vuls/inventory.tsx
#
# It looks like you may be committing a cherry-pick.
# If this is not correct, please run
#	git update-ref -d CHERRY_PICK_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author:    Chantal Belén kelm <99441266+chantal-kelm@users.noreply.github.com>
# Date:      Wed Oct 19 12:04:00 2022 -0300
#
# On branch 4.4-7.16
# Your branch is up to date with 'origin/4.4-7.16'.
#
# You are currently cherry-picking commit 8ec037c.
#
# Changes to be committed:
#	modified:   CHANGELOG.md
#	modified:   public/components/agents/sca/inventory.tsx
#	new file:   public/components/agents/sca/inventory/checks-table.tsx
#	new file:   public/components/agents/sca/inventory/index.ts
#	new file:   public/components/agents/sca/inventory/lib/api-request.ts
#	new file:   public/components/agents/sca/inventory/lib/index.ts
#	modified:   public/components/agents/vuls/inventory.tsx
#	modified:   public/components/common/tables/table-default.tsx
#	modified:   public/components/common/tables/table-wz-api.tsx
#	modified:   public/components/wz-search-bar/lib/base-handler.ts
#
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.

SCA checks are not being paginated properly
6 participants