From 29a125c08eb45b247dfbe1b966b2fd0180fa3f9d Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Thu, 12 Nov 2026 11:39:49 +0100 Subject: [PATCH 1/6] add: parse agent OS CPE and support status --- src/gmp/models/__tests__/agent.test.ts | 15 +++++++++++++++ src/gmp/models/agent.ts | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/gmp/models/__tests__/agent.test.ts b/src/gmp/models/__tests__/agent.test.ts index 4e0ee8e297..e940c0ca0c 100644 --- a/src/gmp/models/__tests__/agent.test.ts +++ b/src/gmp/models/__tests__/agent.test.ts @@ -26,6 +26,8 @@ describe('Agent model tests', () => { expect(agent.updaterVersion).toBeUndefined(); expect(agent.agentVersion).toBeUndefined(); expect(agent.operatingSystem).toBeUndefined(); + expect(agent.osCpe).toBeUndefined(); + expect(agent.osStatus).toBeUndefined(); expect(agent.architecture).toBeUndefined(); expect(agent.updateToLatest).toBeUndefined(); expect(agent.agentUpdateAvailable).toBeUndefined(); @@ -52,6 +54,8 @@ describe('Agent model tests', () => { expect(agent.updaterVersion).toBeUndefined(); expect(agent.agentVersion).toBeUndefined(); expect(agent.operatingSystem).toBeUndefined(); + expect(agent.osCpe).toBeUndefined(); + expect(agent.osStatus).toBeUndefined(); expect(agent.architecture).toBeUndefined(); expect(agent.updateToLatest).toBeUndefined(); expect(agent.agentUpdateAvailable).toBeUndefined(); @@ -176,6 +180,17 @@ describe('Agent model tests', () => { expect(agent.operatingSystem).toEqual('Linux'); }); + test('should parse OS CPE and support status', () => { + const agent = Agent.fromElement({ + _id: 'test-id', + os_cpe: 'cpe:2.3:o:debian:debian:11:-:-:-:-:-:x86_64:-', + os_status: 'supported', + }); + + expect(agent.osCpe).toBe('cpe:2.3:o:debian:debian:11:-:-:-:-:-:x86_64:-'); + expect(agent.osStatus).toBe('supported'); + }); + test('should parse architecture', () => { const agent = Agent.fromElement({_id: 'test-id', architecture: 'x86_64'}); expect(agent.architecture).toEqual('x86_64'); diff --git a/src/gmp/models/agent.ts b/src/gmp/models/agent.ts index 575a1357eb..3defa78ba1 100644 --- a/src/gmp/models/agent.ts +++ b/src/gmp/models/agent.ts @@ -50,6 +50,8 @@ export interface AgentElement extends ModelElement { updater_version?: string; agent_version?: string; operating_system?: string; + os_cpe?: string; + os_status?: 'supported' | 'unsupported' | 'unknown'; architecture?: string; update_to_latest?: YesNo; agent_update_available?: YesNo; @@ -108,6 +110,8 @@ interface AgentProperties extends ModelProperties { updaterVersion?: string; agentVersion?: string; operatingSystem?: string; + osCpe?: string; + osStatus?: 'supported' | 'unsupported' | 'unknown'; architecture?: string; updateToLatest?: boolean; agentUpdateAvailable?: boolean; @@ -154,6 +158,8 @@ class Agent extends Model { readonly updaterVersion?: string; readonly agentVersion?: string; readonly operatingSystem?: string; + readonly osCpe?: string; + readonly osStatus?: 'supported' | 'unsupported' | 'unknown'; readonly architecture?: string; readonly updateToLatest?: boolean; readonly agentUpdateAvailable?: boolean; @@ -175,6 +181,8 @@ class Agent extends Model { updaterVersion, agentVersion, operatingSystem, + osCpe, + osStatus, architecture, updateToLatest, agentUpdateAvailable, @@ -198,6 +206,8 @@ class Agent extends Model { this.updaterVersion = updaterVersion; this.agentVersion = agentVersion; this.operatingSystem = operatingSystem; + this.osCpe = osCpe; + this.osStatus = osStatus; this.architecture = architecture; this.updateToLatest = updateToLatest; this.agentUpdateAvailable = agentUpdateAvailable; @@ -231,6 +241,8 @@ class Agent extends Model { copy.updaterVersion = parseToString(element.updater_version); copy.agentVersion = parseToString(element.agent_version); copy.operatingSystem = parseToString(element.operating_system); + copy.osCpe = parseToString(element.os_cpe); + copy.osStatus = element.os_status; copy.architecture = parseToString(element.architecture); copy.updateToLatest = isDefined(element.update_to_latest) ? parseBoolean(element.update_to_latest) From 5069eba599e7e8ab5b7dbab3c733bf7c969d2e51 Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Thu, 12 Nov 2026 11:39:49 +0100 Subject: [PATCH 2/6] add: extract OS product names generically from CPE --- .../__tests__/operating-system-name.test.ts | 48 ++++++++++++++++++ src/web/utils/operating-system-name.ts | 49 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/web/utils/__tests__/operating-system-name.test.ts create mode 100644 src/web/utils/operating-system-name.ts diff --git a/src/web/utils/__tests__/operating-system-name.test.ts b/src/web/utils/__tests__/operating-system-name.test.ts new file mode 100644 index 0000000000..7347b87280 --- /dev/null +++ b/src/web/utils/__tests__/operating-system-name.test.ts @@ -0,0 +1,48 @@ +/* SPDX-FileCopyrightText: 2026 Greenbone AG + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import {describe, expect, test} from '@gsa/testing'; +import getOperatingSystemNameFromCpe from 'web/utils/operating-system-name'; + +describe('getOperatingSystemNameFromCpe', () => { + test.each([ + ['debian', 'debian'], + ['ubuntu_linux', 'ubuntu linux'], + ['almalinux', 'almalinux'], + ['FutureOS_Enterprise-Edge', 'FutureOS Enterprise-Edge'], + [String.raw`product\:edition`, 'product:edition'], + [String.raw`product\\edition`, String.raw`product\edition`], + [String.raw`product\!`, 'product!'], + ])('should extract %s without OS-specific rules', (product, name) => { + expect( + getOperatingSystemNameFromCpe( + `cpe:2.3:o:vendor:${product}:1:-:-:-:-:-:x86_64:-`, + ), + ).toBe(name); + }); + + test('should respect escaped separators in other fields', () => { + expect( + getOperatingSystemNameFromCpe( + String.raw`cpe:2.3:o:vendor\:name:Some_OS:1:-:-:-:-:-:x86_64:-`, + ), + ).toBe('Some OS'); + }); + + test.each([ + undefined, + '', + 'not a CPE', + 'cpe:2.3:o:vendor:product', + 'cpe:2.3:o:vendor:product:1:-:-:-:-:-:x86_64:-:extra', + 'cpe:2.3:a:vendor:product:1:-:-:-:-:-:x86_64:-', + 'cpe:2.3:o:vendor::1:-:-:-:-:-:x86_64:-', + 'cpe:2.3:o:vendor:*:1:-:-:-:-:-:x86_64:-', + 'cpe:2.3:o:vendor:-:1:-:-:-:-:-:x86_64:-', + 'cpe:2.3:o:vendor:product:1:-:-:-:-:-:x86_64:-\\', + ])('should return no name for %s', cpe => { + expect(getOperatingSystemNameFromCpe(cpe)).toBeUndefined(); + }); +}); diff --git a/src/web/utils/operating-system-name.ts b/src/web/utils/operating-system-name.ts new file mode 100644 index 0000000000..83a8b56ae1 --- /dev/null +++ b/src/web/utils/operating-system-name.ts @@ -0,0 +1,49 @@ +/* SPDX-FileCopyrightText: 2026 Greenbone AG + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +const getOperatingSystemNameFromCpe = (cpe?: string): string | undefined => { + if (!cpe) { + return undefined; + } + + const fields: string[] = []; + let field = ''; + let escaped = false; + + for (const character of cpe) { + if (escaped) { + field += `\\${character}`; + escaped = false; + } else if (character === '\\') { + escaped = true; + } else if (character === ':') { + fields.push(field); + field = ''; + } else { + field += character; + } + } + fields.push(field); + + if ( + escaped || + fields.length !== 13 || + fields[0] !== 'cpe' || + fields[1] !== '2.3' || + fields[2] !== 'o' || + fields.some(value => value.length === 0) + ) { + return undefined; + } + + const product = fields[4]; + if (product === '*' || product === '-') { + return undefined; + } + + return product.replace(/\\(.)/g, '$1').replace(/_/g, ' '); +}; + +export default getOperatingSystemNameFromCpe; From 46f0781d07a0fc9d745b0c14cc6d860deeee2ba9 Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Thu, 12 Nov 2026 11:39:49 +0100 Subject: [PATCH 3/6] change: support static colors and sizes in HaloDot --- src/web/components/status/HaloDot.tsx | 19 +++++++++----- .../status/__tests__/HaloDot.test.tsx | 26 +++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/web/components/status/HaloDot.tsx b/src/web/components/status/HaloDot.tsx index 0f1c6c49ac..6f56861496 100644 --- a/src/web/components/status/HaloDot.tsx +++ b/src/web/components/status/HaloDot.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import styled, {keyframes} from 'styled-components'; +import styled, {css, keyframes} from 'styled-components'; import Theme from 'web/utils/theme'; const pulse = keyframes` @@ -26,13 +26,20 @@ const pulse = keyframes` } `; -const HaloDot = styled.span` +interface HaloDotProps { + $animated?: boolean; + $color?: string; + $size?: string; +} + +const HaloDot = styled.span` display: inline-flex; - width: 12px; - height: 12px; + width: ${({$size = '12px'}) => $size}; + height: ${({$size = '12px'}) => $size}; border-radius: 50%; - background: ${Theme.green}; - animation: ${pulse} 2.2s ease-out infinite; + background: ${({$color = Theme.green}) => $color}; + animation: ${({$animated = true}) => + $animated ? css`${pulse} 2.2s ease-out infinite` : 'none'}; will-change: transform, box-shadow, opacity; @media (prefers-reduced-motion: reduce) { diff --git a/src/web/components/status/__tests__/HaloDot.test.tsx b/src/web/components/status/__tests__/HaloDot.test.tsx index 9d0b1fc70c..8d7d1a1d63 100644 --- a/src/web/components/status/__tests__/HaloDot.test.tsx +++ b/src/web/components/status/__tests__/HaloDot.test.tsx @@ -25,5 +25,31 @@ describe('HaloDot tests', () => { 'aria-label', 'Last Contact', ); + expect(screen.getByTestId('halo-dot')).toHaveStyle({ + backgroundColor: 'rgb(17, 171, 81)', + width: '12px', + height: '12px', + }); + expect( + window.getComputedStyle(screen.getByTestId('halo-dot')).animation, + ).toContain('2.2s ease-out infinite'); + }); + + test('should support a static colored dot with a custom size', () => { + render( + , + ); + + expect(screen.getByTestId('static-dot')).toHaveStyle({ + animation: 'none', + backgroundColor: 'rgb(255, 165, 0)', + width: '8px', + height: '8px', + }); }); }); From 07b36efe83abdb9508d3200e65e7548b37f09f08 Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Thu, 12 Nov 2026 11:39:49 +0100 Subject: [PATCH 4/6] change: display agent OS names and support status --- src/web/pages/agents/AgentTableRow.tsx | 31 ++++- .../agents/__tests__/AgentTableRow.test.tsx | 117 +++++++++++++++++- 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/src/web/pages/agents/AgentTableRow.tsx b/src/web/pages/agents/AgentTableRow.tsx index 0364fe21b9..418142bf45 100644 --- a/src/web/pages/agents/AgentTableRow.tsx +++ b/src/web/pages/agents/AgentTableRow.tsx @@ -9,6 +9,7 @@ import { getAuthorizationLabel, } from 'web/components/label/AgentsStateLabel'; import Divider from 'web/components/layout/Divider'; +import HaloDot from 'web/components/status/HaloDot'; import TableData from 'web/components/table/TableData'; import TableRow from 'web/components/table/TableRow'; import {type RowComponentProps} from 'web/entities/EntitiesTable'; @@ -16,6 +17,8 @@ import useTranslation from 'web/hooks/useTranslation'; import AgentActions, { type AgentActionsProps, } from 'web/pages/agents/AgentActions'; +import getOperatingSystemNameFromCpe from 'web/utils/operating-system-name'; +import Theme from 'web/utils/theme'; export interface AgentTableRowProps extends AgentActionsProps, RowComponentProps { @@ -38,6 +41,19 @@ const AgentTableRow = ({ const lastUpdateTitle = entity.lastUpdate?.toString() ?? _('Never'); const ipAddressesTitle = `${_('IP Addresses')}: ${entity.ipAddresses?.join(', ') ?? _('None')} `; + const operatingSystemName = + getOperatingSystemNameFromCpe(entity.osCpe) || + entity.operatingSystem || + _('Unknown'); + const supportStatus = entity.osStatus ?? 'unknown'; + const operatingSystemTitle = [ + entity.osCpe || _('No OS CPE was reported.'), + supportStatus === 'unknown' + ? _('Operating system support status is unknown.') + : undefined, + ] + .filter(Boolean) + .join('\n'); return ( @@ -53,7 +69,20 @@ const AgentTableRow = ({ )} - {entity.operatingSystem} + + + {operatingSystemName} + + + {getConnectionStatusLabel(entity.connectionStatus)} diff --git a/src/web/pages/agents/__tests__/AgentTableRow.test.tsx b/src/web/pages/agents/__tests__/AgentTableRow.test.tsx index 09e29fda7a..b165d6f3fc 100644 --- a/src/web/pages/agents/__tests__/AgentTableRow.test.tsx +++ b/src/web/pages/agents/__tests__/AgentTableRow.test.tsx @@ -4,7 +4,7 @@ */ import {describe, expect, test, testing} from '@gsa/testing'; -import {fireEvent, rendererWith, screen} from 'web/testing'; +import {fireEvent, rendererWith, screen, within} from 'web/testing'; import dayjs from 'dayjs'; import EverythingCapabilities from 'gmp/capabilities/everything'; import Agent from 'gmp/models/agent'; @@ -33,6 +33,121 @@ describe('AgentTableRow tests', () => { expect(screen.getByTitle(/Thu.*Jan.*2026/)).toBeInTheDocument(); }); + test('should show the OS name, support status, and CPE title', () => { + const cpe = 'cpe:2.3:o:debian:debian:11:-:-:-:-:-:x86_64:-'; + const agent = new Agent({ + id: 'agent-1', + osCpe: cpe, + osStatus: 'supported', + }); + + const {render} = rendererWith({capabilities: true}); + render(); + + const osName = screen.getByText('debian'); + expect(osName).toBeInTheDocument(); + expect( + screen.getByRole('img', { + name: 'Operating system support status: supported', + }), + ).toHaveStyle({backgroundColor: '#11ab51'}); + + expect(osName).toHaveAttribute('title', cpe); + }); + + test.each(['unsupported', 'unknown'] as const)( + 'should show orange support status for %s operating systems', + status => { + const agent = new Agent({id: 'agent-1', osStatus: status}); + const {render} = rendererWith({capabilities: true}); + render(); + + expect( + screen.getByRole('img', { + name: `Operating system support status: ${status}`, + }), + ).toHaveStyle({backgroundColor: 'rgb(255, 165, 0)'}); + }, + ); + + test.each([ + [ + 'cpe:2.3:o:canonical:ubuntu_linux:24.04:-:-:-:-:-:x86_64:-', + 'ubuntu linux', + ], + ['cpe:2.3:o:almalinux:almalinux:9:-:-:-:-:-:x86_64:-', 'almalinux'], + ['cpe:2.3:o:somevendor:someproduct:37:-:-:-:-:-:x86_64:-', 'someproduct'], + ])('should display the distribution name for %s', (osCpe, name) => { + const {render} = rendererWith({capabilities: true}); + render( + , + ); + + expect(screen.getByText(name)).toBeInTheDocument(); + expect(screen.queryByText('linux')).not.toBeInTheDocument(); + }); + + test.each([ + undefined, + 'not a CPE', + 'cpe:2.3:o:vendor:*:1:-:-:-:-:-:x86_64:-', + ])('should fall back to the backend OS name for %s', osCpe => { + const {render} = rendererWith({capabilities: true}); + render( + , + ); + + expect(screen.getByText('Backend OS name')).toBeInTheDocument(); + }); + + test.each([ + {operatingSystem: 'linux', name: 'linux'}, + {operatingSystem: undefined, name: 'Unknown'}, + ])('should explain missing OS CPE for $name', ({operatingSystem, name}) => { + const {render} = rendererWith({capabilities: true}); + render( + , + ); + + const status = screen.getByRole('img', { + name: 'Operating system support status: unknown', + }); + const osName = within(status.parentElement!).getByText(name); + expect(osName).toBeInTheDocument(); + expect(osName).toHaveAttribute( + 'title', + 'No OS CPE was reported.\nOperating system support status is unknown.', + ); + expect(status).toHaveStyle({backgroundColor: 'rgb(255, 165, 0)'}); + }); + + test('should retain the CPE when explaining unknown support status', () => { + const osCpe = 'cpe:2.3:o:debian:debian:11:-:-:-:-:-:x86_64:-'; + const {render} = rendererWith({capabilities: true}); + render( + , + ); + + expect(screen.getByText('debian')).toHaveAttribute( + 'title', + `${osCpe}\nOperating system support status is unknown.`, + ); + }); + test('should call action handlers when icons are clicked', () => { const agent = new Agent({ id: '1', From cd8af36da24340f293ffdcfcc67db47ca511108c Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Thu, 12 Nov 2026 13:17:52 +0100 Subject: [PATCH 5/6] add: translations for agent os support --- public/locales/gsa-de.json | 3 ++ public/locales/gsa-en.json | 3 ++ public/locales/gsa-it.json | 3 ++ public/locales/gsa-ja.json | 3 ++ public/locales/gsa-zh_CN.json | 3 ++ public/locales/gsa-zh_TW.json | 3 ++ src/gmp/models/agent.ts | 15 ++++++++-- src/web/components/status/HaloDot.tsx | 22 +++++++-------- src/web/pages/agents/AgentTableRow.tsx | 12 +++++--- .../agents/__tests__/AgentTableRow.test.tsx | 28 +++++++++++++------ 10 files changed, 68 insertions(+), 27 deletions(-) diff --git a/public/locales/gsa-de.json b/public/locales/gsa-de.json index 25d1159d53..190d4b8f19 100644 --- a/public/locales/gsa-de.json +++ b/public/locales/gsa-de.json @@ -1426,6 +1426,7 @@ "No Notes available": "Keine Notizen vorhanden", "No NVTs available": "Keine NVTs vorhanden", "No Operating Systems available": "Keine Betriebssysteme vorhanden", + "No OS CPE was reported.": "Es wurde keine CPE für das Betriebssystem gemeldet.", "No Overrides available": "Keine Übersteuerungen vorhanden", "No parameters available": "Keine Parameter vorhanden", "No permissions available": "Keine Berechtigungen vorhanden", @@ -1540,6 +1541,8 @@ "Operating System is in use": "Betriebssysteme in Verwendung", "Operating System List": "Betriebssystemliste", "Operating System Name": "Betriebssystem-Name", + "Operating system support status is unknown.": "Der Supportstatus des Betriebssystems ist unbekannt.", + "Operating system support status: {{status}}": "Supportstatus des Betriebssystems: {{status}}", "Operating System: {{name}}": "Betriebssystem: {{name}}", "Operating Systems": "Betriebssysteme", "Operating Systems by CVSS (Total: {{count}})": "Betriebssysteme nach CVSS (Gesamt: {{count}})", diff --git a/public/locales/gsa-en.json b/public/locales/gsa-en.json index 7a02df5c33..590aba8bf2 100644 --- a/public/locales/gsa-en.json +++ b/public/locales/gsa-en.json @@ -1426,6 +1426,7 @@ "No Notes available": "No Notes available", "No NVTs available": "No NVTs available", "No Operating Systems available": "No Operating Systems available", + "No OS CPE was reported.": "No OS CPE was reported.", "No Overrides available": "No Overrides available", "No parameters available": "No parameters available", "No permissions available": "No permissions available", @@ -1540,6 +1541,8 @@ "Operating System is in use": "Operating System is in use", "Operating System List": "Operating System List", "Operating System Name": "Operating System Name", + "Operating system support status is unknown.": "Operating system support status is unknown.", + "Operating system support status: {{status}}": "Operating system support status: {{status}}", "Operating System: {{name}}": "Operating System: {{name}}", "Operating Systems": "Operating Systems", "Operating Systems by CVSS (Total: {{count}})": "Operating Systems by CVSS (Total: {{count}})", diff --git a/public/locales/gsa-it.json b/public/locales/gsa-it.json index ab63bc39ea..5e94fc5b7c 100644 --- a/public/locales/gsa-it.json +++ b/public/locales/gsa-it.json @@ -1426,6 +1426,7 @@ "No Notes available": "Nessuna nota disponibile", "No NVTs available": "Nessun NVT disponibile", "No Operating Systems available": "Nessun sistema operativo disponibile", + "No OS CPE was reported.": "Non è stato segnalato alcun CPE per il sistema operativo.", "No Overrides available": "Nessun Override disponibile", "No parameters available": "Nessun parametro disponibile", "No permissions available": "Nessuna autorizzazione disponibile", @@ -1540,6 +1541,8 @@ "Operating System is in use": "Il sistema operativo è in uso", "Operating System List": "Elenco sistemi operativi", "Operating System Name": "Nome sistema operativo", + "Operating system support status is unknown.": "Lo stato di supporto del sistema operativo è sconosciuto.", + "Operating system support status: {{status}}": "Stato di supporto del sistema operativo: {{status}}", "Operating System: {{name}}": "Sistema operativo: {{name}}", "Operating Systems": "Sistemi operativi", "Operating Systems by CVSS (Total: {{count}})": "Sistemi operativi per CVSS (Totale: {{count}})", diff --git a/public/locales/gsa-ja.json b/public/locales/gsa-ja.json index 5d5886c091..d6a437e06f 100644 --- a/public/locales/gsa-ja.json +++ b/public/locales/gsa-ja.json @@ -1426,6 +1426,7 @@ "No Notes available": "利用可能なノートがありません", "No NVTs available": "利用可能なNVTがありません", "No Operating Systems available": "利用可能なオペレーティングシステムがありません", + "No OS CPE was reported.": "", "No Overrides available": "利用可能なオーバーライドがありません", "No parameters available": "利用可能なパラメーターがありません", "No permissions available": "利用可能な権限がありません", @@ -1540,6 +1541,8 @@ "Operating System is in use": "このオペレーティングシステムは現在使用中です", "Operating System List": "オペレーティングシステム一覧", "Operating System Name": "オペレーティングシステム名", + "Operating system support status is unknown.": "", + "Operating system support status: {{status}}": "", "Operating System: {{name}}": "オペレーティングシステム: {{name}}", "Operating Systems": "オペレーティングシステム", "Operating Systems by CVSS (Total: {{count}})": "CVSS別オペレーティングシステム (合計: {{count}})", diff --git a/public/locales/gsa-zh_CN.json b/public/locales/gsa-zh_CN.json index b29b286efa..8b7c9061a9 100644 --- a/public/locales/gsa-zh_CN.json +++ b/public/locales/gsa-zh_CN.json @@ -1426,6 +1426,7 @@ "No Notes available": "没有可用的备注", "No NVTs available": "没有可用的NVTs", "No Operating Systems available": "没有可用的操作系统", + "No OS CPE was reported.": "", "No Overrides available": "没有可用的重写", "No parameters available": "没有可用的参数", "No permissions available": "没有可用的权限", @@ -1540,6 +1541,8 @@ "Operating System is in use": "操作系统正在使用中", "Operating System List": "操作系统列表", "Operating System Name": "操作系统名称", + "Operating system support status is unknown.": "", + "Operating system support status: {{status}}": "", "Operating System: {{name}}": "操作系统: {{name}}", "Operating Systems": "操作系统", "Operating Systems by CVSS (Total: {{count}})": "操作系统按CVSS分类(总计:{{count}})", diff --git a/public/locales/gsa-zh_TW.json b/public/locales/gsa-zh_TW.json index d7af5fecd2..8c3c2eb47d 100644 --- a/public/locales/gsa-zh_TW.json +++ b/public/locales/gsa-zh_TW.json @@ -1426,6 +1426,7 @@ "No Notes available": "沒有可用的備註", "No NVTs available": "", "No Operating Systems available": "", + "No OS CPE was reported.": "", "No Overrides available": "", "No parameters available": "", "No permissions available": "沒有可用的權限", @@ -1540,6 +1541,8 @@ "Operating System is in use": "", "Operating System List": "作業系統清單", "Operating System Name": "作業系統名稱", + "Operating system support status is unknown.": "", + "Operating system support status: {{status}}": "", "Operating System: {{name}}": "", "Operating Systems": "作業系統", "Operating Systems by CVSS (Total: {{count}})": "", diff --git a/src/gmp/models/agent.ts b/src/gmp/models/agent.ts index 3defa78ba1..0f8012b1e2 100644 --- a/src/gmp/models/agent.ts +++ b/src/gmp/models/agent.ts @@ -15,6 +15,9 @@ import { import {map} from 'gmp/utils/array'; import {isDefined} from 'gmp/utils/identity'; +export type OperatingSystemStatus = + (typeof OperatingSystemStatus)[keyof typeof OperatingSystemStatus]; + interface AgentScriptExecutorElement { bulk_size?: number; bulk_throttle_time_in_ms?: number; @@ -51,7 +54,7 @@ export interface AgentElement extends ModelElement { agent_version?: string; operating_system?: string; os_cpe?: string; - os_status?: 'supported' | 'unsupported' | 'unknown'; + os_status?: OperatingSystemStatus; architecture?: string; update_to_latest?: YesNo; agent_update_available?: YesNo; @@ -111,7 +114,7 @@ interface AgentProperties extends ModelProperties { agentVersion?: string; operatingSystem?: string; osCpe?: string; - osStatus?: 'supported' | 'unsupported' | 'unknown'; + osStatus?: OperatingSystemStatus; architecture?: string; updateToLatest?: boolean; agentUpdateAvailable?: boolean; @@ -124,6 +127,12 @@ interface AgentProperties extends ModelProperties { config?: AgentConfig; } +export const OperatingSystemStatus = { + supported: 'supported', + unsupported: 'unsupported', + unknown: 'unknown', +} as const; + const parseAgentScriptExecutor = ( agentScriptExecutor?: AgentScriptExecutorElement, ): AgentScriptExecutorConfig => { @@ -159,7 +168,7 @@ class Agent extends Model { readonly agentVersion?: string; readonly operatingSystem?: string; readonly osCpe?: string; - readonly osStatus?: 'supported' | 'unsupported' | 'unknown'; + readonly osStatus?: OperatingSystemStatus; readonly architecture?: string; readonly updateToLatest?: boolean; readonly agentUpdateAvailable?: boolean; diff --git a/src/web/components/status/HaloDot.tsx b/src/web/components/status/HaloDot.tsx index 6f56861496..735dc04b2d 100644 --- a/src/web/components/status/HaloDot.tsx +++ b/src/web/components/status/HaloDot.tsx @@ -6,6 +6,12 @@ import styled, {css, keyframes} from 'styled-components'; import Theme from 'web/utils/theme'; +interface HaloDotProps { + $animated?: boolean; + $color?: string; + $size?: string; +} + const pulse = keyframes` 0% { opacity: 0.85; @@ -26,20 +32,14 @@ const pulse = keyframes` } `; -interface HaloDotProps { - $animated?: boolean; - $color?: string; - $size?: string; -} - const HaloDot = styled.span` display: inline-flex; - width: ${({$size = '12px'}) => $size}; - height: ${({$size = '12px'}) => $size}; + width: ${({$size: size = '12px'}) => size}; + height: ${({$size: size = '12px'}) => size}; border-radius: 50%; - background: ${({$color = Theme.green}) => $color}; - animation: ${({$animated = true}) => - $animated ? css`${pulse} 2.2s ease-out infinite` : 'none'}; + background: ${({$color: color = Theme.green}) => color}; + animation: ${({$animated: animated = true}) => + animated ? css`${pulse} 2.2s ease-out infinite` : 'none'}; will-change: transform, box-shadow, opacity; @media (prefers-reduced-motion: reduce) { diff --git a/src/web/pages/agents/AgentTableRow.tsx b/src/web/pages/agents/AgentTableRow.tsx index 418142bf45..d90b229074 100644 --- a/src/web/pages/agents/AgentTableRow.tsx +++ b/src/web/pages/agents/AgentTableRow.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type Agent from 'gmp/models/agent'; +import {OperatingSystemStatus, type default as Agent} from 'gmp/models/agent'; import { getConnectionStatusLabel, getAuthorizationLabel, @@ -45,10 +45,10 @@ const AgentTableRow = ({ getOperatingSystemNameFromCpe(entity.osCpe) || entity.operatingSystem || _('Unknown'); - const supportStatus = entity.osStatus ?? 'unknown'; + const supportStatus = entity.osStatus ?? OperatingSystemStatus.unknown; const operatingSystemTitle = [ entity.osCpe || _('No OS CPE was reported.'), - supportStatus === 'unknown' + supportStatus === OperatingSystemStatus.unknown ? _('Operating system support status is unknown.') : undefined, ] @@ -74,7 +74,11 @@ const AgentTableRow = ({ {operatingSystemName} { test('should render authorized agent correctly', () => { @@ -38,7 +39,7 @@ describe('AgentTableRow tests', () => { const agent = new Agent({ id: 'agent-1', osCpe: cpe, - osStatus: 'supported', + osStatus: OperatingSystemStatus.supported, }); const {render} = rendererWith({capabilities: true}); @@ -55,8 +56,11 @@ describe('AgentTableRow tests', () => { expect(osName).toHaveAttribute('title', cpe); }); - test.each(['unsupported', 'unknown'] as const)( - 'should show orange support status for %s operating systems', + test.each([ + OperatingSystemStatus.unsupported, + OperatingSystemStatus.unknown, + ])( + 'should show warning support status for %s operating systems', status => { const agent = new Agent({id: 'agent-1', osStatus: status}); const {render} = rendererWith({capabilities: true}); @@ -66,7 +70,7 @@ describe('AgentTableRow tests', () => { screen.getByRole('img', { name: `Operating system support status: ${status}`, }), - ).toHaveStyle({backgroundColor: 'rgb(255, 165, 0)'}); + ).toHaveStyle({backgroundColor: Theme.severityWarnYellow}); }, ); @@ -124,13 +128,13 @@ describe('AgentTableRow tests', () => { const status = screen.getByRole('img', { name: 'Operating system support status: unknown', }); - const osName = within(status.parentElement!).getByText(name); + const osName = screen.getByText(name, {selector: 'span[title]'}); expect(osName).toBeInTheDocument(); expect(osName).toHaveAttribute( 'title', 'No OS CPE was reported.\nOperating system support status is unknown.', ); - expect(status).toHaveStyle({backgroundColor: 'rgb(255, 165, 0)'}); + expect(status).toHaveStyle({backgroundColor: Theme.severityWarnYellow}); }); test('should retain the CPE when explaining unknown support status', () => { @@ -138,7 +142,13 @@ describe('AgentTableRow tests', () => { const {render} = rendererWith({capabilities: true}); render( , ); From 1369d39f8565264930c7a936594ebd31e254e706 Mon Sep 17 00:00:00 2001 From: Daniele Mangiagli Date: Fri, 13 Nov 2026 16:13:43 +0100 Subject: [PATCH 6/6] Update AgentTableRow.test.tsx --- src/web/pages/agents/__tests__/AgentTableRow.test.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/web/pages/agents/__tests__/AgentTableRow.test.tsx b/src/web/pages/agents/__tests__/AgentTableRow.test.tsx index 026a2c52dc..7490e4e3bc 100644 --- a/src/web/pages/agents/__tests__/AgentTableRow.test.tsx +++ b/src/web/pages/agents/__tests__/AgentTableRow.test.tsx @@ -56,10 +56,7 @@ describe('AgentTableRow tests', () => { expect(osName).toHaveAttribute('title', cpe); }); - test.each([ - OperatingSystemStatus.unsupported, - OperatingSystemStatus.unknown, - ])( + test.each([OperatingSystemStatus.unsupported, OperatingSystemStatus.unknown])( 'should show warning support status for %s operating systems', status => { const agent = new Agent({id: 'agent-1', osStatus: status});