Skip to content

Commit

Permalink
if details not defined, then choose first OS from identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
saberlynx committed Oct 24, 2019
1 parent 7fcb517 commit e9eb503
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions gsa/src/web/pages/hosts/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import React from 'react';

import 'core-js/features/array/find';

import _ from 'gmp/locale';

import {isDefined} from 'gmp/utils/identity';
Expand Down Expand Up @@ -112,13 +114,23 @@ const Row = ({
onToggleDetailsClick,
...props
}) => {
const {details = {}} = entity;
const os_cpe = isDefined(details.best_os_cpe)
? details.best_os_cpe.value
: undefined;
const {details = {}, identifiers} = entity;

let os_cpe;

if (isDefined(details) && isDefined(details.best_os_cpe)) {
os_cpe = details.best_os_cpe.value;
} else if (isDefined(identifiers)) {
const firstOs = identifiers.find(identifier => identifier.name === 'OS');
os_cpe = isDefined(firstOs) ? firstOs.value : undefined;
} else {
os_cpe = undefined;
}

const os_txt = isDefined(details.best_os_txt)
? details.best_os_txt.value
: undefined;

return (
<TableRow>
<TableData flex="column">
Expand Down

0 comments on commit e9eb503

Please sign in to comment.