mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #34500 and Resolves #33758 Video demo: https://www.youtube.com/watch?v=4HZlKG0G1B0 - Added a new aggregation table `operating_system_version_vulnerabilities` for faster queries. The table is currently used only for Linux vulnerabilities, but could be used for other OS vulnerabilities. - Added `max_vulnerabilities` parameter per [API doc](https://github.com/fleetdm/fleet/pull/33533) - Also added `max_vulnerabilities` parameter to `os_versions/{id}` endpoint, but not making it public since that endpoint is still slow and needs other API changes. bug #34974 - Removed `"kernels": []` from `os_versions` endpoint result # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually ## Database migrations - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added ability to limit the number of vulnerabilities displayed for operating system versions via an optional parameter. * Introduced vulnerability count tracking for operating system versions, now visible in API responses and UI displays. * Enhanced operating system vulnerability visualization with improved count-based rendering. * **Tests** * Added comprehensive test coverage for vulnerability limiting behavior across multiple operating system versions and architectures. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
96 lines
2 KiB
TypeScript
96 lines
2 KiB
TypeScript
/** software/os OS tab */
|
|
|
|
import React from "react";
|
|
import { useQuery } from "react-query";
|
|
import { InjectedRouter } from "react-router";
|
|
import {
|
|
IGetOSVersionsQueryKey,
|
|
IOSVersionsResponse,
|
|
getOSVersions,
|
|
} from "services/entities/operating_systems";
|
|
|
|
import TableDataError from "components/DataError";
|
|
import Spinner from "components/Spinner";
|
|
import { SelectedPlatform } from "interfaces/platform";
|
|
|
|
import SoftwareOSTable from "./SoftwareOSTable";
|
|
|
|
const baseClass = "software-os";
|
|
|
|
interface ISoftwareOSProps {
|
|
router: InjectedRouter;
|
|
isSoftwareEnabled: boolean;
|
|
perPage: number;
|
|
orderDirection: "asc" | "desc";
|
|
orderKey: string;
|
|
currentPage: number;
|
|
teamId?: number;
|
|
platform: SelectedPlatform;
|
|
}
|
|
|
|
const SoftwareOS = ({
|
|
router,
|
|
isSoftwareEnabled,
|
|
perPage,
|
|
orderDirection,
|
|
orderKey,
|
|
currentPage,
|
|
teamId,
|
|
platform,
|
|
}: ISoftwareOSProps) => {
|
|
const queryParams = {
|
|
page: currentPage,
|
|
per_page: perPage,
|
|
order_direction: orderDirection,
|
|
order_key: orderKey,
|
|
platform: platform === "all" ? undefined : platform,
|
|
teamId,
|
|
max_vulnerabilities: 3,
|
|
};
|
|
|
|
const { data, isFetching, isLoading, isError } = useQuery<
|
|
IOSVersionsResponse,
|
|
Error,
|
|
IOSVersionsResponse,
|
|
IGetOSVersionsQueryKey[]
|
|
>(
|
|
[
|
|
{
|
|
scope: "software-os",
|
|
...queryParams,
|
|
},
|
|
],
|
|
() => getOSVersions(queryParams),
|
|
{
|
|
keepPreviousData: true,
|
|
staleTime: 30000,
|
|
}
|
|
);
|
|
|
|
if (isLoading) {
|
|
return <Spinner />;
|
|
}
|
|
|
|
if (isError) {
|
|
return <TableDataError verticalPaddingSize="pad-xxxlarge" />;
|
|
}
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
<SoftwareOSTable
|
|
router={router}
|
|
data={data}
|
|
isSoftwareEnabled={isSoftwareEnabled}
|
|
perPage={perPage}
|
|
orderDirection={orderDirection}
|
|
orderKey={orderKey}
|
|
currentPage={currentPage}
|
|
teamId={teamId}
|
|
isLoading={isFetching}
|
|
platform={platform}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SoftwareOS;
|