From 752c2c49e71eaf3408811e5493014fca90c342a2 Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Thu, 8 Jun 2023 12:49:02 +0200 Subject: [PATCH 1/2] Added a new message type. Added a new message type for the case that a CPE or a CVE cannot be found. --- src/web/components/error/message.js | 60 ++++++++++++++++++++ src/web/components/error/messagecontainer.js | 30 ++++++++++ src/web/entity/page.js | 41 +++++++++++-- 3 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/web/components/error/message.js create mode 100644 src/web/components/error/messagecontainer.js diff --git a/src/web/components/error/message.js b/src/web/components/error/message.js new file mode 100644 index 0000000000..7690ce1bca --- /dev/null +++ b/src/web/components/error/message.js @@ -0,0 +1,60 @@ +/* Copyright (C) 2018-2022 Greenbone AG + * + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +import React from 'react'; + +import {isDefined} from 'gmp/utils/identity'; + +import Divider from 'web/components/layout/divider'; +import Layout from 'web/components/layout/layout'; + +import StNonAvailableIcon from 'web/components/icon/stnonavailableicon'; + +import PropTypes from 'web/utils/proptypes'; + +import MessageContainer from './messagecontainer'; + +const Message = ({ + message, + details, + children, + 'data-testid': dataTestId, + ...props +}) => ( + + + + + + {message} + {isDefined(details) && ( + {details} + )} + + {children} + + + +); + +Message.propTypes = { + 'data-testid': PropTypes.string, + details: PropTypes.string, + message: PropTypes.string, +}; + +export default Message; diff --git a/src/web/components/error/messagecontainer.js b/src/web/components/error/messagecontainer.js new file mode 100644 index 0000000000..0295ec7cfd --- /dev/null +++ b/src/web/components/error/messagecontainer.js @@ -0,0 +1,30 @@ +/* Copyright (C) 2018-2022 Greenbone AG + * + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +import styled from 'styled-components'; + +import Layout from 'web/components/layout/layout'; + +const MessageContainer = styled(Layout)` + padding: 15px; + margin: 15px 15px 15px 15px; + border: 1px solid; +`; + +export default MessageContainer; + +// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/entity/page.js b/src/web/entity/page.js index cef9c2c703..31ab0e6f27 100644 --- a/src/web/entity/page.js +++ b/src/web/entity/page.js @@ -33,6 +33,8 @@ import Toolbar from 'web/components/bar/toolbar'; import ErrorMessage from 'web/components/error/errormessage'; +import Message from 'web/components/error/message'; + import Layout from 'web/components/layout/layout'; import Loading from 'web/components/loading/loading'; @@ -49,6 +51,10 @@ const ErrorContent = styled.div` white-space: pre; `; +const MessageContent = styled.div` + white-space: pre; +`; + class EntityPage extends React.Component { constructor(...args) { super(...args); @@ -146,14 +152,40 @@ class EntityPage extends React.Component { {entity: typeName(entityType)}, ); + if (entityType === 'cpe') { + content = _( + '\nThis could have the following reasons:\n' + + '1. The CPE might not be included in the official NVD CPE dictionary ' + + 'yet, and no additional information is available.\n' + + '2. You might have followed an incorrect link and the CPE does ' + + 'not exist.', + ); + } + if (entityType === 'cve') { content = _( '\nThis could have the following reasons:\n' + - '1. You might have followed an incorrect link and the CVE does ' + - 'not exist\n' + - '2. The CVE might not be included in the SCAP database yet. ' + + '1. The CVE might not be included in the SCAP database yet. ' + 'For new CVEs it can take a month or more until they become ' + - 'available.', + 'available.\n' + + '2. You might have followed an incorrect link and the CVE does ' + + 'not exist.', + ); + } + + if (entityType === 'cpe' || entityType === 'cve') { + return ( + + {content} + ); } @@ -171,6 +203,7 @@ class EntityPage extends React.Component { ); } + return ; } return null; From 4bd8f1a5161595291fac2f371d7e9cf66c3dedef Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Wed, 14 Jun 2023 13:23:51 +0200 Subject: [PATCH 2/2] Added some translation. --- public/locales/gsa-de.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/locales/gsa-de.json b/public/locales/gsa-de.json index 01e72d8196..1cb445767f 100644 --- a/public/locales/gsa-de.json +++ b/public/locales/gsa-de.json @@ -1,5 +1,7 @@ { "\nThis could have the following reasons:\n1. You might have followed an incorrect link and the CVE does not exist\n2. The CVE might not be included in the SCAP database yet. For new CVEs it can take a month or more until they become available.": "\nDies kann folgende Ursachen haben:\n1. Möglicherweise war der Link für diese CVE inkorrekt und sie existiert nicht.\n2. Die CVE ist vielleicht noch nicht in der SCAP-Datenbank enthalten. Für neue CVEs kann es einen Monat oder länger dauern bis sie verfügbar sind.", + "\nThis could have the following reasons:\n1. The CVE might not be included in the SCAP database yet. For new CVEs it can take a month or more until they become available.\n2. You might have followed an incorrect link and the CVE does not exist.": "\nDies kann folgende Ursachen haben:\n1. Die CVE ist vielleicht noch nicht in der SCAP-Datenbank enthalten. Für neue CVEs kann es einen Monat oder länger dauern bis sie verfügbar sind.\n2. Möglicherweise war der Link für diese CVE inkorrekt und sie existiert nicht.", + "\nThis could have the following reasons:\n1. The CPE might not be included in the official NVD CPE dictionary yet, and no additional information is available.\n2. You might have followed an incorrect link and the CPE does not exist.": "\nDies kann folgende Ursachen haben:\n1. Die CPE ist vielleicht noch nicht im offiziellen NVD CPE Verzeichnis enthalten und es sind keine weiteren Daten verfügbar. \n2. Möglicherweise war der Link für diese CPE inkorrekt und sie existiert nicht.", "\nYou might have followed an incorrect link and the {{entity}} does not exist.": "Möglicherweise sind Sie einem fehlerhaften Link gefolgt und die Ressource existiert nicht.", " on Port {{port}}": " auf Port {{port}}", " on port ": " auf Port ",