diff --git a/CHANGELOG.md b/CHANGELOG.md index 407b7d8d89..bb6dc7e86c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [21.04] - 2021-04-16 ### Added +- Allow to add ssh elevate credential to target dialog and display elevate credential in details [#2954](https://github.com/greenbone/gsa/pull/2954) - Allow to set unix socket permissions for gsad [#2816](https://github.com/greenbone/gsa/pull/2816) - Added CVSS date to NVT details [#2802](https://github.com/greenbone/gsa/pull/2802) - Added option to allow to scan simultaneous IPs to targets diff --git a/gsa/public/locales/gsa-de.json b/gsa/public/locales/gsa-de.json index 51a1b77da4..6c6bd41f85 100644 --- a/gsa/public/locales/gsa-de.json +++ b/gsa/public/locales/gsa-de.json @@ -385,6 +385,7 @@ "Create new SMB credential": "Neue SMB-Anmeldedaten erstellen", "Create new SNMP credential": "Neue SNMP-Anmeldedaten erstellen", "Create new SSH credential": "Neue SSH-Anmeldedaten erstellen", + "Create new SSH elevate credential": "Neue SSH-Anmeldedaten für zusätzliche Berechtigungen erstellen", "Create new Ticket": "Neues Ticket erstellen", "Create new Ticket for Result": "Neues Ticket für Ergebnis erstellen", "Create new Ticket for Result {{- name}}": "Neues Ticket für Ergebnis ({{- name}}) erstellen", @@ -561,6 +562,7 @@ "Edit process": "Prozess bearbeiten", "Edit {{entity}}": "{{entity}} bearbeiten", "Effect": "Auswirkung", + "Elevate privileges": "Berechtigungen erweitern", "Email": "E-Mail", "Email Encryption": "E-Mail-Verschlüsselung", "Email report to": "E-Mail-Bericht an", @@ -1390,6 +1392,7 @@ "SSH Credential": "SSH-Anmeldedaten", "SSH authentication was successful": "SSH-Authentifizierung war erfolgreich", "SSH authentication was unsuccessful": "SSH-Authentifizierung ist fehlgeschlagen", + "SSH elevate credential ": "SSH-Anmeldedaten für zusätzliche Berechtigungen ", "SSL / TLS Certificate": "SSL-/TLS-Zertifikat", "Sa.": "Sa.", "Same": "Gleich", diff --git a/gsa/src/gmp/commands/targets.js b/gsa/src/gmp/commands/targets.js index d79444b8e7..84cd47df5b 100644 --- a/gsa/src/gmp/commands/targets.js +++ b/gsa/src/gmp/commands/targets.js @@ -23,6 +23,8 @@ import registerCommand from 'gmp/command'; import Target from 'gmp/models/target'; +import {UNSET_VALUE} from 'web/utils/render'; + import EntitiesCommand from './entities'; import EntityCommand from './entity'; @@ -47,6 +49,7 @@ class TargetCommand extends EntityCommand { alive_tests, allowSimultaneousIPs, ssh_credential_id = 0, + ssh_elevate_credential_id = 0, port, smb_credential_id = 0, esxi_credential_id = 0, @@ -71,6 +74,10 @@ class TargetCommand extends EntityCommand { alive_tests, port, ssh_credential_id, + ssh_elevate_credential_id: + ssh_credential_id === UNSET_VALUE + ? UNSET_VALUE + : ssh_elevate_credential_id, smb_credential_id, esxi_credential_id, snmp_credential_id, @@ -95,6 +102,7 @@ class TargetCommand extends EntityCommand { alive_tests, allowSimultaneousIPs, ssh_credential_id = 0, + ssh_elevate_credential_id = 0, port, smb_credential_id = 0, esxi_credential_id = 0, @@ -124,6 +132,10 @@ class TargetCommand extends EntityCommand { smb_credential_id, snmp_credential_id, ssh_credential_id, + ssh_elevate_credential_id: + ssh_credential_id === UNSET_VALUE + ? UNSET_VALUE + : ssh_elevate_credential_id, target_source, target_exclude_source, }); diff --git a/gsa/src/gmp/models/credential.js b/gsa/src/gmp/models/credential.js index 948821a44d..13af869c0b 100644 --- a/gsa/src/gmp/models/credential.js +++ b/gsa/src/gmp/models/credential.js @@ -37,6 +37,8 @@ export const SSH_CREDENTIAL_TYPES = [ USERNAME_SSH_KEY_CREDENTIAL_TYPE, ]; +export const SSH_ELEVATE_CREDENTIAL_TYPES = [USERNAME_PASSWORD_CREDENTIAL_TYPE]; + export const SMB_CREDENTIAL_TYPES = [USERNAME_PASSWORD_CREDENTIAL_TYPE]; export const ESXI_CREDENTIAL_TYPES = [USERNAME_PASSWORD_CREDENTIAL_TYPE]; diff --git a/gsa/src/gmp/models/target.js b/gsa/src/gmp/models/target.js index 9dff57a016..d61b5792f4 100644 --- a/gsa/src/gmp/models/target.js +++ b/gsa/src/gmp/models/target.js @@ -30,6 +30,7 @@ export const TARGET_CREDENTIAL_NAMES = [ 'snmp_credential', 'ssh_credential', 'esxi_credential', + 'ssh_elevate_credential', ]; class Target extends Model { diff --git a/gsa/src/web/pages/targets/component.js b/gsa/src/web/pages/targets/component.js index 6fcaf621c5..e41442809a 100644 --- a/gsa/src/web/pages/targets/component.js +++ b/gsa/src/web/pages/targets/component.js @@ -69,6 +69,9 @@ class TargetComponent extends React.Component { this, ); this.handleSshCredentialChange = this.handleSshCredentialChange.bind(this); + this.handleSshElevateCredentialChange = this.handleSshElevateCredentialChange.bind( + this, + ); this.handleSmbCredentialChange = this.handleSmbCredentialChange.bind(this); this.handleSnmpCredentialChange = this.handleSnmpCredentialChange.bind( this, @@ -128,6 +131,7 @@ class TargetComponent extends React.Component { smb_credential_id: id_or__(entity.smb_credential), snmp_credential_id: id_or__(entity.snmp_credential), ssh_credential_id: id_or__(entity.ssh_credential), + ssh_elevate_credential_id: id_or__(entity.ssh_elevate_credential), }); }); } else { @@ -154,6 +158,7 @@ class TargetComponent extends React.Component { smb_credential_id: undefined, snmp_credential_id: undefined, ssh_credential_id: undefined, + ssh_elevate_credential_id: undefined, target_source: undefined, target_exclude_source: undefined, target_title: _('New Target'), @@ -269,6 +274,10 @@ class TargetComponent extends React.Component { this.setState({ssh_credential_id}); } + handleSshElevateCredentialChange(ssh_elevate_credential_id) { + this.setState({ssh_elevate_credential_id}); + } + handleSnmpCredentialChange(snmp_credential_id) { this.setState({snmp_credential_id}); } @@ -327,6 +336,7 @@ class TargetComponent extends React.Component { smb_credential_id, snmp_credential_id, ssh_credential_id, + ssh_elevate_credential_id, target_source, target_exclude_source, target_title, @@ -377,6 +387,7 @@ class TargetComponent extends React.Component { smb_credential_id={smb_credential_id} snmp_credential_id={snmp_credential_id} ssh_credential_id={ssh_credential_id} + ssh_elevate_credential_id={ssh_elevate_credential_id} target_source={target_source} target_exclude_source={target_exclude_source} title={target_title} @@ -388,6 +399,9 @@ class TargetComponent extends React.Component { onSshCredentialChange={this.handleSshCredentialChange} onEsxiCredentialChange={this.handleEsxiCredentialChange} onSmbCredentialChange={this.handleSmbCredentialChange} + onSshElevateCredentialChange={ + this.handleSshElevateCredentialChange + } onSave={d => { this.handleInteraction(); return save(d).then(() => this.closeTargetDialog()); diff --git a/gsa/src/web/pages/targets/details.js b/gsa/src/web/pages/targets/details.js index 675d0248f9..7c8044e86d 100644 --- a/gsa/src/web/pages/targets/details.js +++ b/gsa/src/web/pages/targets/details.js @@ -54,6 +54,7 @@ const TargetDetails = ({capabilities, entity, links = true}) => { smb_credential, snmp_credential, ssh_credential, + ssh_elevate_credential, tasks, allowSimultaneousIPs, } = entity; @@ -160,6 +161,24 @@ const TargetDetails = ({capabilities, entity, links = true}) => { )} + {isDefined(ssh_credential) && + isDefined(ssh_elevate_credential) && ( // Skip one column, because there is no way to fit a variation of the word "elevate" without leaving lots of white space on other rows + + {''} + + + {_('SSH elevate credential ')} + + {ssh_elevate_credential.name} + + + + + )} + {isDefined(smb_credential) && ( {_('SMB')} diff --git a/gsa/src/web/pages/targets/dialog.js b/gsa/src/web/pages/targets/dialog.js index a5bb8118c0..7fd2673ef3 100644 --- a/gsa/src/web/pages/targets/dialog.js +++ b/gsa/src/web/pages/targets/dialog.js @@ -47,6 +47,7 @@ import { SNMP_CREDENTIAL_TYPES, SSH_CREDENTIAL_TYPES, USERNAME_PASSWORD_CREDENTIAL_TYPE, + SSH_ELEVATE_CREDENTIAL_TYPES, } from 'gmp/models/credential'; const DEFAULT_PORT = 22; @@ -89,6 +90,12 @@ const NEW_SSH = { title: _l('Create new SSH credential'), }; +const NEW_SSH_ELEVATE = { + id_field: 'ssh_elevate_credential_id', + types: SSH_ELEVATE_CREDENTIAL_TYPES, + title: _l('Create new SSH elevate credential'), +}; + const NEW_SMB = { id_field: 'smb_credential_id', title: _l('Create new SMB credential'), @@ -127,6 +134,7 @@ const TargetDialog = ({ smb_credential_id = UNSET_VALUE, snmp_credential_id = UNSET_VALUE, ssh_credential_id = UNSET_VALUE, + ssh_elevate_credential_id = UNSET_VALUE, target_source = 'manual', target_exclude_source = 'manual', title = _('New Target'), @@ -139,6 +147,7 @@ const TargetDialog = ({ onSmbCredentialChange, onEsxiCredentialChange, onSnmpCredentialChange, + onSshElevateCredentialChange, ...initial }) => { const ssh_credentials = credentials.filter(ssh_credential_filter); @@ -170,6 +179,7 @@ const TargetDialog = ({ smb_credential_id, snmp_credential_id, ssh_credential_id, + ssh_elevate_credential_id, }; return ( @@ -342,34 +352,59 @@ const TargetDialog = ({ )} {capabilities.mayOp('get_credentials') && ( - - - + {_('on port')} + + {!in_use && ( + + + + )} + + + {state.ssh_credential_id !== UNSET_VALUE && ( + + + {_('Elevate privileges')} +