diff --git a/client/src/app/api/models.ts b/client/src/app/api/models.ts index 32ba5eb4..3b75b03a 100644 --- a/client/src/app/api/models.ts +++ b/client/src/app/api/models.ts @@ -35,8 +35,8 @@ export interface HubPaginatedResult { // Base -export interface CVEBase { - id: string; +export interface VulnerabilityBase { + vulnerability_id: string; title: string; description: string; severity: Severity; @@ -67,10 +67,12 @@ export interface SBOMBase { } export interface AdvisoryBase { - id: string; + identifier: string; severity: Severity; + published: string; modified: string; title: string; + sha256: string; metadata: { category: string; publisher: { @@ -97,12 +99,12 @@ export interface AdvisoryBase { export type Severity = "low" | "moderate" | "important" | "critical"; export interface Advisory extends AdvisoryBase { - cves: CVEBase[]; + vulnerabilities: VulnerabilityBase[]; } // CVE -export interface CVE extends CVEBase { +export interface CVE extends VulnerabilityBase { related_sboms: SBOMBase[]; related_advisories: AdvisoryBase[]; } @@ -110,7 +112,7 @@ export interface CVE extends CVEBase { // Package export interface Package extends PackageBase { - related_cves: CVEBase[]; + related_cves: VulnerabilityBase[]; related_sboms: SBOMBase[]; } diff --git a/client/src/app/api/rest.ts b/client/src/app/api/rest.ts index e937589b..1e24e511 100644 --- a/client/src/app/api/rest.ts +++ b/client/src/app/api/rest.ts @@ -15,8 +15,7 @@ import { const API = "/api"; -export const ADVISORIES = API + "/advisories"; -export const ADVISORIES_SEARCH = API + "/v1/search/advisory"; +export const ADVISORIES = API + "/v1/advisory"; export const CVES = API + "/cves"; export const SBOMS = API + "/sboms"; export const PACKAGES = API + "/packages"; @@ -44,7 +43,7 @@ export const getHubPaginatedResult = ( // export const getAdvisories = (params: HubRequestParams = {}) => { - return getHubPaginatedResult(ADVISORIES_SEARCH, params); + return getHubPaginatedResult(ADVISORIES, params); }; export const getAdvisoryById = (id: number | string) => { diff --git a/client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts b/client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts index 7cd421ff..e536f23b 100644 --- a/client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts +++ b/client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts @@ -162,13 +162,16 @@ export const serializeFilterForHub = (filter: HubFilter): string => { const { field, operator, value } = filter; const joinedValue = typeof value === "string" - ? wrapInQuotesAndEscape(value) + ? value : typeof value === "number" - ? `"${value}"` - : `(${value.list - .map(wrapInQuotesAndEscape) - .join(value.operator === "OR" ? "|" : ",")})`; - return `${field}${operator}${joinedValue}`; + ? `"${value}"` + : `(${value.list.join(value.operator === "OR" ? "|" : ",")})`; + + if (!field) { + return joinedValue; + } else { + return `${field}${operator}${joinedValue}`; + } }; /** @@ -183,9 +186,6 @@ export const serializeFilterRequestParamsForHub = ( ) => { const { filters } = deserializedParams; if (filters) { - serializedParams.append( - "filter", - filters.map(serializeFilterForHub).join(",") - ); + serializedParams.append("q", filters.map(serializeFilterForHub).join(",")); } }; diff --git a/client/src/app/hooks/table-controls/sorting/getSortHubRequestParams.ts b/client/src/app/hooks/table-controls/sorting/getSortHubRequestParams.ts index 155b053b..009a5e7f 100644 --- a/client/src/app/hooks/table-controls/sorting/getSortHubRequestParams.ts +++ b/client/src/app/hooks/table-controls/sorting/getSortHubRequestParams.ts @@ -51,6 +51,6 @@ export const serializeSortRequestParamsForHub = ( const { sort } = deserializedParams; if (sort) { const { field, direction } = sort; - serializedParams.append("sort", `${direction}:${field}`); + serializedParams.append("sort", `${field}:${direction}`); } }; diff --git a/client/src/app/pages/advisory-details/advisory-details.tsx b/client/src/app/pages/advisory-details/advisory-details.tsx index 8e210123..2fd428a8 100644 --- a/client/src/app/pages/advisory-details/advisory-details.tsx +++ b/client/src/app/pages/advisory-details/advisory-details.tsx @@ -1,39 +1,26 @@ import React from "react"; -import ReactMarkdown from "react-markdown"; import { Link } from "react-router-dom"; import { Breadcrumb, BreadcrumbItem, PageSection, - Stack, - StackItem, - TextContent, } from "@patternfly/react-core"; -import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; - import DetailsPage from "@patternfly/react-component-groups/dist/dynamic/DetailsPage"; -import DownloadIcon from "@patternfly/react-icons/dist/esm/icons/download-icon"; import { PathParam, useRouteParams } from "@app/Routes"; import { LoadingWrapper } from "@app/components/LoadingWrapper"; -import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText"; -import { markdownPFComponents } from "@app/components/markdownPFComponents"; -import { useDownload } from "@app/hooks/useDownload"; import { useFetchAdvisoryById } from "@app/queries/advisories"; import { Overview } from "./overview"; -import { Source } from "./source"; -import { CVEs } from "./cves"; +import { Vulnerabilities } from "./vulnerabilities"; export const AdvisoryDetails: React.FC = () => { const advisoryId = useRouteParams(PathParam.ADVISORY_ID); const { advisory, isFetching, fetchError } = useFetchAdvisoryById(advisoryId); - const { downloadAdvisory } = useDownload(); - return ( <> @@ -49,33 +36,18 @@ export const AdvisoryDetails: React.FC = () => { } pageHeading={{ - title: advisoryId ?? "", - label: advisory - ? { - children: ( - - ), - isCompact: true, - } - : undefined, + title: advisory?.identifier ?? "", + // label: advisory + // ? { + // children: ( + // + // ), + // isCompact: true, + // } + // : undefined, }} - actionButtons={[ - { - children: ( - <> - Download - - ), - onClick: () => { - if (advisoryId) { - downloadAdvisory(advisoryId); - } - }, - variant: "secondary", - }, - ]} tabs={[ { eventKey: "overview", @@ -92,52 +64,21 @@ export const AdvisoryDetails: React.FC = () => { ), }, { - eventKey: "notes", - title: "Notes", - children: ( -
- - - - {advisory?.metadata.notes.map((e, index) => ( - - - {e} - - - ))} - - - -
- ), - }, - { - eventKey: "cves", - title: "CVEs", + eventKey: "vulnerabilities", + title: "Vulnerabilities", children: (
- +
), }, - { - eventKey: "source", - title: "Source", - children: ( -
- {advisoryId && } -
- ), - }, ]} />
diff --git a/client/src/app/pages/advisory-details/overview.tsx b/client/src/app/pages/advisory-details/overview.tsx index 9729f9ff..aec43604 100644 --- a/client/src/app/pages/advisory-details/overview.tsx +++ b/client/src/app/pages/advisory-details/overview.tsx @@ -10,18 +10,14 @@ import { DescriptionListTerm, Grid, GridItem, - List, - ListItem, Stack, StackItem, } from "@patternfly/react-core"; -import ExternalLinkAltIcon from "@patternfly/react-icons/dist/esm/icons/external-link-alt-icon"; import dayjs from "dayjs"; -import { Advisory } from "@app/api/models"; import { RENDER_DATE_FORMAT } from "@app/Constants"; -import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText"; +import { Advisory } from "@app/api/models"; interface OverviewProps { advisory: Advisory; @@ -35,22 +31,34 @@ export const Overview: React.FC = ({ advisory }) => { - Overview + General view Title - {advisory.cves.map((e) => e.title)} + {advisory.title} - Category + Published - {advisory.metadata.category} + {dayjs(advisory.published).format(RENDER_DATE_FORMAT)} + Modified + + {dayjs(advisory.modified).format(RENDER_DATE_FORMAT)} + + + {/* + Category + + {advisory.metadata.category} + + */} + {/* Aggregate severity @@ -59,12 +67,12 @@ export const Overview: React.FC = ({ advisory }) => { value={advisory.severity} /> - + */} - + {/* Publisher @@ -98,8 +106,8 @@ export const Overview: React.FC = ({ advisory }) => { - - + */} + {/* Tracking @@ -133,10 +141,10 @@ export const Overview: React.FC = ({ advisory }) => { - + */} - + {/* @@ -161,7 +169,7 @@ export const Overview: React.FC = ({ advisory }) => { - + */} ); diff --git a/client/src/app/pages/advisory-details/cves.tsx b/client/src/app/pages/advisory-details/vulnerabilities.tsx similarity index 74% rename from client/src/app/pages/advisory-details/cves.tsx rename to client/src/app/pages/advisory-details/vulnerabilities.tsx index 997f9ed5..609ee8d0 100644 --- a/client/src/app/pages/advisory-details/cves.tsx +++ b/client/src/app/pages/advisory-details/vulnerabilities.tsx @@ -16,11 +16,8 @@ import { Tr, } from "@patternfly/react-table"; -import { RENDER_DATE_FORMAT } from "@app/Constants"; - -import { CVEBase } from "@app/api/models"; +import { VulnerabilityBase } from "@app/api/models"; import { FilterToolbar, FilterType } from "@app/components/FilterToolbar"; -import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText"; import { SimplePagination } from "@app/components/SimplePagination"; import { ConditionalTableBody, @@ -28,17 +25,19 @@ import { } from "@app/components/TableControls"; import { useLocalTableControls } from "@app/hooks/table-controls"; -interface CVEsProps { - cves: CVEBase[]; +interface VulnerabilitiesProps { + vulnerabilities: VulnerabilityBase[]; } -export const CVEs: React.FC = ({ cves }) => { +export const Vulnerabilities: React.FC = ({ + vulnerabilities, +}) => { const tableControls = useLocalTableControls({ tableName: "cves-table", - idProperty: "id", - items: cves, + idProperty: "vulnerability_id", + items: vulnerabilities, columnNames: { - cve: "CVE ID", + vulnerabilityId: "ID", title: "Title", discovery: "Discovery", release: "Release", @@ -47,9 +46,9 @@ export const CVEs: React.FC = ({ cves }) => { }, hasActionsColumn: true, isSortEnabled: true, - sortableColumns: ["cve", "discovery", "release"], + sortableColumns: ["vulnerabilityId", "discovery", "release"], getSortValues: (vuln) => ({ - cve: vuln?.id || "", + vulnerabilityId: vuln?.vulnerability_id || "", discovery: vuln ? dayjs(vuln.date_discovered).millisecond() : 0, release: vuln ? dayjs(vuln.date_released).millisecond() : 0, }), @@ -60,11 +59,11 @@ export const CVEs: React.FC = ({ cves }) => { isFilterEnabled: true, filterCategories: [ { - categoryKey: "cve", + categoryKey: "id", title: "ID", type: FilterType.search, placeholderText: "Search by ID...", - getItemValue: (item) => item.id || "", + getItemValue: (item) => item.vulnerability_id || "", }, ], }); @@ -92,7 +91,7 @@ export const CVEs: React.FC = ({ cves }) => { @@ -100,11 +99,11 @@ export const CVEs: React.FC = ({ cves }) => { - +
- + - {isCellExpanded(item) ? ( @@ -161,7 +165,7 @@ export const CVEs: React.FC = ({ cves }) => {
+ @@ -116,15 +115,20 @@ export const CVEs: React.FC = ({ cves }) => { {currentPageItems?.map((item, rowIndex) => { return ( -
- {item.id} + + + {item.vulnerability_id} + = ({ cves }) => { {item.title} - {dayjs(item.date_discovered).format(RENDER_DATE_FORMAT)} + {/* {dayjs(item.date_discovered).format(RENDER_DATE_FORMAT)} */} - {dayjs(item.date_released).format(RENDER_DATE_FORMAT)} + {/* {dayjs(item.date_released).format(RENDER_DATE_FORMAT)} */} - + {/* */} - {item.cwe} + {/* {item.cwe} */}
{ @@ -41,20 +51,20 @@ export const AdvisoryList: React.FC = () => { tableName: "advisories", persistenceKeyPrefix: TablePersistenceKeyPrefixes.advisories, columnNames: { - id: "ID", + identifier: "Identifier", title: "Title", - severity: "Aggregated severity", - revisionDate: "Revision", + severity: "Severity", + published: "Published", + modified: "Modified", cves: "CVEs", - download: "Download", }, + isPaginationEnabled: true, isSortEnabled: true, - sortableColumns: ["id"], - initialItemsPerPage: 10, + sortableColumns: ["identifier", "published", "modified"], isFilterEnabled: true, filterCategories: [ { - categoryKey: "filterText", + categoryKey: "", title: "Filter text", placeholderText: "Search", type: FilterType.search, @@ -69,18 +79,23 @@ export const AdvisoryList: React.FC = () => { } = useFetchAdvisories( getHubRequestParams({ ...tableControlState, + hubSortFieldKeys: { + identifier: "identifier", + published: "published", + modified: "modified", + }, }) ); const tableControls = useTableControlProps({ ...tableControlState, - idProperty: "id", + idProperty: "sha256", currentPageItems: advisories, totalItemCount, isLoading: isFetching, selectionState: useSelectionState({ items: advisories, - isEqual: (a, b) => a.id === b.id, + isEqual: (a, b) => a.identifier === b.identifier, }), }); @@ -120,12 +135,12 @@ export const AdvisoryList: React.FC = () => { @@ -142,12 +157,12 @@ export const AdvisoryList: React.FC = () => { - + - + + - @@ -159,11 +174,14 @@ export const AdvisoryList: React.FC = () => { > {currentPageItems.map((item) => { return ( - + - - - {item.id} + + + {item.identifier} { modifier="truncate" {...getTdProps({ columnKey: "severity" })} > - + /> */} - + {dayjs(item.published).format(RENDER_DATE_FORMAT)} - + {dayjs(item.modified).format(RENDER_DATE_FORMAT)} - + {/* */} + + + downloadAdvisory(item.identifier), + }, + ]} + /> diff --git a/client/src/app/pages/advisory-list/components/CVEsGaleryCount.tsx b/client/src/app/pages/advisory-list/components/CVEsGaleryCount.tsx index 96d84195..f74a9daa 100644 --- a/client/src/app/pages/advisory-list/components/CVEsGaleryCount.tsx +++ b/client/src/app/pages/advisory-list/components/CVEsGaleryCount.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { CVEBase, Severity } from "@app/api/models"; +import { VulnerabilityBase, Severity } from "@app/api/models"; import { CveGallery } from "@app/components/CveGallery"; type SeverityCount = { [key in Severity]: number }; @@ -12,7 +12,7 @@ const defaultSeverityCount: SeverityCount = { }; interface CVEsCountProps { - cves: CVEBase[]; + cves: VulnerabilityBase[]; } export const CVEGalleryCount: React.FC = ({ cves }) => { diff --git a/client/src/app/pages/advisory-list/components/UploadFilesDrawer.tsx b/client/src/app/pages/advisory-list/components/UploadFilesDrawer.tsx index de11ddfc..e4ad6ad2 100644 --- a/client/src/app/pages/advisory-list/components/UploadFilesDrawer.tsx +++ b/client/src/app/pages/advisory-list/components/UploadFilesDrawer.tsx @@ -160,7 +160,7 @@ export const UploadFilesDrawer: React.FC = ({ ) : upload.response ? ( - {`Document ${upload.response.data.id} uploaded`} + {`Document ${upload.response.data.identifier} uploaded`} ) : undefined diff --git a/client/src/app/pages/cve-details/related-advisories.tsx b/client/src/app/pages/cve-details/related-advisories.tsx index b606ea13..72f05b8a 100644 --- a/client/src/app/pages/cve-details/related-advisories.tsx +++ b/client/src/app/pages/cve-details/related-advisories.tsx @@ -25,7 +25,7 @@ export const RelatedAdvisories: React.FC = ({ }) => { const tableControls = useLocalTableControls({ tableName: "advisories-table", - idProperty: "id", + idProperty: "sha256", items: advisories, isLoading: false, columnNames: { @@ -93,9 +93,9 @@ export const RelatedAdvisories: React.FC = ({ {currentPageItems?.map((item, rowIndex) => { return ( - + - {item.id} + {item.identifier} { const tableControls = useTableControlProps({ ...tableControlState, - idProperty: "id", + idProperty: "vulnerability_id", currentPageItems: advisories, totalItemCount, isLoading: isFetching, selectionState: useSelectionState({ items: advisories, - isEqual: (a, b) => a.id === b.id, + isEqual: (a, b) => a.vulnerability_id === b.vulnerability_id, }), }); @@ -156,10 +156,10 @@ export const CveList: React.FC = () => { > {currentPageItems.map((item) => { return ( - + - {item.id} + {item.vulnerability_id} { + try { + return period ? parseInt(period.substring(0, period.length - 1)) : null; + } catch (e) { + return null; + } +}; + +const getPeriodUnit = (period?: string): PeriodUnitType | null => { + try { + return period + ? (period.substring(period.length - 1) as PeriodUnitType) + : null; + } catch (e) { + return null; + } +}; + +const ALL_PERIOD_UNITS = ["s", "m", "h", "d", "w", "M", "y"] as const; +type PeriodUnitType = (typeof ALL_PERIOD_UNITS)[number]; +type PeriodUnitProps = { + [key in PeriodUnitType]: { + label: string; + }; +}; +const PERIOD_UNIT_LIST: PeriodUnitProps = { + s: { label: "seconds" }, + m: { label: "minutes" }, + h: { label: "hours" }, + d: { label: "days" }, + w: { label: "weeks" }, + M: { label: "months" }, + y: { label: "years" }, +}; + +export const ALL_IMPORTER_TYPES = ["sbom", "csaf"] as const; +type ImporterType = (typeof ALL_IMPORTER_TYPES)[number]; + export interface FormValues { name: string; - type: "sbom" | "csaf"; + type: ImporterType; source: string; - period: string; + periodValue: number; + periodUnit: PeriodUnitType; + v3Signatures: boolean; + enabled: boolean; } export interface IImporterFormProps { @@ -47,14 +101,23 @@ export const ImporterForm: React.FC = ({ name: string().trim().required().min(3).max(120), type: string().trim().required().min(3).max(250), source: string().trim().required().min(3).max(250), - period: string().trim().required().min(3).max(250), + periodValue: number().required().min(1), + periodUnit: string().trim().required().max(250), + v3Signatures: boolean().required(), + enabled: boolean().required(), }); + const importerConfiguration = + importer?.configuration.sbom || importer?.configuration.csaf; + const periodValue = getPeriodValue(importerConfiguration?.period); + const periodUnit = getPeriodUnit(importerConfiguration?.period); + const { handleSubmit, formState: { isSubmitting, isValidating, isValid, isDirty }, - getValues, control, + setValue, + getValues, } = useForm({ defaultValues: { name: importer?.name || "", @@ -63,14 +126,19 @@ export const ImporterForm: React.FC = ({ : importer?.configuration.csaf ? "csaf" : "sbom", - source: - importer?.configuration.sbom?.source || - importer?.configuration.csaf?.source || - "", - period: - importer?.configuration.sbom?.period || - importer?.configuration.csaf?.period || - "60s", + source: importerConfiguration?.source || "", + periodValue: periodValue || 60, + periodUnit: periodUnit || "s", + v3Signatures: + importerConfiguration?.v3Signatures !== undefined && + importerConfiguration?.v3Signatures !== null + ? importerConfiguration?.v3Signatures + : false, + enabled: + importerConfiguration?.disabled !== undefined && + importerConfiguration?.disabled !== null + ? !importerConfiguration?.disabled + : true, }, resolver: yupResolver(validationSchema), mode: "onChange", @@ -89,7 +157,7 @@ export const ImporterForm: React.FC = ({ }); }; - const { mutate: createSource } = useCreateImporterMutation( + const { mutate: createImporter } = useCreateImporterMutation( onCreateSuccess, onCreateError ); @@ -112,80 +180,221 @@ export const ImporterForm: React.FC = ({ ); const onSubmit = (formValues: FormValues) => { + const configuration: ImporterConfigurationValues = { + ...importerConfiguration!, + source: formValues.source.trim(), + period: `${formValues.periodValue}${formValues.periodUnit.trim()}`, + v3Signatures: formValues.v3Signatures, + disabled: !formValues.enabled, + }; const payload: Importer = { name: formValues.name.trim(), configuration: { - [formValues.type]: { - source: formValues.source.trim(), - period: formValues.period.trim(), - }, + [formValues.type]: configuration, }, }; - if (importer) { updateImporter(payload); } else { - createSource(payload); + createImporter(payload); } onClose(); }; + const fillDemoSettings = () => { + if (getValues().type === "sbom") { + setValue("source", "https://access.redhat.com/security/data/sbom/beta/"); + setValue("v3Signatures", true); + } else if (getValues().type === "csaf") { + setValue( + "source", + "https://redhat.com/.well-known/csaf/provider-metadata.json" + ); + setValue("v3Signatures", true); + } + }; + return ( -
- - {["sbom", "csaf"].map((option, index) => ( - - ))} - - - - - - - - + + } + /> + } > - Cancel - - - + + + + + + ( + { + onChange(value - 1); + }} + onChange={onChange} + onPlus={() => { + onChange(value + 1); + }} + inputName="periodValue" + inputAriaLabel="period value" + minusBtnAriaLabel="minus" + plusBtnAriaLabel="plus" + /> + )} + /> + + + ( + + {ALL_PERIOD_UNITS.map((option, index) => ( + + ))} + + )} + /> + + + + + ( + + { + onChange(checked); + }} + /> + + + + + + + )} + /> + + + + + + + + ); }; diff --git a/client/src/app/pages/importer-list/importer-list.tsx b/client/src/app/pages/importer-list/importer-list.tsx index effabdfc..e74e28b9 100644 --- a/client/src/app/pages/importer-list/importer-list.tsx +++ b/client/src/app/pages/importer-list/importer-list.tsx @@ -21,6 +21,7 @@ import { ToolbarItem, } from "@patternfly/react-core"; import { + ActionsColumn, ExpandableRowContent, Td as PFTd, Tr as PFTr, @@ -224,6 +225,20 @@ export const ImporterList: React.FC = () => { )} + + setCreateUpdateModalState(item), + }, + { + title: "Delete", + onClick: () => deleteRow(item), + }, + ]} + /> + {isCellExpanded(item) ? ( diff --git a/client/src/app/pages/package-details/related-cves.tsx b/client/src/app/pages/package-details/related-cves.tsx index 30071200..e99745ad 100644 --- a/client/src/app/pages/package-details/related-cves.tsx +++ b/client/src/app/pages/package-details/related-cves.tsx @@ -7,7 +7,7 @@ import { Toolbar, ToolbarContent, ToolbarItem } from "@patternfly/react-core"; import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table"; import { RENDER_DATE_FORMAT } from "@app/Constants"; -import { CVEBase } from "@app/api/models"; +import { VulnerabilityBase } from "@app/api/models"; import { FilterToolbar, FilterType } from "@app/components/FilterToolbar"; import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText"; import { SimplePagination } from "@app/components/SimplePagination"; @@ -18,13 +18,13 @@ import { import { useLocalTableControls } from "@app/hooks/table-controls"; interface RelatedCVEsProps { - cves: CVEBase[]; + cves: VulnerabilityBase[]; } export const RelatedCVEs: React.FC = ({ cves }) => { const tableControls = useLocalTableControls({ tableName: "cves-table", - idProperty: "id", + idProperty: "vulnerability_id", items: cves, isLoading: false, columnNames: { @@ -45,7 +45,7 @@ export const RelatedCVEs: React.FC = ({ cves }) => { title: "Filter text", placeholderText: "Search", type: FilterType.search, - getItemValue: (item) => item.id, + getItemValue: (item) => item.vulnerability_id, }, ], }); @@ -99,10 +99,12 @@ export const RelatedCVEs: React.FC = ({ cves }) => { > {currentPageItems?.map((item, rowIndex) => { return ( - + - {item.id} + + {item.vulnerability_id} + = ({ sbomId }) => { const tableControls = useLocalTableControls({ tableName: "cves-table", - idProperty: "id", + idProperty: "vulnerability_id", items: cves, isLoading: isFetching, columnNames: { @@ -57,7 +57,7 @@ export const CVEs: React.FC = ({ sbomId }) => { title: "Filter tex", type: FilterType.search, placeholderText: "Search...", - getItemValue: (item) => item.id, + getItemValue: (item) => item.vulnerability_id, }, ], }); @@ -113,14 +113,14 @@ export const CVEs: React.FC = ({ sbomId }) => { > {currentPageItems?.map((item, rowIndex) => { return ( - + - {item.id} + {item.vulnerability_id} Note`], }, - cves: [ + vulnerabilities: [ { - id: "cve1", + vulnerability_id: "cve1", title: "title1", description: "description1", severity: "critical", @@ -38,7 +40,7 @@ export const mockAdvisoryArray: Advisory[] = [ date_updated: new Date().toString(), }, { - id: "cve2", + vulnerability_id: "cve2", title: "title2", description: "description2", severity: "low", @@ -53,14 +55,14 @@ export const mockAdvisoryArray: Advisory[] = [ ]; export const handlers = [ - rest.get(AppRest.ADVISORIES_SEARCH, (req, res, ctx) => { + rest.get(AppRest.ADVISORIES, (req, res, ctx) => { return res( ctx.json({ items: mockAdvisoryArray, total: mockAdvisoryArray.length }) ); }), rest.get(`${AppRest.ADVISORIES}/:id`, (req, res, ctx) => { const { id } = req.params; - const item = mockAdvisoryArray.find((app) => app.id === id); + const item = mockAdvisoryArray.find((app) => app.identifier === id); if (item) { return res(ctx.json(item)); } else { diff --git a/client/src/mocks/stub-new-work/cves.ts b/client/src/mocks/stub-new-work/cves.ts index 43562806..f00e2505 100644 --- a/client/src/mocks/stub-new-work/cves.ts +++ b/client/src/mocks/stub-new-work/cves.ts @@ -5,7 +5,7 @@ import { CVE } from "@app/api/models"; import { mockAdvisoryArray } from "./advisories"; import { mockSBOMArray } from "./sboms"; -export const mockCVEArray: CVE[] = mockAdvisoryArray.flatMap(({ cves }) => { +export const mockCVEArray: CVE[] = mockAdvisoryArray.flatMap(({ vulnerabilities: cves }) => { return cves.map((cve) => { const result: CVE = { ...cve, @@ -22,7 +22,7 @@ export const handlers = [ }), rest.get(`${AppRest.CVES}/:id`, (req, res, ctx) => { const { id } = req.params; - const item = mockCVEArray.find((app) => app.id === id); + const item = mockCVEArray.find((app) => app.vulnerability_id === id); if (item) { return res(ctx.json(item)); } else { diff --git a/client/src/mocks/stub-new-work/sboms.ts b/client/src/mocks/stub-new-work/sboms.ts index bf212747..57e501ca 100644 --- a/client/src/mocks/stub-new-work/sboms.ts +++ b/client/src/mocks/stub-new-work/sboms.ts @@ -37,7 +37,7 @@ export const mockPackageArray: Package[] = [ key1: "value1", key2: "value2", }, - related_cves: mockAdvisoryArray.flatMap((e) => e.cves), + related_cves: mockAdvisoryArray.flatMap((e) => e.vulnerabilities), related_sboms: mockSBOMArray, }, ];