Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}})",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/gsa-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}})",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/gsa-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}})",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/gsa-ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "利用可能な権限がありません",
Expand Down Expand Up @@ -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}})",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/gsa-zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "没有可用的权限",
Expand Down Expand Up @@ -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}})",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/gsa-zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "沒有可用的權限",
Expand Down Expand Up @@ -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}})": "",
Expand Down
15 changes: 15 additions & 0 deletions src/gmp/models/__tests__/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
21 changes: 21 additions & 0 deletions src/gmp/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +53,8 @@ export interface AgentElement extends ModelElement {
updater_version?: string;
agent_version?: string;
operating_system?: string;
os_cpe?: string;
os_status?: OperatingSystemStatus;
architecture?: string;
update_to_latest?: YesNo;
agent_update_available?: YesNo;
Expand Down Expand Up @@ -108,6 +113,8 @@ interface AgentProperties extends ModelProperties {
updaterVersion?: string;
agentVersion?: string;
operatingSystem?: string;
osCpe?: string;
osStatus?: OperatingSystemStatus;
architecture?: string;
updateToLatest?: boolean;
agentUpdateAvailable?: boolean;
Expand All @@ -120,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 => {
Expand Down Expand Up @@ -154,6 +167,8 @@ class Agent extends Model {
readonly updaterVersion?: string;
readonly agentVersion?: string;
readonly operatingSystem?: string;
readonly osCpe?: string;
readonly osStatus?: OperatingSystemStatus;
readonly architecture?: string;
readonly updateToLatest?: boolean;
readonly agentUpdateAvailable?: boolean;
Expand All @@ -175,6 +190,8 @@ class Agent extends Model {
updaterVersion,
agentVersion,
operatingSystem,
osCpe,
osStatus,
architecture,
updateToLatest,
agentUpdateAvailable,
Expand All @@ -198,6 +215,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;
Expand Down Expand Up @@ -231,6 +250,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)
Expand Down
19 changes: 13 additions & 6 deletions src/web/components/status/HaloDot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
* 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';

interface HaloDotProps {
$animated?: boolean;
$color?: string;
$size?: string;
}

const pulse = keyframes`
0% {
opacity: 0.85;
Expand All @@ -26,13 +32,14 @@ const pulse = keyframes`
}
`;

const HaloDot = styled.span`
const HaloDot = styled.span<HaloDotProps>`
display: inline-flex;
width: 12px;
height: 12px;
width: ${({$size: size = '12px'}) => size};
height: ${({$size: size = '12px'}) => size};
border-radius: 50%;
background: ${Theme.green};
animation: ${pulse} 2.2s ease-out infinite;
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) {
Expand Down
26 changes: 26 additions & 0 deletions src/web/components/status/__tests__/HaloDot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<HaloDot
$animated={false}
$color="orange"
$size="8px"
data-testid="static-dot"
/>,
);

expect(screen.getByTestId('static-dot')).toHaveStyle({
animation: 'none',
backgroundColor: 'rgb(255, 165, 0)',
width: '8px',
height: '8px',
});
});
});
37 changes: 35 additions & 2 deletions src/web/pages/agents/AgentTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
* 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,
} 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';
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<Agent> {
Expand All @@ -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 ?? OperatingSystemStatus.unknown;
const operatingSystemTitle = [
entity.osCpe || _('No OS CPE was reported.'),
supportStatus === OperatingSystemStatus.unknown
? _('Operating system support status is unknown.')
: undefined,
]
.filter(Boolean)
.join('\n');

return (
<TableRow data-testid={dataTestId}>
Expand All @@ -53,7 +69,24 @@ const AgentTableRow = ({
)}
</Divider>
</TableData>
<TableData>{entity.operatingSystem}</TableData>
<TableData>
<Divider align={['start', 'center']}>
<span title={operatingSystemTitle}>{operatingSystemName}</span>
<HaloDot
$animated={false}
$color={
supportStatus === OperatingSystemStatus.supported
? Theme.green
: Theme.severityWarnYellow
}
$size="8px"
aria-label={_('Operating system support status: {{status}}', {
status: supportStatus,
})}
role="img"
/>
</Divider>
</TableData>
<TableData title={`${_('Last Contact')}: ${lastUpdateTitle} `}>
{getConnectionStatusLabel(entity.connectionStatus)}
</TableData>
Expand Down
Loading