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

kibana-cloud-security-posture owned UX adjustment for borealis #205136

Merged
merged 50 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7fdda71
review the use of success colors
maxcold Dec 19, 2024
76c495a
mark euiColorVis usage with TODOs
maxcold Dec 19, 2024
0461c8d
add todo for replacing hardcoded color
maxcold Dec 19, 2024
081b0fb
update comments
maxcold Dec 23, 2024
534662a
add TODO regarding discontinue of euiThemeVars
maxcold Dec 23, 2024
73e762f
Merge branch 'main' into csp-update-to-borealis
maxcold Dec 24, 2024
324d4b2
implement vuln severity color utils for borealis
maxcold Dec 24, 2024
58f7c58
replace border color with color token for cvss badge
maxcold Dec 27, 2024
4dc1687
replace misconfig colors with color tokens from euiTheme
maxcold Dec 27, 2024
723fc89
remove euiPaletteColorBlindBehindText usage from cloud_defend
maxcold Dec 27, 2024
4da5c31
replace euiThemeVars for nvd logo
maxcold Dec 27, 2024
d058d36
replace euiThemeVars with euiTheme in findings flyout
maxcold Dec 27, 2024
4331c44
replace EuiThemeVars with euiTheme in vulnerability flyout
maxcold Dec 27, 2024
23123f0
replace euiThemeVars in vulnerability overview tab
maxcold Dec 27, 2024
a9fcb94
replace euiThemeVars in k8s_security routes
maxcold Dec 27, 2024
55f8ab4
replace euiThemeVars with euiTheme for misconfig details table
maxcold Dec 27, 2024
693d6f4
remove unused hook in session_view
maxcold Dec 27, 2024
5405bd1
replace vis colors with color tokens for tree node buttons
maxcold Dec 27, 2024
42816c6
use matching color from Borealis for tty control markers
maxcold Dec 27, 2024
1d4635e
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 7, 2025
5aa0b99
clarify todos for vulnerability color palette
maxcold Jan 8, 2025
5d74600
use getMisconfigurationStatusColor utility function for misconfig det…
maxcold Jan 8, 2025
80e3202
create useMisconfigurationStatusColor hook and use instead of getMisc…
maxcold Jan 8, 2025
6d51d79
use useGetCvsScoreColor instead of getCvsScoreColor
maxcold Jan 8, 2025
8e91a02
introduce useGetSeverityStatusColor to avoid passing euiTheme around
maxcold Jan 8, 2025
b037cb8
fix eslint
maxcold Jan 8, 2025
860cbec
introduce MisconfigurationEvaluationStatus type
maxcold Jan 9, 2025
1559140
remove euiThemeVars from distribution bar stories
maxcold Jan 9, 2025
a360730
fix tests for get_findings_colors
maxcold Jan 9, 2025
f4e9eaa
rename get_finding_colors test file
maxcold Jan 9, 2025
d5dd00a
add clarifying comment
maxcold Jan 9, 2025
e036036
update todos for session_view
maxcold Jan 10, 2025
1ea43b1
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 10, 2025
2c23441
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 13, 2025
6c0b8d7
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine Jan 13, 2025
c904efa
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 13, 2025
2d511a6
fix linting errors
maxcold Jan 14, 2025
3886bc3
fix types
maxcold Jan 14, 2025
9740b3e
fix types
maxcold Jan 14, 2025
0f58306
hardcode colors for severity and failed/passed findings
maxcold Jan 16, 2025
591571f
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 16, 2025
cdb5557
fix test
maxcold Jan 17, 2025
bf8c679
remove unused color mocks
maxcold Jan 17, 2025
4c349ce
add severity palette ticket to todos
maxcold Jan 17, 2025
10b0525
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 17, 2025
31bf2c6
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 17, 2025
5703e77
Merge branch 'main' into csp-update-to-borealis
maxcold Jan 20, 2025
dd899e3
removed todos from k8s dashboard plugin to avoid conflicts with remov…
maxcold Jan 20, 2025
87fa9b3
revert changes in k8s dashboard plugin as it is being removed from Ki…
maxcold Jan 20, 2025
834501a
cr comments
maxcold Jan 20, 2025
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 @@ -5,6 +5,7 @@
* 2.0.
*/
import { VulnSeverity } from './types/vulnerabilities';
import { MisconfigurationEvaluationStatus } from './types/misconfigurations';

export const KSPM_POLICY_TEMPLATE = 'kspm';
export const CSPM_POLICY_TEMPLATE = 'cspm';
Expand Down Expand Up @@ -48,7 +49,8 @@ export const VULNERABILITIES_SEVERITY: Record<VulnSeverity, VulnSeverity> = {
UNKNOWN: 'UNKNOWN',
};

export const MISCONFIGURATION_STATUS: Record<string, string> = {
export const MISCONFIGURATION_STATUS: Record<string, MisconfigurationEvaluationStatus> = {
PASSED: 'passed',
FAILED: 'failed',
UNKNOWN: 'unknown',
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type {
} from './schema/vulnerabilities/csp_vulnerability_finding';
export type { BenchmarksCisId } from './types/benchmark';
export type { VulnSeverity } from './types/vulnerabilities';
export type { MisconfigurationEvaluationStatus } from './types/misconfigurations';
export * from './constants';
export {
extractErrorMessage,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export type MisconfigurationEvaluationStatus = 'passed' | 'failed' | 'unknown';
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
* 2.0.
*/
import React from 'react';
import { euiThemeVars } from '@kbn/ui-theme';
import { EuiTitle, EuiSpacer } from '@elastic/eui';
import { DistributionBar as DistributionBarComponent } from '..';

const mockStatsFindings = [
{
key: 'passed',
count: 90,
color: euiThemeVars.euiColorVis0,
color: 'green',
maxcold marked this conversation as resolved.
Show resolved Hide resolved
label: 'Passed',
},
{
key: 'failed',
count: 10,
color: euiThemeVars.euiColorVis9,
color: 'red',
label: <>{'Failed'}</>,
},
];
Expand All @@ -28,22 +27,22 @@ const mockStatsAlerts = [
{
key: 'low',
count: 1000,
color: euiThemeVars.euiColorVis0,
color: 'green',
},
{
key: 'medium',
count: 800,
color: euiThemeVars.euiColorVis5,
color: '#f7dc6f',
Copy link
Contributor

Choose a reason for hiding this comment

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

my ocd: yellow / gold / lemonchiffon / lightgoldenrodyellow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gold it is then :)

},
{
key: 'high',
count: 300,
color: euiThemeVars.euiColorVis7,
color: 'orange',
},
{
key: 'critical',
count: 50,
color: euiThemeVars.euiColorVis9,
color: 'red',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"include": ["**/*.ts", "**/*.tsx"],
"kbn_references": [
"@kbn/ui-theme",
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
*/

export * from './src/types';
export * from './src/constants/component_constants';
export * from './src/constants/navigation';
export type { NavFilter } from './src/utils/query_utils';
export { showErrorToast } from './src/utils/show_error_toast';
export { encodeQuery, decodeQuery } from './src/utils/query_utils';
export { CspEvaluationBadge } from './src/components/csp_evaluation_badge';
export { getSeverityStatusColor, getCvsScoreColor } from './src/utils/get_vulnerability_colors';
export {
getSeverityStatusColor,
getCvsScoreColor,
getMisconfigurationStatusColor,
} from './src/utils/get_finding_colors';
export { getSeverityText } from './src/utils/get_vulnerability_text';
export { getVulnerabilityStats, hasVulnerabilitiesData } from './src/utils/vulnerability_helpers';
export { CVSScoreBadge, SeverityStatusBadge } from './src/components/vulnerability_badges';
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,37 @@
*/

import React from 'react';
import { EuiBadge, type EuiBadgeProps } from '@elastic/eui';
import { EuiBadge } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { statusColors } from '../constants/component_constants';
import { MISCONFIGURATION_STATUS } from '@kbn/cloud-security-posture-common';
import type { MisconfigurationEvaluationStatus } from '@kbn/cloud-security-posture-common';
import { getMisconfigurationStatusColor } from '../utils/get_finding_colors';

interface Props {
type?: 'passed' | 'failed';
type?: MisconfigurationEvaluationStatus;
}

// 'fail' / 'pass' are same chars length, but not same width size.
// 46px is used to make sure the badge is always the same width.
const BADGE_WIDTH = '46px';

const getColor = (type: Props['type']): EuiBadgeProps['color'] => {
if (type === 'passed') return statusColors.passed;
if (type === 'failed') return statusColors.failed;
return 'default';
};

export const CspEvaluationBadge = ({ type }: Props) => (
<EuiBadge
color={getColor(type)}
color={getMisconfigurationStatusColor(type)}
css={css`
width: ${BADGE_WIDTH};
display: flex;
justify-content: center;
`}
data-test-subj={`${type}_finding`}
>
{type === 'failed' ? (
{type === MISCONFIGURATION_STATUS.FAILED ? (
<FormattedMessage
id="securitySolutionPackages.csp.cspEvaluationBadge.failLabel"
defaultMessage="Fail"
/>
) : type === 'passed' ? (
) : type === MISCONFIGURATION_STATUS.PASSED ? (
<FormattedMessage
id="securitySolutionPackages.csp.cspEvaluationBadge.passLabel"
defaultMessage="Pass"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
* 2.0.
*/

import { EuiBadge, EuiIcon, EuiTextColor } from '@elastic/eui';
import { EuiBadge, EuiIcon, EuiTextColor, useEuiTheme } from '@elastic/eui';
import React from 'react';
import { css } from '@emotion/react';
import { float } from '@elastic/elasticsearch/lib/api/types';
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
import { getCvsScoreColor, getSeverityStatusColor } from '../utils/get_vulnerability_colors';
import { useGetCvsScoreColor } from '../hooks/use_get_cvs_score_color';
import { useGetSeverityStatusColor } from '../hooks/use_get_severity_status_color';

const VULNERABILITIES_CVSS_SCORE_BADGE_SUBJ = 'vulnerabilities_cvss_score_badge';

Expand All @@ -24,6 +25,9 @@ interface SeverityStatusBadgeProps {
}

export const CVSScoreBadge = ({ score, version }: CVSScoreBadgeProps) => {
const { euiTheme } = useEuiTheme();
const { getCvsScoreColor } = useGetCvsScoreColor();

if (!score) return null;

const color = getCvsScoreColor(score);
Expand All @@ -48,7 +52,7 @@ export const CVSScoreBadge = ({ score, version }: CVSScoreBadgeProps) => {
css={css`
width: 1px;
border: 0 none;
background-color: rgba(255, 255, 255, 0.2);
background-color: ${euiTheme.border.color};
margin: 0px 6px;
`}
/>
Expand All @@ -60,6 +64,8 @@ export const CVSScoreBadge = ({ score, version }: CVSScoreBadgeProps) => {
};

export const SeverityStatusBadge = ({ severity }: SeverityStatusBadgeProps) => {
const { getSeverityStatusColor } = useGetSeverityStatusColor();

if (!severity) return null;
const color = getSeverityStatusColor(severity);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 { useEuiTheme } from '@elastic/eui';

import { getCvsScoreColor as getCvsScoreColorUtil } from '../..';

export const useGetCvsScoreColor = () => {
const { euiTheme } = useEuiTheme();

const getCvsScoreColor = (score: number) => {
return getCvsScoreColorUtil(score, euiTheme);
};

return { getCvsScoreColor };
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 { useEuiTheme } from '@elastic/eui';
import { VulnSeverity } from '@kbn/cloud-security-posture-common';

import { getSeverityStatusColor as getSeverityStatusColorUtil } from '../..';

export const useGetSeverityStatusColor = () => {
const { euiTheme } = useEuiTheme();
const getSeverityStatusColor = (status: VulnSeverity) => {
return getSeverityStatusColorUtil(status, euiTheme);
};
return { getSeverityStatusColor };
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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 { getCvsScoreColor, getSeverityStatusColor, SEVERITY_COLOR } from './get_finding_colors';
import { EuiThemeComputed } from '@elastic/eui';

const mockEuiThemeBorealis = {
themeName: 'borialis',
};

describe('getSeverityStatusColor', () => {
it('should return the correct color for LOW severity', () => {
expect(getSeverityStatusColor('LOW', mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.low
);
});

it('should return the correct color for MEDIUM severity', () => {
expect(getSeverityStatusColor('MEDIUM', mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.medium
);
});

it('should return the correct color for HIGH severity', () => {
expect(getSeverityStatusColor('HIGH', mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.high
);
});

it('should return the correct color for CRITICAL severity', () => {
expect(getSeverityStatusColor('CRITICAL', mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.critical
);
});

it('should return the correct color for an unknown severity', () => {
expect(getSeverityStatusColor('UNKNOWN', mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.unknown
);
});
});

describe('getCvsScoreColor', () => {
it('returns correct color for low severity score', () => {
expect(getCvsScoreColor(1.5, mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.low
);
});

it('returns correct color for medium severity score', () => {
expect(getCvsScoreColor(5.5, mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.medium
);
});

it('returns correct color for high severity score', () => {
expect(getCvsScoreColor(7.9, mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.high
);
});

it('returns correct color for critical severity score', () => {
expect(getCvsScoreColor(10.0, mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.critical
);
});

it('returns correct color for low severity score for undefined value', () => {
expect(getCvsScoreColor(-0.2, mockEuiThemeBorealis as EuiThemeComputed)).toBe(
SEVERITY_COLOR.unknown
);
});
});
Loading