diff --git a/frontend/client/src/app/api/model-utils.ts b/frontend/client/src/app/api/model-utils.ts index 32d0b1da2..60f881ab9 100644 --- a/frontend/client/src/app/api/model-utils.ts +++ b/frontend/client/src/app/api/model-utils.ts @@ -5,9 +5,10 @@ import { global_warning_color_100 as moderateColor, } from "@patternfly/react-tokens"; -import { Severity } from "./models"; import { ProgressProps } from "@patternfly/react-core"; +import { Severity } from "./models"; + type ListType = { [key in Severity]: { shieldIconColor: { name: string; value: string; var: string }; @@ -33,15 +34,3 @@ export const severityList: ListType = { progressProps: { variant: "danger" }, }, }; - -export const severityFromNumber = (score: number): Severity => { - if (score >= 9.0) { - return "critical"; - } else if (score >= 7.0) { - return "important"; - } else if (score >= 4.0) { - return "moderate"; - } else { - return "low"; - } -}; diff --git a/frontend/client/src/app/api/models.ts b/frontend/client/src/app/api/models.ts index 86af5f558..f142d048c 100644 --- a/frontend/client/src/app/api/models.ts +++ b/frontend/client/src/app/api/models.ts @@ -70,6 +70,6 @@ export interface AdvisoryVulnerability { title: string; discovery_date: string; release_date: string; - score: number; + severity: Severity; cwe: string; } diff --git a/frontend/client/src/app/components/SeverityProgressBar.tsx b/frontend/client/src/app/components/SeverityProgressBar.tsx deleted file mode 100644 index 8c31ce024..000000000 --- a/frontend/client/src/app/components/SeverityProgressBar.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; - -import { Progress } from "@patternfly/react-core"; - -import { severityFromNumber, severityList } from "@app/api/model-utils"; - -interface SeverityRendererProps { - value: number; - showLabel?: boolean; -} - -export const SeverityProgressBar: React.FC = ({ - value, -}) => { - const severityType = severityFromNumber(value); - const severityProps = severityList[severityType]; - - return ( - <> - - - ); -}; diff --git a/frontend/client/src/app/components/SeverityShieldAndText.tsx b/frontend/client/src/app/components/SeverityShieldAndText.tsx index ed2332ea3..576c203cf 100644 --- a/frontend/client/src/app/components/SeverityShieldAndText.tsx +++ b/frontend/client/src/app/components/SeverityShieldAndText.tsx @@ -3,44 +3,33 @@ import React from "react"; import { Flex, FlexItem } from "@patternfly/react-core"; import ShieldIcon from "@patternfly/react-icons/dist/esm/icons/shield-alt-icon"; -import { severityFromNumber, severityList } from "@app/api/model-utils"; +import { severityList } from "@app/api/model-utils"; import { Severity } from "@app/api/models"; interface SeverityShieldAndTextProps { - value: Severity | number; - showLabel?: boolean; + value: Severity; + hideLabel?: boolean; } export const SeverityShieldAndText: React.FC = ({ value, - showLabel, + hideLabel, }) => { - let severity: Severity; - if (typeof value === "number") { - severity = severityFromNumber(value); - } else { - severity = value; - } - - const severityProps = severityList[severity]; + const severityProps = severityList[value]; return ( - <> - - - - - {showLabel && ( - - {severity.charAt(0).toUpperCase() + severity.slice(1)} - - )} - - + + + + + {!hideLabel && ( + {value.charAt(0).toUpperCase() + value.slice(1)} + )} + ); }; diff --git a/frontend/client/src/app/pages/advisory-details/advisory-details.tsx b/frontend/client/src/app/pages/advisory-details/advisory-details.tsx index 7020c0f2c..888149751 100644 --- a/frontend/client/src/app/pages/advisory-details/advisory-details.tsx +++ b/frontend/client/src/app/pages/advisory-details/advisory-details.tsx @@ -55,7 +55,6 @@ export const AdvisoryDetails: React.FC = () => { children: ( ), isCompact: true, diff --git a/frontend/client/src/app/pages/advisory-details/overview.tsx b/frontend/client/src/app/pages/advisory-details/overview.tsx index 84b12f125..4e30e9098 100644 --- a/frontend/client/src/app/pages/advisory-details/overview.tsx +++ b/frontend/client/src/app/pages/advisory-details/overview.tsx @@ -57,7 +57,6 @@ export const Overview: React.FC = ({ advisory }) => { @@ -156,17 +155,10 @@ export const Overview: React.FC = ({ advisory }) => { - {/* + Product info - - - - */} + Remaining to be defined + diff --git a/frontend/client/src/app/pages/advisory-details/source.tsx b/frontend/client/src/app/pages/advisory-details/source.tsx index 1fd6df0c6..f5b39a7db 100644 --- a/frontend/client/src/app/pages/advisory-details/source.tsx +++ b/frontend/client/src/app/pages/advisory-details/source.tsx @@ -20,7 +20,6 @@ export const Source: React.FC = ({ advisoryId }) => { isLineNumbersVisible isReadOnly isMinimapVisible - // isLanguageLabelVisible code={source ?? ""} language={Language.json} height="685px" diff --git a/frontend/client/src/app/pages/advisory-details/vulnerabilities.tsx b/frontend/client/src/app/pages/advisory-details/vulnerabilities.tsx index 0216fbfa7..e596c4cf2 100644 --- a/frontend/client/src/app/pages/advisory-details/vulnerabilities.tsx +++ b/frontend/client/src/app/pages/advisory-details/vulnerabilities.tsx @@ -12,12 +12,12 @@ import dayjs from "dayjs"; import { RENDER_DATE_FORMAT } from "@app/Constants"; import { AdvisoryVulnerability } from "@app/api/models"; +import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText"; import { ConditionalTableBody, FilterType, useClientTableBatteries, } from "@carlosthe19916-latest/react-table-batteries"; -import { SeverityProgressBar } from "@app/components/SeverityProgressBar"; interface VulnerabilitiesProps { vulnerabilities: AdvisoryVulnerability[]; @@ -35,7 +35,7 @@ export const Vulnerabilities: React.FC = ({ title: "Title", discovery: "Discovery", release: "Release", - score: "Score", + severity: "Severity", cwe: "CWE", }, hasActionsColumn: true, @@ -110,7 +110,7 @@ export const Vulnerabilities: React.FC = ({ - + @@ -136,8 +136,8 @@ export const Vulnerabilities: React.FC = ({ {dayjs(item.release_date).format(RENDER_DATE_FORMAT)} - - + + {item.cwe} diff --git a/frontend/client/src/app/pages/advisory-list/components/VulnerabilitiesCount.tsx b/frontend/client/src/app/pages/advisory-list/components/VulnerabilitiesCount.tsx index d7f5ffc8f..8bd2bb963 100644 --- a/frontend/client/src/app/pages/advisory-list/components/VulnerabilitiesCount.tsx +++ b/frontend/client/src/app/pages/advisory-list/components/VulnerabilitiesCount.tsx @@ -39,7 +39,10 @@ export const VulnerabilitiesCount: React.FC = ({ style={{ whiteSpace: "nowrap" }} > - + {count} diff --git a/frontend/client/src/app/pages/advisory-list/useAdvisoryList.tsx b/frontend/client/src/app/pages/advisory-list/useAdvisoryList.tsx index 8484fa485..898647eb8 100644 --- a/frontend/client/src/app/pages/advisory-list/useAdvisoryList.tsx +++ b/frontend/client/src/app/pages/advisory-list/useAdvisoryList.tsx @@ -134,10 +134,7 @@ export const useAdvisoryList = () => { {item.metadata.title} - + {dayjs(item.revision_date).format(RENDER_DATE_FORMAT)} diff --git a/frontend/client/src/mocks/stub-new-work/advisories.ts b/frontend/client/src/mocks/stub-new-work/advisories.ts index 78d5321a9..02e5532e8 100644 --- a/frontend/client/src/mocks/stub-new-work/advisories.ts +++ b/frontend/client/src/mocks/stub-new-work/advisories.ts @@ -37,7 +37,7 @@ export const mockProjectArray: Advisory[] = [ title: "title1", discovery_date: new Date().toString(), release_date: new Date().toString(), - score: 7.5, + severity: "critical", cwe: "cwe1", }, ], @@ -58,7 +58,11 @@ export const handlers = [ } }), rest.get(`${AppRest.ADVISORIES}/:id/source`, (req, res, ctx) => { - return res(ctx.json("{}")); + return res( + ctx.json( + "This is Mock data, but the real API should return the advisory JSON file" + ) + ); }), ];