From e5c5992cdaa80e77191bb035117fb59669d02c81 Mon Sep 17 00:00:00 2001 From: Victor Lyuboslavsky <2685025+getvictor@users.noreply.github.com> Date: Wed, 5 Nov 2025 17:02:55 -0600 Subject: [PATCH] Fix non-Linux not displaying all OS version. (#35220) **Related issue:** Resolves #35166 Fix - For an OS version, we first fetch the version with max_vulnerabilities=0. - If the OS version has vulnerabilities and it is non-Linux, then we refetch the OS version without specifying the `max_vulnerabilities` parameter, which fetches all vulnerabilities. # Checklist for submitter ## Testing - [x] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results ## Summary by CodeRabbit * **Improvements** * Optimized vulnerability data loading for operating system details with enhanced fetching strategy * Improved loading state management for clearer visibility during data retrieval on OS version pages --------- Co-authored-by: Jacob Shandling --- .../SoftwareOSDetailsPage.tsx | 21 ++++++++++++++++++- .../services/entities/operating_systems.ts | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frontend/pages/SoftwarePage/SoftwareOSDetailsPage/SoftwareOSDetailsPage.tsx b/frontend/pages/SoftwarePage/SoftwareOSDetailsPage/SoftwareOSDetailsPage.tsx index f98820d193..1efe1cc4eb 100644 --- a/frontend/pages/SoftwarePage/SoftwareOSDetailsPage/SoftwareOSDetailsPage.tsx +++ b/frontend/pages/SoftwarePage/SoftwareOSDetailsPage/SoftwareOSDetailsPage.tsx @@ -1,6 +1,6 @@ /** software/os/:id */ -import React, { useCallback, useContext } from "react"; +import React, { useCallback, useContext, useState } from "react"; import { useQuery } from "react-query"; import { useErrorHandler } from "react-error-boundary"; import { InjectedRouter, RouteComponentProps } from "react-router"; @@ -169,6 +169,11 @@ const SoftwareOSDetailsPage = ({ includeNoTeam: true, }); + // Track whether we need to fetch all vulnerabilities + const [maxVulnerabilities, setMaxVulnerabilities] = useState< + number | undefined + >(0); + const { data: { os_version: osVersionDetails, counts_updated_at } = {}, isLoading, @@ -184,6 +189,7 @@ const SoftwareOSDetailsPage = ({ scope: "osVersionDetails", os_version_id: osVersionIdFromURL, teamId: teamIdForApi, + max_vulnerabilities: maxVulnerabilities, }, ], ({ queryKey }) => osVersionsAPI.getOSVersion(queryKey[0]), @@ -200,6 +206,19 @@ const SoftwareOSDetailsPage = ({ handlePageError(error); } }, + onSuccess: (data) => { + const { + os_version: { platform, vulnerabilities_count }, + } = data; + if ( + !isLinuxLike(platform) && + vulnerabilities_count && + vulnerabilities_count > 0 && + maxVulnerabilities === 0 + ) { + setMaxVulnerabilities(undefined); + } + }, } ); diff --git a/frontend/services/entities/operating_systems.ts b/frontend/services/entities/operating_systems.ts index 2d989990fe..969829d79e 100644 --- a/frontend/services/entities/operating_systems.ts +++ b/frontend/services/entities/operating_systems.ts @@ -42,6 +42,7 @@ export interface IOSVersionsResponse { interface IGetOsVersionOptions { os_version_id: number; teamId?: number; + max_vulnerabilities?: number; } export interface IGetOsVersionQueryKey extends IGetOsVersionOptions { @@ -94,11 +95,12 @@ export const getOSVersions = ({ const getOSVersion = ({ os_version_id, teamId, + max_vulnerabilities, }: IGetOsVersionOptions): Promise => { const endpoint = endpoints.OS_VERSION(os_version_id); const queryString = buildQueryStringFromParams({ team_id: teamId, - max_vulnerabilities: 3, // Limit CVEs to first 3, use vulnerabilities_count for total + max_vulnerabilities, }); const path = queryString ? `${endpoint}?${queryString}` : endpoint;