Skip to content

Commit

Permalink
Add: Added a new message type for the case that a CPE or a CVE cannot…
Browse files Browse the repository at this point in the history
… be found
  • Loading branch information
timopollmeier authored Jun 14, 2023
2 parents c0da6db + 463468f commit 44c6ea6
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 4 deletions.
2 changes: 2 additions & 0 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
@@ -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 ",
Expand Down
60 changes: 60 additions & 0 deletions src/web/components/error/message.js
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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
}) => (
<MessageContainer data-testid={dataTestId}>
<Divider margin="15px" align={['start', 'start']}>
<StNonAvailableIcon size="medium" />
<Layout {...props}>
<Divider>
<b data-testid="message">{message}</b>
{isDefined(details) && (
<span data-testid="message-details">{details}</span>
)}
</Divider>
{children}
</Layout>
</Divider>
</MessageContainer>
);

Message.propTypes = {
'data-testid': PropTypes.string,
details: PropTypes.string,
message: PropTypes.string,
};

export default Message;
30 changes: 30 additions & 0 deletions src/web/components/error/messagecontainer.js
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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:
41 changes: 37 additions & 4 deletions src/web/entity/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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 (
<Message
flex="column"
message={_(
'The {{entity}} you were looking for could not be found.',
{
entity: typeName(entityType),
},
)}
>
<MessageContent>{content}</MessageContent>
</Message>
);
}

Expand All @@ -171,6 +203,7 @@ class EntityPage extends React.Component {
</ErrorMessage>
);
}

return <ErrorMessage message={entityError.message} />;
}
return null;
Expand Down

0 comments on commit 44c6ea6

Please sign in to comment.