Skip to content

[Cloud Security ] 12165 update UI handling of multiple CVEs and package fields#216411

Merged
alexreal1314 merged 27 commits intomainfrom
12165-update-ui-implementation-of-cve
Apr 8, 2025
Merged

[Cloud Security ] 12165 update UI handling of multiple CVEs and package fields#216411
alexreal1314 merged 27 commits intomainfrom
12165-update-ui-implementation-of-cve

Conversation

@alexreal1314
Copy link
Copy Markdown
Contributor

@alexreal1314 alexreal1314 commented Mar 30, 2025

Summary

This PR updates the rendering of multi value fields - vulnerability.id, package.name, package.version and package.fixed_version in the vulnerabilities data-grid page and alerts insights vulnerabilities tab data grid.
It also updates the rendering of package.* fields in the vulnerabilities flyout and both flyout and data grids are re using the same kbn package component to display it.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Make CVSS column to be displayed first in the data grid.
  • if there is a single CVE display its value across the data grid.
  • data-grid if there is more than a single CVE show it as <first_cve> <+x more> badge indicating the number of CVES left. Clicking on the badge should open a Popver where all CVEs are displayed as badges - clicking on the value will add it to the search bar filters, each batch should have a copy icon as well.
  • insights tab data-grid should have similar logic to display multi value fields but without adding it to the filters logic since there are no filters in that page.
  • logic of displaying multiple CVEs should be applied to package.name, package.version and package.fixed_version fields in both data grids.
  • arrays in package-related vulnerability fields are rendered correctly in the flyout header and footer.
  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Unit or functional tests were updated or added to match the most common scenarios
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Screen recording

Screen.Recording.2025-04-06.at.12.18.11.mov

@alexreal1314 alexreal1314 added Team:Cloud Security Cloud Security team related backport:skip This PR does not require backporting release_note:enhancement ci:cloud-deploy Create or update a Cloud deployment labels Mar 30, 2025
@kibanamachine
Copy link
Copy Markdown
Contributor

Cloud deployment initiated, see credentials at: https://buildkite.com/elastic/kibana-deploy-cloud-from-pr/builds/127

@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch 2 times, most recently from b3694e1 to 79ea6b7 Compare March 31, 2025 09:51
firstItemRenderer?: (item: K) => React.ReactNode;
}

const MultiValueCellPopoverComponent = <T, K = string>({
Copy link
Copy Markdown
Contributor Author

@alexreal1314 alexreal1314 Mar 31, 2025

Choose a reason for hiding this comment

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

I was thinking about making this component a wrapper to EuiPopover that displays a badge and gets array of items and a render function but there are few issues with that approach:

  1. if vulnerability.id = ['a'] in that case if we don't render the first item here then the consumer should render it. So we will end up with a '+ 0' text in the badge since we are displaying the amount of items left - 1. That leads to the next issue.
  2. To avoid displaying '+ 0' badge we need to check if the array's length is bigger than 1 - in that case we rely on the consumer to display the first item - IMO it leads to split responsibility between consumer and component, risk of inconsistency if conusmers doesn't handle single item case and if we add items.length - 1 logic to the component it is coupled with display logic.
    E.G consumer will do something like this:
    image

therefore we hide this logic in the component and render it as it is or allow the user to pass optional param firstItemRenderer function to handle the first item rendering. So this component handles the first item and the subsequent ones are rendered in the popover. it is possible to render only the badge and pass firstItemRenderer as an empty function.
Other params are:

  • items , which are the items to be renders in the popover.
  • field - the field we are rendering - e.g 'vulnerability.id', 'package.name' etc.
  • object - the object which the value is extracted from, needed for the renderItem callback.
  • renderItem function - renders each item in the popover
  • firstItemRenderer optional - custom render function to handle first item.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the proposal makes sense, as it aims on flexbility and reusability

@alexreal1314 alexreal1314 marked this pull request as ready for review March 31, 2025 12:31
@alexreal1314 alexreal1314 requested review from a team as code owners March 31, 2025 12:31
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@alexreal1314 alexreal1314 changed the title 12165 update UI implementation of CVE [Cloud Security ] 12165 update UI handling of multiple CVEs and package fields Mar 31, 2025
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch from 8c8be35 to 204fc04 Compare April 1, 2025 13:01
@alexreal1314 alexreal1314 added the ci:cloud-redeploy Always create a new Cloud deployment label Apr 1, 2025
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch from 204fc04 to c2c7528 Compare April 1, 2025 13:17
@alexreal1314 alexreal1314 removed the request for review from a team April 1, 2025 13:17
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch 2 times, most recently from d49e639 to 3060d38 Compare April 2, 2025 12:19
@opauloh opauloh self-requested a review April 3, 2025 06:03
Copy link
Copy Markdown
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

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

some minor comments, mainly around namings, but i do think its important in this case.

onMouseLeave={handleMouseLeave}
css={css`
position: fixed;
z-index: 9000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use z index from euiTheme

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use z index from euiTheme

Yes, z-index levels can be tricky to maintain. As an example, if everyone were using arbitrary values, Kibana could end up with several components overriding each other, so ideally, we should use the appropriate levels token according to the context where it's being rendered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, could you consider taking a look at EuiPortal instead of createPortal to see if it works for us? It seems to work by relying on using natural order where it adds the element of the portal on the end of the page, so it leverages natural z-index stacking, and then we (hopefully) wouldn't even need to worry about z-index

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JordanSh @opauloh updated z-index to use euiTheme.levels.modal instead. regarding EuiPortal, I tried to use it originally but it didn't render properly. Maybe I'll do some research separately to understand what is the difference.

{ id: VULNERABILITY_FIELDS.VULNERABILITY_ID, width: 130 },
{ id: VULNERABILITY_FIELDS.SCORE_BASE, width: 80 },
{ id: VULNERABILITY_FIELDS.VULNERABILITY_TITLE, width: 160 },
{ id: VULNERABILITY_FIELDS.VULNERABILITY_ID, width: 180 },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a small ux improvement could be that regardless of the columns width, the expand badge should always show. meaning the text should truncate to fit the column's width including the expand badge. it shouldn't be too complicated but if that turns out to be so, its not a must

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JordanSh you mean the expand badge which is the first column or the cve column badge?

const { setUrlQuery } = useUrlQuery<URLQuery>(getPersistedDefaultQuery);

const onAddFilter = useCallback(
(clickedField: string, values: string | string[], operation: '+' | '-') => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i suggest to use 'add-filter' 'remove-filter' instead of +-
also, im not sure but i think we already have a hook that does that, or maybe it was removed when we changed to the UnifiedDataTable? @opauloh do you know?

Copy link
Copy Markdown
Contributor Author

@alexreal1314 alexreal1314 Apr 6, 2025

Choose a reason for hiding this comment

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

@JordanSh I'm using filterManager which is what is used in other places, and since it accepts '+' or '-' types I don't see the reason to create another type and then map it to this type.
const onAddFilter = useCallback<AddFieldFilterHandler>( (clickedField, value, operation) => { const newFilters = generateFilters(filterManager, clickedField, value, operation, dataView); filterManager.addFilters(newFilters); setUrlQuery({ filters: filterManager.getFilters(), }); }, [dataView, filterManager, setUrlQuery] );

export type AddFieldFilterHandler = ( field: string, value: unknown, type: '+' | '-' ) => void;

);

const renderItem = useCallback(
(item: string, i: number, field: string, object: CspVulnerabilityFinding) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

kind of a nit pick since its only within this function's scope but i would suggest not to use generic names like 'object', you could call this a finding or a document, it makes the rest of the code easier to read

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JordanSh Its not necessarily a finding or a document it could be any json. Regarding the naming I changed the function name to better represent what we are rendering when passing it as a param but the 'object' name should remain because the signature of the callback function is:
interface MultiValueCellPopoverProps<T, K = string> { items: K[]; field: string; object: T; renderItem: (item: K, i: number, field: string, object: T) => React.ReactNode; firstItemRenderer?: (item: K) => React.ReactNode; }

Copy link
Copy Markdown
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

I added a few comments and suggestions, but overall, it's a great job 💯

onMouseLeave={handleMouseLeave}
css={css`
position: fixed;
z-index: 9000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use z index from euiTheme

Yes, z-index levels can be tricky to maintain. As an example, if everyone were using arbitrary values, Kibana could end up with several components overriding each other, so ideally, we should use the appropriate levels token according to the context where it's being rendered.

onMouseLeave={handleMouseLeave}
css={css`
position: fixed;
z-index: 9000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, could you consider taking a look at EuiPortal instead of createPortal to see if it works for us? It seems to work by relying on using natural order where it adds the element of the portal on the end of the page, so it leverages natural z-index stacking, and then we (hopefully) wouldn't even need to worry about z-index

firstItemRenderer?: (item: K) => React.ReactNode;
}

const MultiValueCellPopoverComponent = <T, K = string>({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the proposal makes sense, as it aims on flexbility and reusability

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner April 6, 2025 09:33
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch 2 times, most recently from 3aa0c21 to dd1c48a Compare April 6, 2025 13:34
@alexreal1314 alexreal1314 removed the request for review from a team April 6, 2025 13:34
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch from 49a1168 to a7f6056 Compare April 7, 2025 07:09
@alexreal1314 alexreal1314 force-pushed the 12165-update-ui-implementation-of-cve branch from a7f6056 to 0c071c3 Compare April 7, 2025 07:09
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 7, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #115 / X-Pack Accessibility Tests - Group 1 Kibana Home Accessibility Observability overview page meets a11y requirements

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloudSecurityPosture 693 697 +4
securitySolution 7184 7190 +6
total +10

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/cloud-security-posture 108 119 +11

Async chunks

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

id before after diff
cloudSecurityPosture 513.1KB 519.5KB +6.5KB
securitySolution 8.9MB 8.9MB +3.9KB
total +10.3KB
Unknown metric groups

API count

id before after diff
@kbn/cloud-security-posture 108 120 +12

History

@alexreal1314 alexreal1314 added ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment and removed ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment labels Apr 7, 2025
Copy link
Copy Markdown
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for addressing the suggestions!

@alexreal1314 alexreal1314 merged commit 854bfc4 into main Apr 8, 2025
15 checks passed
@alexreal1314 alexreal1314 deleted the 12165-update-ui-implementation-of-cve branch April 8, 2025 07:22
maxcold added a commit that referenced this pull request May 27, 2025
…1302)

## Summary

This PR backports changes related to Qualys VMDR added integration
support that were merged to version 9.1.0.

PRs backported:

- #213039
- #216411


### Identify risks

Thorough sanity check need to be made before merging since a lot of
conflicts were fixed manually.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maxim Kholod <maxim.kholod@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment release_note:enhancement Team:Cloud Security Cloud Security team related v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants