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

Fix vuln flyout when score is zero #196092

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const VulnerabilityOverviewTiles = ({ vulnerabilityRecord }: VulnerabilityTabPro

return (
<EuiFlexGroup data-test-subj={OVERVIEW_TAB_VULNERABILITY_FLYOUT}>
Copy link
Contributor Author

@CohenIdo CohenIdo Oct 14, 2024

Choose a reason for hiding this comment

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

The issue arises because JavaScript treats 0 as a falsy value, but in the case of this condition, the vulnerability?.score?.base && vulnerability.score.base !== 0 is evaluated separately. Since vulnerability?.score?.base returns 0 (falsy), the component still renders because it’s not stopping evaluation correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

why base is 0 in the first place? is wiz.vulnerability.score 0 when it's missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like 0 is a valid value. we just dont handle it and didnt expect it as such. ive talked with ido, for now i guess just ignore 0 and we will take this with @smriti-elastic

{vulnerability?.score?.base && (
{!!vulnerability?.score?.base && (
<EuiFlexItem css={tileStyle}>
<EuiText css={tileTitleTextStyle}>
<FormattedMessage
Expand Down