2024-02-14 17:58:40 +00:00
|
|
|
/** software/os OS tab */
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
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";
|
2024-02-22 22:24:11 +00:00
|
|
|
import Spinner from "components/Spinner";
|
2024-10-16 15:02:06 +00:00
|
|
|
import { SelectedPlatform } from "interfaces/platform";
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
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;
|
2024-10-16 15:02:06 +00:00
|
|
|
platform: SelectedPlatform;
|
2024-01-25 18:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SoftwareOS = ({
|
|
|
|
|
router,
|
|
|
|
|
isSoftwareEnabled,
|
|
|
|
|
perPage,
|
|
|
|
|
orderDirection,
|
|
|
|
|
orderKey,
|
|
|
|
|
currentPage,
|
|
|
|
|
teamId,
|
2024-10-16 15:02:06 +00:00
|
|
|
platform,
|
2024-01-25 18:03:44 +00:00
|
|
|
}: ISoftwareOSProps) => {
|
|
|
|
|
const queryParams = {
|
|
|
|
|
page: currentPage,
|
|
|
|
|
per_page: perPage,
|
|
|
|
|
order_direction: orderDirection,
|
|
|
|
|
order_key: orderKey,
|
2024-10-16 15:02:06 +00:00
|
|
|
platform: platform === "all" ? undefined : platform,
|
2024-01-25 18:03:44 +00:00
|
|
|
teamId,
|
os_versions endpoint performance improvements (#34897)
<!-- 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 -->
2025-11-03 19:07:44 +00:00
|
|
|
max_vulnerabilities: 3,
|
2024-01-25 18:03:44 +00:00
|
|
|
};
|
|
|
|
|
|
2024-02-22 22:24:11 +00:00
|
|
|
const { data, isFetching, isLoading, isError } = useQuery<
|
2024-01-25 18:03:44 +00:00
|
|
|
IOSVersionsResponse,
|
|
|
|
|
Error,
|
|
|
|
|
IOSVersionsResponse,
|
|
|
|
|
IGetOSVersionsQueryKey[]
|
|
|
|
|
>(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
scope: "software-os",
|
|
|
|
|
...queryParams,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
() => getOSVersions(queryParams),
|
|
|
|
|
{
|
|
|
|
|
keepPreviousData: true,
|
|
|
|
|
staleTime: 30000,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-02-22 22:24:11 +00:00
|
|
|
if (isLoading) {
|
|
|
|
|
return <Spinner />;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
if (isError) {
|
2025-05-06 13:20:03 +00:00
|
|
|
return <TableDataError verticalPaddingSize="pad-xxxlarge" />;
|
2024-01-25 18:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={baseClass}>
|
|
|
|
|
<SoftwareOSTable
|
|
|
|
|
router={router}
|
|
|
|
|
data={data}
|
|
|
|
|
isSoftwareEnabled={isSoftwareEnabled}
|
|
|
|
|
perPage={perPage}
|
|
|
|
|
orderDirection={orderDirection}
|
|
|
|
|
orderKey={orderKey}
|
|
|
|
|
currentPage={currentPage}
|
|
|
|
|
teamId={teamId}
|
|
|
|
|
isLoading={isFetching}
|
2024-10-16 15:02:06 +00:00
|
|
|
platform={platform}
|
2024-01-25 18:03:44 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SoftwareOS;
|