mirror of
https://github.com/fleetdm/fleet
synced 2026-05-18 14:38:53 +00:00
93 lines
2.1 KiB
TypeScript
93 lines
2.1 KiB
TypeScript
/** software/vulnerabilities Vulnerabilities tab */
|
|
|
|
import React from "react";
|
|
import { useQuery } from "react-query";
|
|
import { InjectedRouter } from "react-router";
|
|
import {
|
|
IGetVulnerabilitiesQueryKey,
|
|
IVulnerabilitiesResponse,
|
|
getVulnerabilities,
|
|
} from "services/entities/vulnerabilities";
|
|
|
|
import TableDataError from "components/DataError";
|
|
|
|
import SoftwareVulnerabilitiesTable from "./SoftwareVulnerabilitiesTable";
|
|
|
|
const baseClass = "software-vulnerabilities";
|
|
|
|
interface ISoftwareVulnerabilitiesProps {
|
|
router: InjectedRouter;
|
|
isSoftwareEnabled: boolean;
|
|
perPage: number;
|
|
query?: string;
|
|
orderDirection: "asc" | "desc";
|
|
orderKey: string;
|
|
currentPage: number;
|
|
teamId?: number;
|
|
showExploitedVulnerabilitiesOnly: boolean;
|
|
}
|
|
|
|
const SoftwareVulnerabilities = ({
|
|
router,
|
|
isSoftwareEnabled,
|
|
query,
|
|
perPage,
|
|
orderDirection,
|
|
orderKey,
|
|
currentPage,
|
|
teamId,
|
|
showExploitedVulnerabilitiesOnly,
|
|
}: ISoftwareVulnerabilitiesProps) => {
|
|
const queryParams = {
|
|
page: currentPage,
|
|
per_page: perPage,
|
|
order_direction: orderDirection,
|
|
order_key: orderKey,
|
|
teamId,
|
|
query,
|
|
exploit: showExploitedVulnerabilitiesOnly,
|
|
};
|
|
|
|
const { data, isFetching, isError } = useQuery<
|
|
IVulnerabilitiesResponse,
|
|
Error,
|
|
IVulnerabilitiesResponse,
|
|
IGetVulnerabilitiesQueryKey[]
|
|
>(
|
|
[
|
|
{
|
|
scope: "software-vulnerabilities",
|
|
...queryParams,
|
|
},
|
|
],
|
|
() => getVulnerabilities(queryParams),
|
|
{
|
|
keepPreviousData: true,
|
|
staleTime: 30000,
|
|
}
|
|
);
|
|
|
|
if (isError) {
|
|
return <TableDataError className={`${baseClass}__table-error`} />;
|
|
}
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
<SoftwareVulnerabilitiesTable
|
|
router={router}
|
|
data={data}
|
|
query={query}
|
|
showExploitedVulnerabilitiesOnly={showExploitedVulnerabilitiesOnly}
|
|
isSoftwareEnabled={isSoftwareEnabled}
|
|
perPage={perPage}
|
|
orderDirection={orderDirection}
|
|
orderKey={orderKey}
|
|
currentPage={currentPage}
|
|
teamId={teamId}
|
|
isLoading={isFetching}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SoftwareVulnerabilities;
|