-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
kibana-cloud-security-posture owned UX udjustment for borealis #205136
base: main
Are you sure you want to change the base?
Changes from all commits
7fdda71
76c495a
0461c8d
081b0fb
534662a
73e762f
324d4b2
58f7c58
4dc1687
723fc89
4da5c31
d058d36
4331c44
23123f0
a9fcb94
55f8ab4
693d6f4
5405bd1
42816c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiThemeComputed } from '@elastic/eui'; | ||
import { euiThemeVars } from '@kbn/ui-theme'; // TODO: replace with euiTheme | ||
import type { VulnSeverity } from '@kbn/cloud-security-posture-common'; | ||
import { | ||
VULNERABILITIES_SEVERITY, | ||
MISCONFIGURATION_STATUS, | ||
} from '@kbn/cloud-security-posture-common'; | ||
|
||
const isBorealis = (euiThemeName: string) => { | ||
return euiThemeName?.toLowerCase().includes('borealis'); | ||
}; | ||
|
||
const isAmsterdam = (euiThemeName: string) => { | ||
return euiThemeName?.toLowerCase().includes('amsterdam'); | ||
}; | ||
|
||
// TODO: replace with severity color palette | ||
// TODO: replace with euiTheme.colors.vis.* from useEuiTheme hook | ||
// TODO: replace #aaa with proper color token | ||
export const getSeverityStatusColor = ( | ||
severity: VulnSeverity, | ||
euiTheme: EuiThemeComputed | ||
): string => { | ||
// TOOD: remove old mapping when severity palette is fixed (atm it is inverted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should be able to just use the new severity color palette for both Amsterdam and Borealis, but currently there is a bug in elastic/eui#8247 that the severity colors for Amsterdam are inverted. Keeping the old mapping until the severity color palette is fixed |
||
if (euiTheme && isAmsterdam(euiTheme.themeName)) { | ||
switch (severity) { | ||
case VULNERABILITIES_SEVERITY.LOW: | ||
return euiThemeVars.euiColorVis0; | ||
case VULNERABILITIES_SEVERITY.MEDIUM: | ||
return euiThemeVars.euiColorVis5_behindText; | ||
case VULNERABILITIES_SEVERITY.HIGH: | ||
return euiThemeVars.euiColorVis9_behindText; | ||
case VULNERABILITIES_SEVERITY.CRITICAL: | ||
return euiThemeVars.euiColorDanger; | ||
default: | ||
return '#aaa'; | ||
} | ||
} | ||
|
||
switch (severity) { | ||
case VULNERABILITIES_SEVERITY.LOW: | ||
return euiTheme.colors.vis.euiColorVis0; // TODO: use color from the severity palette? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. severity paletter introduced in elastic/eui#8247 is missing green color which is used for low severity alerts and vulnerabilities. There is a discussion between EUI team and security designers on how to go about it. The workaround is to use |
||
case VULNERABILITIES_SEVERITY.MEDIUM: | ||
return euiTheme.colors.vis.euiColorSeverity7; | ||
case VULNERABILITIES_SEVERITY.HIGH: | ||
return euiTheme.colors.vis.euiColorSeverity11; | ||
case VULNERABILITIES_SEVERITY.CRITICAL: | ||
return euiTheme.colors.vis.euiColorSeverity14; | ||
default: | ||
return euiTheme.colors.vis.euiColorSeverity0; | ||
} | ||
}; | ||
|
||
// TODO: replace with severity color palette | ||
// TODO: replace with euiTheme.colors.vis.* from useEuiTheme hook | ||
export const getCvsScoreColor = (score: number, euiTheme: EuiThemeComputed): string | undefined => { | ||
// TOOD: remove old mapping when severity palette is fixed (atm it is inverted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as for |
||
if (euiTheme && isAmsterdam(euiTheme.themeName)) { | ||
if (score <= 4) { | ||
return euiThemeVars.euiColorVis0; // low severity | ||
} else if (score >= 4 && score <= 7) { | ||
return euiThemeVars.euiColorVis7; // medium severity | ||
} else if (score >= 7 && score <= 9) { | ||
return euiThemeVars.euiColorVis9; // high severity | ||
} else if (score >= 9) { | ||
return euiThemeVars.euiColorDanger; // critical severity | ||
} | ||
} | ||
|
||
if (score <= 4) { | ||
return getSeverityStatusColor(VULNERABILITIES_SEVERITY.LOW, euiTheme); | ||
} else if (score >= 4 && score <= 7) { | ||
return getSeverityStatusColor(VULNERABILITIES_SEVERITY.MEDIUM, euiTheme); | ||
} else if (score >= 7 && score <= 9) { | ||
return getSeverityStatusColor(VULNERABILITIES_SEVERITY.HIGH, euiTheme); | ||
} else if (score >= 9) { | ||
return getSeverityStatusColor(VULNERABILITIES_SEVERITY.CRITICAL, euiTheme); | ||
} else { | ||
return getSeverityStatusColor(VULNERABILITIES_SEVERITY.UNKNOWN, euiTheme); | ||
} | ||
}; | ||
|
||
export const getMisconfigurationStatusColor = ( | ||
status: 'passed' | 'failed' | 'unknown', | ||
euiTheme: EuiThemeComputed | ||
): string => { | ||
switch (status) { | ||
case MISCONFIGURATION_STATUS.PASSED: | ||
return euiTheme.colors.success; | ||
case MISCONFIGURATION_STATUS.FAILED: | ||
return euiTheme.colors.danger; | ||
case MISCONFIGURATION_STATUS.UNKNOWN: | ||
default: | ||
return euiTheme.colors.vis.euiColorSeverity0; | ||
} | ||
}; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these todos should go away when we use only the severity palette for both themes