2022-06-08 19:01:38 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
2024-02-12 14:02:00 +00:00
|
|
|
import { formatSeverity } from "utilities/helpers";
|
2024-01-25 18:03:44 +00:00
|
|
|
import { ISoftwareVulnerability } from "interfaces/software";
|
2022-06-08 19:01:38 +00:00
|
|
|
|
2024-02-08 13:54:00 +00:00
|
|
|
import paths from "router/paths";
|
2022-06-08 19:01:38 +00:00
|
|
|
import HeaderCell from "components/TableContainer/DataTable/HeaderCell/HeaderCell";
|
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
|
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
2023-10-16 15:43:47 +00:00
|
|
|
import { HumanTimeDiffWithDateTip } from "components/HumanTimeDiffWithDateTip";
|
2023-04-27 15:53:30 +00:00
|
|
|
import PremiumFeatureIconWithTooltip from "components/PremiumFeatureIconWithTooltip";
|
2024-02-12 14:02:00 +00:00
|
|
|
import ProbabilityOfExploit from "components/ProbabilityOfExploit/ProbabilityOfExploit";
|
2024-02-08 13:54:00 +00:00
|
|
|
import ViewAllHostsLink from "components/ViewAllHostsLink";
|
|
|
|
|
import LinkCell from "components/TableContainer/DataTable/LinkCell";
|
2022-06-08 19:01:38 +00:00
|
|
|
|
|
|
|
|
interface IHeaderProps {
|
|
|
|
|
column: {
|
|
|
|
|
title: string;
|
|
|
|
|
isSortedDesc: boolean;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
interface ICellProps {
|
|
|
|
|
cell: {
|
|
|
|
|
value: number | string | string[];
|
|
|
|
|
};
|
|
|
|
|
row: {
|
2023-12-12 21:03:33 +00:00
|
|
|
original: ISoftwareVulnerability;
|
2022-06-08 19:01:38 +00:00
|
|
|
index: number;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ITextCellProps extends ICellProps {
|
|
|
|
|
cell: {
|
|
|
|
|
value: string | number;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface IDataColumn {
|
|
|
|
|
title: string;
|
|
|
|
|
Header: ((props: IHeaderProps) => JSX.Element) | string;
|
|
|
|
|
accessor: string;
|
|
|
|
|
Cell: (props: ITextCellProps) => JSX.Element;
|
|
|
|
|
disableHidden?: boolean;
|
|
|
|
|
disableSortBy?: boolean;
|
|
|
|
|
sortType?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
const generateTableConfig = (
|
2023-04-27 15:53:30 +00:00
|
|
|
isPremiumTier: boolean,
|
|
|
|
|
isSandboxMode: boolean
|
|
|
|
|
): IDataColumn[] => {
|
2022-06-08 19:01:38 +00:00
|
|
|
const tableHeaders: IDataColumn[] = [
|
|
|
|
|
{
|
|
|
|
|
title: "Vunerability",
|
|
|
|
|
accessor: "cve",
|
|
|
|
|
disableSortBy: true,
|
|
|
|
|
Header: "Vulnerability",
|
2024-02-08 13:54:00 +00:00
|
|
|
Cell: ({ cell: { value } }: ITextCellProps) => {
|
|
|
|
|
const cveName = value.toString();
|
2022-06-08 19:01:38 +00:00
|
|
|
return (
|
2024-02-08 13:54:00 +00:00
|
|
|
<LinkCell
|
|
|
|
|
value={cveName}
|
|
|
|
|
path={paths.SOFTWARE_VULNERABILITY_DETAILS(cveName)}
|
2022-10-27 18:06:57 +00:00
|
|
|
/>
|
2022-06-08 19:01:38 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const premiumHeaders: IDataColumn[] = [
|
|
|
|
|
{
|
|
|
|
|
title: "Severity",
|
|
|
|
|
accessor: "cvss_score",
|
|
|
|
|
disableSortBy: false,
|
|
|
|
|
Header: (headerProps: IHeaderProps): JSX.Element => {
|
|
|
|
|
const titleWithToolTip = (
|
|
|
|
|
<TooltipWrapper
|
2023-11-07 21:15:49 +00:00
|
|
|
tipContent={
|
|
|
|
|
<>
|
|
|
|
|
The worst case impact across different environments (CVSS base
|
|
|
|
|
score).
|
|
|
|
|
</>
|
|
|
|
|
}
|
2022-06-08 19:01:38 +00:00
|
|
|
>
|
|
|
|
|
Severity
|
|
|
|
|
</TooltipWrapper>
|
|
|
|
|
);
|
|
|
|
|
return (
|
2023-04-27 15:53:30 +00:00
|
|
|
<>
|
|
|
|
|
<HeaderCell
|
|
|
|
|
value={titleWithToolTip}
|
|
|
|
|
isSortedDesc={headerProps.column.isSortedDesc}
|
|
|
|
|
/>
|
2023-12-12 21:03:33 +00:00
|
|
|
{isSandboxMode && <PremiumFeatureIconWithTooltip />}
|
2023-04-27 15:53:30 +00:00
|
|
|
</>
|
2022-06-08 19:01:38 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
Cell: ({ cell: { value } }: ITextCellProps): JSX.Element => (
|
|
|
|
|
<TextCell formatter={formatSeverity} value={value} />
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-02-08 13:54:00 +00:00
|
|
|
title: "Probability of exploit",
|
|
|
|
|
accessor: "epss_probability",
|
2022-06-08 19:01:38 +00:00
|
|
|
disableSortBy: false,
|
|
|
|
|
Header: (headerProps: IHeaderProps): JSX.Element => {
|
|
|
|
|
const titleWithToolTip = (
|
|
|
|
|
<TooltipWrapper
|
2024-02-08 13:54:00 +00:00
|
|
|
className="epss_probability"
|
2023-11-07 21:15:49 +00:00
|
|
|
tipContent={
|
|
|
|
|
<>
|
2024-02-08 13:54:00 +00:00
|
|
|
The probability that this vulnerability will be exploited in the
|
|
|
|
|
next 30 days (EPSS probability). <br />
|
|
|
|
|
This data is reported by FIRST.org.
|
2023-11-07 21:15:49 +00:00
|
|
|
</>
|
|
|
|
|
}
|
2022-06-08 19:01:38 +00:00
|
|
|
>
|
2024-02-08 13:54:00 +00:00
|
|
|
Probability of exploit
|
2022-06-08 19:01:38 +00:00
|
|
|
</TooltipWrapper>
|
|
|
|
|
);
|
|
|
|
|
return (
|
2023-04-27 15:53:30 +00:00
|
|
|
<>
|
|
|
|
|
<HeaderCell
|
|
|
|
|
value={titleWithToolTip}
|
|
|
|
|
isSortedDesc={headerProps.column.isSortedDesc}
|
|
|
|
|
/>
|
2023-12-12 21:03:33 +00:00
|
|
|
{isSandboxMode && <PremiumFeatureIconWithTooltip />}
|
2023-04-27 15:53:30 +00:00
|
|
|
</>
|
2022-06-08 19:01:38 +00:00
|
|
|
);
|
|
|
|
|
},
|
2024-02-08 13:54:00 +00:00
|
|
|
Cell: (cellProps: ICellProps): JSX.Element => (
|
2024-02-12 14:02:00 +00:00
|
|
|
<ProbabilityOfExploit
|
2024-02-08 13:54:00 +00:00
|
|
|
probabilityOfExploit={cellProps.row.original.epss_probability}
|
|
|
|
|
cisaKnownExploit={cellProps.row.original.cisa_known_exploit}
|
|
|
|
|
/>
|
2022-06-08 19:01:38 +00:00
|
|
|
),
|
|
|
|
|
},
|
2023-03-23 16:32:32 +00:00
|
|
|
{
|
|
|
|
|
title: "Published",
|
|
|
|
|
accessor: "cve_published",
|
|
|
|
|
disableSortBy: false,
|
|
|
|
|
Header: (headerProps: IHeaderProps): JSX.Element => {
|
|
|
|
|
const titleWithToolTip = (
|
|
|
|
|
<TooltipWrapper
|
2023-11-07 21:15:49 +00:00
|
|
|
tipContent={
|
|
|
|
|
<>
|
|
|
|
|
The date this vulnerability was published in the National
|
|
|
|
|
Vulnerability Database (NVD).
|
|
|
|
|
</>
|
|
|
|
|
}
|
2023-03-23 16:32:32 +00:00
|
|
|
>
|
|
|
|
|
Published
|
|
|
|
|
</TooltipWrapper>
|
|
|
|
|
);
|
|
|
|
|
return (
|
2023-04-27 15:53:30 +00:00
|
|
|
<>
|
|
|
|
|
<HeaderCell
|
|
|
|
|
value={titleWithToolTip}
|
|
|
|
|
isSortedDesc={headerProps.column.isSortedDesc}
|
|
|
|
|
/>
|
2023-12-12 21:03:33 +00:00
|
|
|
{isSandboxMode && <PremiumFeatureIconWithTooltip />}
|
2023-04-27 15:53:30 +00:00
|
|
|
</>
|
2023-03-23 16:32:32 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
Cell: ({ cell: { value } }: ITextCellProps): JSX.Element => {
|
|
|
|
|
const valString = typeof value === "number" ? value.toString() : value;
|
|
|
|
|
return (
|
|
|
|
|
<TextCell
|
|
|
|
|
value={valString ? { timeString: valString } : undefined}
|
|
|
|
|
formatter={valString ? HumanTimeDiffWithDateTip : undefined}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-02-08 13:54:00 +00:00
|
|
|
{
|
|
|
|
|
title: "Detected",
|
|
|
|
|
accessor: "created_at",
|
|
|
|
|
disableSortBy: false,
|
|
|
|
|
Header: (headerProps: IHeaderProps): JSX.Element => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<HeaderCell
|
|
|
|
|
value="Detected"
|
|
|
|
|
isSortedDesc={headerProps.column.isSortedDesc}
|
|
|
|
|
/>
|
|
|
|
|
{isSandboxMode && <PremiumFeatureIconWithTooltip />}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
Cell: (cellProps: ICellProps): JSX.Element => {
|
|
|
|
|
const createdAt = cellProps.row.original.created_at || "";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<TextCell
|
|
|
|
|
value={{ timeString: createdAt }}
|
|
|
|
|
formatter={HumanTimeDiffWithDateTip}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "",
|
|
|
|
|
Header: "",
|
|
|
|
|
accessor: "linkToFilteredHosts",
|
|
|
|
|
disableSortBy: true,
|
|
|
|
|
Cell: (cellProps: ICellProps) => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{cellProps.row.original && (
|
|
|
|
|
<ViewAllHostsLink
|
|
|
|
|
queryParams={{
|
|
|
|
|
vulnerability: cellProps.row.original.cve,
|
|
|
|
|
}}
|
|
|
|
|
className="vulnerabilities-link"
|
|
|
|
|
rowHover
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-06-08 19:01:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return isPremiumTier ? tableHeaders.concat(premiumHeaders) : tableHeaders;
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
export default generateTableConfig;
|