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

[Cloud Posture]fix incorrect vuln_mgmt details in flyout #157745

Conversation

Omolola-Akinleye
Copy link
Contributor

@Omolola-Akinleye Omolola-Akinleye commented May 15, 2023

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.
Currently, after navigating any page after the first page and clicking on vulnerability, the flyout displays incorrect details.

Currently, we use the data.page, which lists the maximum amount of vulnerabilities(500 vulnerabilities). The vulnerabilityIndex is set each time, a user clicks to expand vulnerability. We were currently only selecting vulnerabilities from the first page.

Solution:

Use slicedPage to get the vulnerabilities on the current page and then select vulnerability by vulnerabilityIndex

Updated.mov

@Omolola-Akinleye Omolola-Akinleye added v8.8.0 bug Fixes for quality problems that affect the customer experience labels May 15, 2023
@Omolola-Akinleye Omolola-Akinleye changed the title fix incorrect vuln_mgmt details in flyout [Cloud Posture]fix incorrect vuln_mgmt details in flyout May 15, 2023
@Omolola-Akinleye Omolola-Akinleye self-assigned this May 15, 2023
@Omolola-Akinleye Omolola-Akinleye added the Team:Cloud Security Cloud Security team related label May 15, 2023
@Omolola-Akinleye Omolola-Akinleye marked this pull request as ready for review May 15, 2023 16:20
@Omolola-Akinleye Omolola-Akinleye requested a review from a team as a code owner May 15, 2023 16:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

Copy link
Contributor

@kfirpeled kfirpeled left a comment

Choose a reason for hiding this comment

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

Checked locally, LGTM

const selectedVulnerability = data?.page[urlQuery.vulnerabilityIndex];

const selectedVulnerability = useMemo(() => {
return slicedPage?.find(
Copy link
Contributor

Choose a reason for hiding this comment

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

@Omolola-Akinleye why we use find if we know the index?
shouldn't slicedPage[urlQuery.vulnerabilityIndex] would work here? and would be O(1) instead of O(n)

Copy link
Contributor Author

@Omolola-Akinleye Omolola-Akinleye May 15, 2023

Choose a reason for hiding this comment

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

Fair point. Typescript throw undefined when I was using data?.page. I incorrectly confused slicedPage for data.page as being possibly undefined. I will adjust that.

@kfirpeled kfirpeled added the release_note:skip Skip the PR/issue when compiling release notes label May 15, 2023
@Omolola-Akinleye Omolola-Akinleye enabled auto-merge (squash) May 15, 2023 18:47
@@ -116,7 +116,10 @@ const VulnerabilitiesContent = ({ dataView }: { dataView: DataView }) => {
const slicedPage = usePageSlice(data?.page, pageIndex, pageSize);

const invalidIndex = -1;
const selectedVulnerability = data?.page[urlQuery.vulnerabilityIndex];

const selectedVulnerability = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain why useMemo is needed here? if the calculation is O(1), I assume it is redundant overhead

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kfirpeled Good point.useMemo is not needed here. It's over-optimization

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 202.7KB 202.8KB +30.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Omolola-Akinleye

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 15, 2023
)

## Summary

Summarize your PR. If it involves visual changes include a screenshot or
gif.
Currently, after navigating any page after the first page and clicking
on vulnerability, the flyout displays incorrect details.

Currently, we use the `data.page`, which lists the maximum amount of
vulnerabilities(500 vulnerabilities). The `vulnerabilityIndex` is set
each time, a user clicks to expand vulnerability. We were currently only
selecting vulnerabilities from the first page.

Solution:

Use `slicedPage` to get the vulnerabilities on the current page and then
select vulnerability by `vulnerabilityIndex`

https://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4
(cherry picked from commit 5eb9102)
kibanamachine added a commit that referenced this pull request May 15, 2023
…) (#157795)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Cloud Posture]fix incorrect vuln_mgmt details in flyout
(#157745)](#157745)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Lola","email":"omolola.akinleye@elastic.co"},"sourceCommit":{"committedDate":"2023-05-15T19:48:22Z","message":"[Cloud
Posture]fix incorrect vuln_mgmt details in flyout (#157745)\n\n##
Summary\r\n\r\nSummarize your PR. If it involves visual changes include
a screenshot or\r\ngif.\r\nCurrently, after navigating any page after
the first page and clicking\r\non vulnerability, the flyout displays
incorrect details.\r\n\r\nCurrently, we use the `data.page`, which lists
the maximum amount of\r\nvulnerabilities(500 vulnerabilities). The
`vulnerabilityIndex` is set\r\neach time, a user clicks to expand
vulnerability. We were currently only\r\nselecting vulnerabilities from
the first page.\r\n\r\nSolution:\r\n\r\nUse `slicedPage` to get the
vulnerabilities on the current page and then\r\nselect vulnerability by
`vulnerabilityIndex`\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4","sha":"5eb9102bc9313ff46ae72bb6af71e87e09c2ad7c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Cloud
Security","v8.8.0","v8.9.0"],"number":157745,"url":"https://github.com/elastic/kibana/pull/157745","mergeCommit":{"message":"[Cloud
Posture]fix incorrect vuln_mgmt details in flyout (#157745)\n\n##
Summary\r\n\r\nSummarize your PR. If it involves visual changes include
a screenshot or\r\ngif.\r\nCurrently, after navigating any page after
the first page and clicking\r\non vulnerability, the flyout displays
incorrect details.\r\n\r\nCurrently, we use the `data.page`, which lists
the maximum amount of\r\nvulnerabilities(500 vulnerabilities). The
`vulnerabilityIndex` is set\r\neach time, a user clicks to expand
vulnerability. We were currently only\r\nselecting vulnerabilities from
the first page.\r\n\r\nSolution:\r\n\r\nUse `slicedPage` to get the
vulnerabilities on the current page and then\r\nselect vulnerability by
`vulnerabilityIndex`\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4","sha":"5eb9102bc9313ff46ae72bb6af71e87e09c2ad7c"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157745","number":157745,"mergeCommit":{"message":"[Cloud
Posture]fix incorrect vuln_mgmt details in flyout (#157745)\n\n##
Summary\r\n\r\nSummarize your PR. If it involves visual changes include
a screenshot or\r\ngif.\r\nCurrently, after navigating any page after
the first page and clicking\r\non vulnerability, the flyout displays
incorrect details.\r\n\r\nCurrently, we use the `data.page`, which lists
the maximum amount of\r\nvulnerabilities(500 vulnerabilities). The
`vulnerabilityIndex` is set\r\neach time, a user clicks to expand
vulnerability. We were currently only\r\nselecting vulnerabilities from
the first page.\r\n\r\nSolution:\r\n\r\nUse `slicedPage` to get the
vulnerabilities on the current page and then\r\nselect vulnerability by
`vulnerabilityIndex`\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4","sha":"5eb9102bc9313ff46ae72bb6af71e87e09c2ad7c"}}]}]
BACKPORT-->

Co-authored-by: Lola <omolola.akinleye@elastic.co>
jasonrhodes pushed a commit that referenced this pull request May 17, 2023
## Summary

Summarize your PR. If it involves visual changes include a screenshot or
gif.
Currently, after navigating any page after the first page and clicking
on vulnerability, the flyout displays incorrect details.

Currently, we use the `data.page`, which lists the maximum amount of
vulnerabilities(500 vulnerabilities). The `vulnerabilityIndex` is set
each time, a user clicks to expand vulnerability. We were currently only
selecting vulnerabilities from the first page.

Solution:

Use `slicedPage` to get the vulnerabilities on the current page and then
select vulnerability by `vulnerabilityIndex`


https://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.8.0 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud Security] CNVM is displaying incorrect details for a finding in the flyout.
5 participants