Skip to content

Commit

Permalink
Add: Certificate info for TippingPoint alerts
Browse files Browse the repository at this point in the history
The details of alerts using the TippingPoint SMS method now shows
information about the TLS certificate.

This way it is possible to check if the correct certificate is
configured or not.
  • Loading branch information
timopollmeier committed May 9, 2023
1 parent 8aff57a commit fada909
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 52 deletions.
1 change: 1 addition & 0 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@
"No first result available.": "Kein erstes Ergebnis verfügbar.",
"No hosts available": "Keine Hosts vorhanden",
"No information about the Operation System": "Keine Information über das Betriebssystem",
"No information available for existing file. File may not be a correct certificate.": "Keine Informationen für vorhandene Datei verfügbar. Datei ist möglicherweise kein korrektes Zertifikat.",
"No license available": "Keine Lizenz vorhanden",
"No parameters available": "Keine Parameter vorhanden",
"No permissions available": "Keine Berechtigungen vorhanden",
Expand Down
8 changes: 7 additions & 1 deletion src/gmp/models/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {isDefined, isObject} from 'gmp/utils/identity';
import {isEmpty} from 'gmp/utils/string';
import {forEach, map} from 'gmp/utils/array';

import {parseYesNo, YES_VALUE} from 'gmp/parser';
import {parseDate, parseYesNo, YES_VALUE} from 'gmp/parser';

import Model, {parseModelFromElement} from 'gmp/model';

Expand Down Expand Up @@ -82,6 +82,12 @@ const create_values = data => {
}
delete obj._id;
}
if (key === 'certificate_info') {
obj.activationTime = parseDate(obj.activation_time);
obj.expirationTime = parseDate(obj.expiration_time);
delete obj.activation_time;
delete obj.expiration_time;
}
values[key] = obj;
}

Expand Down
85 changes: 85 additions & 0 deletions src/web/components/certinfo/certinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Copyright (C) 2023 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 _ from 'gmp/locale';

import {isDefined} from 'gmp/utils/identity';

import PropTypes from 'web/utils/proptypes';

import DateTime from 'web/components/date/datetime';

import {Col} from 'web/entity/page';

import InfoTable from 'web/components/table/infotable';
import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import TableRow from 'web/components/table/row';

const CertInfo = ({info}) => {
const {activationTime, expirationTime, issuer, md5_fingerprint} = info;
return (
<InfoTable>
<colgroup>
<Col width="10%" />
<Col width="90%" />
</colgroup>
<TableBody>
<TableRow>
<TableData>{_('Activation')}</TableData>
<TableData>
{isDefined(activationTime) ? (
<DateTime date={activationTime} />
) : (
_('N/A')
)}
</TableData>
</TableRow>

<TableRow>
<TableData>{_('Expiration')}</TableData>
<TableData>
{isDefined(expirationTime) ? (
<DateTime date={expirationTime} />
) : (
_('N/A')
)}
</TableData>
</TableRow>

<TableRow>
<TableData>{_('MD5 Fingerprint')}</TableData>
<TableData>{md5_fingerprint}</TableData>
</TableRow>

<TableRow>
<TableData>{_('Issuer')}</TableData>
<TableData>{issuer}</TableData>
</TableRow>
</TableBody>
</InfoTable>
);
};

CertInfo.propTypes = {
info: PropTypes.object.isRequired,
};

export default CertInfo;
21 changes: 20 additions & 1 deletion src/web/pages/alerts/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ import {
} from 'gmp/models/alert';

import PropTypes from 'web/utils/proptypes';

import HorizontalSep from 'web/components/layout/horizontalsep';

import CertInfo from 'web/components/certinfo/certinfo';

import DetailsLink from 'web/components/link/detailslink';

import SimpleTable from 'web/components/table/simpletable';
Expand Down Expand Up @@ -629,6 +630,24 @@ const Method = ({method = {}, details = false, reportFormats = []}) => {
</TableData>
</TableRow>
)}
{isDefined(data.tp_sms_tls_certificate?.value) && (
<TableRow>
<TableData>{_('TLS Certificate')}</TableData>
<TableData>
{isDefined(
data.tp_sms_tls_certificate?.certificate_info,
) ? (
<CertInfo
info={data.tp_sms_tls_certificate.certificate_info}
/>
) : (
_(
'No information available for existing file. File may not be a correct certificate.',
)
)}
</TableData>
</TableRow>
)}
</TableBody>
</Table>
</div>
Expand Down
52 changes: 2 additions & 50 deletions src/web/pages/scanners/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,19 @@ import PropTypes from 'web/utils/proptypes';

import DetailsBlock from 'web/entity/block';

import CertInfo from 'web/components/certinfo/certinfo';

import Layout from 'web/components/layout/layout';

import DetailsLink from 'web/components/link/detailslink';

import DateTime from 'web/components/date/datetime';
import InfoTable from 'web/components/table/infotable';
import TableBody from 'web/components/table/body';
import TableData, {TableDataAlignTop} from 'web/components/table/data';
import TableRow from 'web/components/table/row';

import {Col} from 'web/entity/page';

const CertInfo = ({info}) => {
const {activationTime, expirationTime, issuer, md5_fingerprint} = info;
return (
<InfoTable>
<colgroup>
<Col width="10%" />
<Col width="90%" />
</colgroup>
<TableBody>
<TableRow>
<TableData>{_('Activation')}</TableData>
<TableData>
{isDefined(activationTime) ? (
<DateTime date={activationTime} />
) : (
_('N/A')
)}
</TableData>
</TableRow>

<TableRow>
<TableData>{_('Expiration')}</TableData>
<TableData>
{isDefined(expirationTime) ? (
<DateTime date={expirationTime} />
) : (
_('N/A')
)}
</TableData>
</TableRow>

<TableRow>
<TableData>{_('MD5 Fingerprint')}</TableData>
<TableData>{md5_fingerprint}</TableData>
</TableRow>

<TableRow>
<TableData>{_('Issuer')}</TableData>
<TableData>{issuer}</TableData>
</TableRow>
</TableBody>
</InfoTable>
);
};

CertInfo.propTypes = {
info: PropTypes.object.isRequired,
};

const ScannerDetails = ({entity}) => {
const {
comment,
Expand Down

0 comments on commit fada909

Please sign in to comment.