Skip to content

Commit

Permalink
Merge branch 'master' into clean_up_explicit_compliance_master
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahd93 authored Aug 16, 2019
2 parents 5f73832 + d09f1f9 commit c88c97e
Show file tree
Hide file tree
Showing 29 changed files with 1,335 additions and 5 deletions.
14 changes: 14 additions & 0 deletions gsa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/commands/targets.js
${GSA_SRC_DIR}/src/gmp/commands/tasks.js
${GSA_SRC_DIR}/src/gmp/commands/tickets.js
${GSA_SRC_DIR}/src/gmp/commands/tlscertificates.js
${GSA_SRC_DIR}/src/gmp/commands/trashcan.js
${GSA_SRC_DIR}/src/gmp/commands/users.js
${GSA_SRC_DIR}/src/gmp/commands/vulns.js
Expand Down Expand Up @@ -167,6 +168,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/models/target.js
${GSA_SRC_DIR}/src/gmp/models/task.js
${GSA_SRC_DIR}/src/gmp/models/ticket.js
${GSA_SRC_DIR}/src/gmp/models/tlscertificate.js
${GSA_SRC_DIR}/src/gmp/models/user.js
${GSA_SRC_DIR}/src/gmp/models/vulnerability.js
${GSA_SRC_DIR}/src/gmp/parser.js
Expand Down Expand Up @@ -376,6 +378,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/components/icon/targeticon.js
${GSA_SRC_DIR}/src/web/components/icon/taskicon.js
${GSA_SRC_DIR}/src/web/components/icon/ticketicon.js
${GSA_SRC_DIR}/src/web/components/icon/tlscertificateicon.js
${GSA_SRC_DIR}/src/web/components/icon/toggle3dicon.js
${GSA_SRC_DIR}/src/web/components/icon/trashcanicon.js
${GSA_SRC_DIR}/src/web/components/icon/trashdeleteicon.js
Expand Down Expand Up @@ -485,6 +488,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/components/icon/svg/target.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/task.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/ticket.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/tlscertificate.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/toggle3d.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/trashcan.svg
${GSA_SRC_DIR}/src/web/components/icon/svg/trend_down.svg
Expand Down Expand Up @@ -1015,6 +1019,16 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/tickets/editdialog.js
${GSA_SRC_DIR}/src/web/pages/tickets/listpage.js
${GSA_SRC_DIR}/src/web/pages/tickets/table.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/component.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/details.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/filterdialog.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/listpage.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/row.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/table.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/dashboard/index.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/dashboard/loaders.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/dashboard/modifieddisplay.js
${GSA_SRC_DIR}/src/web/pages/tlscertificates/dashboard/timestatusdisplay.js
${GSA_SRC_DIR}/src/web/pages/users/component.js
${GSA_SRC_DIR}/src/web/pages/users/confirmdeletedialog.js
${GSA_SRC_DIR}/src/web/pages/users/details.js
Expand Down
2 changes: 2 additions & 0 deletions gsa/src/gmp/capabilities/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const types = {
reportformats: 'report_format',
scanconfig: 'config',
scanconfigs: 'config',
tlsCertificate: 'tls_certificate',
tlsCertificates: 'tls_certificate',
};

const convertType = type => {
Expand Down
65 changes: 65 additions & 0 deletions gsa/src/gmp/commands/tlscertificates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* Copyright (C) 2019 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import registerCommand from '../command';

import TlsCertificate from '../models/tlscertificate';

import EntitiesCommand from './entities';
import EntityCommand from './entity';

class TlsCertificateCommand extends EntityCommand {
constructor(http) {
super(http, 'tls_certificate', TlsCertificate);
}

getElementFromRoot(root) {
return root.get_tls_certificate.get_tls_certificates_response
.tls_certificate;
}
}

class TlsCertificatesCommand extends EntitiesCommand {
constructor(http) {
super(http, 'tls_certificate', TlsCertificate);
}

getTimeStatusAggregates({filter} = {}) {
return this.getAggregates({
aggregate_type: 'tls_certificate',
group_column: 'time_status',
filter,
});
}

getModifiedAggregates({filter} = {}) {
return this.getAggregates({
aggregate_type: 'tls_certificate',
group_column: 'modified',
filter,
});
}
getEntitiesResponse(root) {
return root.get_tls_certificates.get_tls_certificates_response;
}
}

registerCommand('tlscertificate', TlsCertificateCommand);
registerCommand('tlscertificates', TlsCertificatesCommand);

// vim: set ts=2 sw=2 tw=80:
1 change: 1 addition & 0 deletions gsa/src/gmp/gmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import './commands/tags.js';
import './commands/targets.js';
import './commands/tasks.js';
import './commands/tickets.js';
import './commands/tlscertificates.js';
import './commands/trashcan.js';
import './commands/users.js';
import './commands/vulns.js';
Expand Down
3 changes: 3 additions & 0 deletions gsa/src/gmp/models/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ export const TARGETS_FILTER_FILTER = Filter.fromString('type=target');
export const TASKS_FILTER_FILTER = Filter.fromString('type=task');
export const TAGS_FILTER_FILTER = Filter.fromString('type=tag');
export const TICKETS_FILTER_FILTER = Filter.fromString('type=ticket');
export const TLS_CERTIFICATES_FILTER_FILTER = Filter.fromString(
'type=tls_certificate',
);
export const USERS_FILTER_FILTER = Filter.fromString('type=user');
export const VULNS_FILTER_FILTER = Filter.fromString('type=vuln');

Expand Down
103 changes: 103 additions & 0 deletions gsa/src/gmp/models/tlscertificate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* Copyright (C) 2019 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import {_l} from 'gmp/locale/lang';

import Model from '../model';

import {parseBoolean, parseDate} from 'gmp/parser';
import {forEach} from 'gmp/utils/array';
import {isDefined} from 'gmp/utils/identity';

export const TIME_STATUS = {
inactive: 'inactive',
valid: 'valid',
expired: 'expired',
unknown: 'unknown',
};

export const TIME_STATUS_TRANSLATIONS = {
[TIME_STATUS.expired]: _l('Expired'),
[TIME_STATUS.inactive]: _l('Inactive'),
[TIME_STATUS.unknown]: _l('Unknown'),
[TIME_STATUS.valid]: _l('Valid'),
};

export const getTranslatableTimeStatus = status =>
`${TIME_STATUS_TRANSLATIONS[status]}`;

class TlsCertificate extends Model {
static entityType = 'tlscertificate';

parseProperties(elem) {
const ret = super.parseProperties(elem);

ret.issuerDn = elem.issuer_dn;
delete ret.issuer_dn;

ret.activationTime = parseDate(elem.activation_time);
delete ret.activation_time;

ret.expirationTime = parseDate(elem.expiration_time);
delete ret.expiration_time;

ret.lastCollected = parseDate(elem.last_collected);
delete ret.last_collected;

ret.timeStatus = elem.time_status;
delete ret.time_status;

const sourceReportIds = new Set();
const sourceHostIps = new Set();
const sourcePorts = new Set();

if (isDefined(ret.sources)) {
forEach(ret.sources.source, source => {
if (isDefined(source.origin)) {
if (source.origin.origin_type === 'Report') {
sourceReportIds.add(source.origin.origin_id);
}
}
if (isDefined(source.location)) {
if (isDefined(source.location.host)) {
sourceHostIps.add(source.location.host.ip);
}
if (isDefined(source.location.port)) {
sourcePorts.add(source.location.port);
}
}
});
}

ret.sourceReportIds = [...sourceReportIds];
ret.sourceHostIps = [...sourceHostIps];
ret.sourcePorts = [...sourcePorts];

delete ret.sources;

ret.valid = parseBoolean(elem.valid);
ret.trust = parseBoolean(elem.trust);

return ret;
}
}

export default TlsCertificate;

// vim: set ts=2 sw=2 tw=80:
3 changes: 3 additions & 0 deletions gsa/src/gmp/utils/entitytype.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const TYPES = {
port_list: 'portlist',
port_range: 'portrange',
report_format: 'reportformat',
tls_certificate: 'tlscertificate',
vuln: 'vulnerability',
};

Expand Down Expand Up @@ -100,6 +101,7 @@ const ENTITY_TYPES = {
target: _l('Target'),
task: _l('Task'),
ticket: _l('Ticket'),
tlscertificate: _l('TLS Certificate'),
user: _l('User'),
vulnerability: _l('Vulnerability'),
};
Expand All @@ -125,6 +127,7 @@ const CMD_TYPES = {
portlist: 'port_list',
portrange: 'port_range',
reportformat: 'report_format',
tlscertificate: 'tls_certificate',
vulnerability: 'vuln',
};

Expand Down
21 changes: 18 additions & 3 deletions gsa/src/web/components/bar/menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ const MenuBar = ({isLoggedIn, capabilities}) => {
false,
);

const mayOpAssets = ['assets', 'tls_certificates'].reduce(
(sum, cur) => sum || capabilities.mayAccess(cur),
false,
);

return (
<React.Fragment>
<MenuBarPlaceholder />
Expand Down Expand Up @@ -149,10 +154,20 @@ const MenuBar = ({isLoggedIn, capabilities}) => {
)}
</Menu>
)}
{capabilities.mayAccess('assets') && (
{mayOpAssets && (
<Menu title={_('Assets')}>
<MenuEntry title={_('Hosts')} to="hosts" />
<MenuEntry title={_('Operating Systems')} to="operatingsystems" />
{capabilities.mayAccess('assets') && (
<MenuEntry title={_('Hosts')} to="hosts" />
)}
{capabilities.mayAccess('assets') && (
<MenuEntry
title={_('Operating Systems')}
to="operatingsystems"
/>
)}
{capabilities.mayAccess('tls_certificates') && (
<MenuEntry title={_('TLS Certificates')} to="tlscertificates" />
)}
</Menu>
)}
{mayOpResilience && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TlsCertificateIcon component tests should render 1`] = `
.c0 {
height: 16px;
width: 16px;
line-height: 16px;
}
.c0 * {
height: inherit;
width: inherit;
}
<span
class="c0 "
data-testid="svg-icon"
>
<svg>
tlscertificate.svg
</svg>
</span>
`;
28 changes: 28 additions & 0 deletions gsa/src/web/components/icon/__tests__/tlscertificateicon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Copyright (C) 2019 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import {testIcon} from 'web/components/icon/testing';

import TlsCertificateIcon from '../tlscertificateicon';

describe('TlsCertificateIcon component tests', () => {
testIcon(TlsCertificateIcon);
});

// vim: set ts=2 sw=2 tw=80:
15 changes: 15 additions & 0 deletions gsa/src/web/components/icon/svg/tlscertificate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c88c97e

Please sign in to comment.