mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
## Addresses #20467 – part 2 ### Aggregate software: #### Software titles <img width="1616" alt="sw-titles-updated" src="https://github.com/user-attachments/assets/0b9922c7-e36e-4d2f-b204-95c3cdf9b602"> #### Software versions <img width="1616" alt="Screenshot 2024-07-29 at 6 14 21 PM" src="https://github.com/user-attachments/assets/5a097700-cd6c-45b1-a21f-9d76a733f0ae"> #### Host software <img width="1616" alt="Screenshot 2024-07-29 at 6 23 01 PM" src="https://github.com/user-attachments/assets/84e18695-f47a-4022-bd53-7f5d37ce452a"> ### Add software modal (VPP) _screenshots use mocked data - UI is flexible enough to display cleanly before and after backend is in place:_ <img width="1339" alt="happy" src="https://github.com/user-attachments/assets/8900aa93-316c-4a09-8e5a-1a1e45b0c458"> #### No apps: <img width="1572" alt="Screenshot 2024-07-29 at 6 35 03 PM" src="https://github.com/user-attachments/assets/466b9b6c-4d3d-49dd-94a9-94e395d89cb7"> #### Not enabled: <img width="1572" alt="Screenshot 2024-07-29 at 6 37 45 PM" src="https://github.com/user-attachments/assets/9bcfd480-8741-4d95-ba3b-550dee4dc673"> #### Error: <img width="1572" alt="Screenshot 2024-07-29 at 6 39 39 PM" src="https://github.com/user-attachments/assets/e944dd40-676e-4aba-9cd9-49ff319bf402"> ### Vuln support – Not supported for now: _see above screenshots for `list` endpoints_ #### Software title detail <img width="1616" alt="Screenshot 2024-07-29 at 6 47 29 PM" src="https://github.com/user-attachments/assets/2e30fd0a-21e4-4d19-bf9b-71a994bfd0e7"> #### Software version and OS detail: <img width="1616" alt="Screenshot 2024-07-29 at 6 48 28 PM" src="https://github.com/user-attachments/assets/e8fec769-ba97-4b6b-b10c-9bb4c973c732"> <img width="1616" alt="Screenshot 2024-07-29 at 6 50 25 PM" src="https://github.com/user-attachments/assets/0ac15727-e0cb-447c-8758-c58b79656d1a"> - [x] Changes file added for user-visible changes in `changes/`, - [x] Added/updated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
142 lines
3.8 KiB
TypeScript
142 lines
3.8 KiB
TypeScript
/**
|
|
software/versions/:id > Vulnerabilities table
|
|
software/os/:id > Vulnerabilities table
|
|
*/
|
|
|
|
import React, { useContext, useMemo } from "react";
|
|
import classnames from "classnames";
|
|
import { InjectedRouter } from "react-router";
|
|
import { Row } from "react-table";
|
|
import PATHS from "router/paths";
|
|
|
|
import { AppContext } from "context/app";
|
|
import { ISoftwareVulnerability } from "interfaces/software";
|
|
import { CONTACT_FLEET_LINK, GITHUB_NEW_ISSUE_LINK } from "utilities/constants";
|
|
import { DisplayPlatform } from "interfaces/platform";
|
|
import { buildQueryStringFromParams } from "utilities/url";
|
|
import TableContainer from "components/TableContainer";
|
|
import TableCount from "components/TableContainer/TableCount";
|
|
import EmptyTable from "components/EmptyTable";
|
|
import CustomLink from "components/CustomLink";
|
|
|
|
import generateTableConfig from "./SoftwareVulnerabilitiesTableConfig";
|
|
|
|
const baseClass = "software-vulnerabilities-table";
|
|
|
|
interface INoVulnsDetectedProps {
|
|
itemName: string;
|
|
}
|
|
|
|
interface IVulnsNotSupportedProps {
|
|
supportInterestText?: DisplayPlatform;
|
|
}
|
|
|
|
const NoVulnsDetected = ({ itemName }: INoVulnsDetectedProps): JSX.Element => {
|
|
return (
|
|
<EmptyTable
|
|
header={`No vulnerabilities detected for this ${itemName}`}
|
|
info={
|
|
<>
|
|
Expecting to see vulnerabilities?{" "}
|
|
<CustomLink
|
|
url={GITHUB_NEW_ISSUE_LINK}
|
|
text="File an issue on GitHub"
|
|
newTab
|
|
/>
|
|
</>
|
|
}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export const VulnsNotSupported = ({
|
|
supportInterestText,
|
|
}: IVulnsNotSupportedProps) => (
|
|
<EmptyTable
|
|
header="Vulnerabilities are not supported for this type of host"
|
|
info={
|
|
<>
|
|
Interested in vulnerabilities in{" "}
|
|
{supportInterestText ?? "this platform"}?{" "}
|
|
<CustomLink url={CONTACT_FLEET_LINK} text="Let us know" newTab />
|
|
</>
|
|
}
|
|
/>
|
|
);
|
|
|
|
interface ISoftwareVulnerabilitiesTableProps {
|
|
data: ISoftwareVulnerability[];
|
|
/** Name displayed on the empty state */
|
|
itemName: string;
|
|
isLoading: boolean;
|
|
className?: string;
|
|
router: InjectedRouter;
|
|
teamIdForApi?: number;
|
|
}
|
|
|
|
interface IRowProps extends Row {
|
|
original: {
|
|
cve?: string;
|
|
};
|
|
}
|
|
|
|
const SoftwareVulnerabilitiesTable = ({
|
|
data,
|
|
itemName,
|
|
isLoading,
|
|
className,
|
|
router,
|
|
teamIdForApi,
|
|
}: ISoftwareVulnerabilitiesTableProps) => {
|
|
const { isPremiumTier } = useContext(AppContext);
|
|
|
|
const classNames = classnames(baseClass, className);
|
|
|
|
const handleRowSelect = (row: IRowProps) => {
|
|
const hostsBySoftwareParams = {
|
|
vulnerability: row.original.cve,
|
|
team_id: teamIdForApi,
|
|
};
|
|
|
|
const path = hostsBySoftwareParams
|
|
? `${PATHS.MANAGE_HOSTS}?${buildQueryStringFromParams(
|
|
hostsBySoftwareParams
|
|
)}`
|
|
: PATHS.MANAGE_HOSTS;
|
|
|
|
router.push(path);
|
|
};
|
|
|
|
const tableHeaders = useMemo(
|
|
() => generateTableConfig(Boolean(isPremiumTier), router, teamIdForApi),
|
|
[isPremiumTier]
|
|
);
|
|
|
|
const renderVulnerabilitiesCount = () => (
|
|
<TableCount name="items" count={data?.length} />
|
|
);
|
|
|
|
return (
|
|
<div className={classNames}>
|
|
<TableContainer
|
|
columnConfigs={tableHeaders}
|
|
data={data}
|
|
defaultSortHeader={isPremiumTier ? "updated_at" : "cve"} // TODO: Change premium to created_at when added to API
|
|
defaultSortDirection="desc"
|
|
emptyComponent={() => <NoVulnsDetected itemName={itemName} />}
|
|
isAllPagesSelected={false}
|
|
isLoading={isLoading}
|
|
isClientSidePagination
|
|
pageSize={20}
|
|
resultsTitle="items"
|
|
showMarkAllPages={false}
|
|
disableMultiRowSelect
|
|
onSelectSingleRow={handleRowSelect}
|
|
disableTableHeader={data.length === 0}
|
|
renderCount={renderVulnerabilitiesCount}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SoftwareVulnerabilitiesTable;
|