From 3143f572cbefb5c590d040377f6ee8ccb1d5597f Mon Sep 17 00:00:00 2001 From: Crystal Lai Date: Fri, 4 Jun 2021 09:41:10 +0200 Subject: [PATCH] Enable parsing ssh_elevate_credential_id and nullify ssh_elevate_credential if there is no ssh_credential --- gsa/src/gmp/commands/targets.js | 11 +++++++++-- gsa/src/gmp/models/target.js | 1 + gsa/src/web/pages/targets/component.js | 22 +++++++++++++--------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/gsa/src/gmp/commands/targets.js b/gsa/src/gmp/commands/targets.js index c68f04538b..2731d77393 100644 --- a/gsa/src/gmp/commands/targets.js +++ b/gsa/src/gmp/commands/targets.js @@ -25,6 +25,7 @@ import Target from 'gmp/models/target'; import EntitiesCommand from './entities'; import EntityCommand from './entity'; +import {UNSET_VALUE} from 'web/utils/render'; const log = logger.getLogger('gmp.commands.targets'); @@ -72,7 +73,10 @@ class TargetCommand extends EntityCommand { alive_tests, port, ssh_credential_id, - ssh_elevate_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, @@ -127,7 +131,10 @@ class TargetCommand extends EntityCommand { smb_credential_id, snmp_credential_id, ssh_credential_id, - ssh_elevate_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/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 4f6eb1603d..e41442809a 100644 --- a/gsa/src/web/pages/targets/component.js +++ b/gsa/src/web/pages/targets/component.js @@ -54,8 +54,9 @@ class TargetComponent extends React.Component { }; this.openCredentialsDialog = this.openCredentialsDialog.bind(this); - this.handleCloseCredentialsDialog = - this.handleCloseCredentialsDialog.bind(this); + this.handleCloseCredentialsDialog = this.handleCloseCredentialsDialog.bind( + this, + ); this.openPortListDialog = this.openPortListDialog.bind(this); this.handleClosePortListDialog = this.handleClosePortListDialog.bind(this); this.openTargetDialog = this.openTargetDialog.bind(this); @@ -64,14 +65,17 @@ class TargetComponent extends React.Component { this.handleCreateCredential = this.handleCreateCredential.bind(this); this.handleCreatePortList = this.handleCreatePortList.bind(this); this.handlePortListChange = this.handlePortListChange.bind(this); - this.handleEsxiCredentialChange = - this.handleEsxiCredentialChange.bind(this); + this.handleEsxiCredentialChange = this.handleEsxiCredentialChange.bind( + this, + ); this.handleSshCredentialChange = this.handleSshCredentialChange.bind(this); - this.handleSshElevateCredentialChange = - this.handleSshElevateCredentialChange.bind(this); + this.handleSshElevateCredentialChange = this.handleSshElevateCredentialChange.bind( + this, + ); this.handleSmbCredentialChange = this.handleSmbCredentialChange.bind(this); - this.handleSnmpCredentialChange = - this.handleSnmpCredentialChange.bind(this); + this.handleSnmpCredentialChange = this.handleSnmpCredentialChange.bind( + this, + ); } openCredentialsDialog({id_field, types, title}) { @@ -127,7 +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_id), + ssh_elevate_credential_id: id_or__(entity.ssh_elevate_credential), }); }); } else {