Skip to content

Commit

Permalink
Enable parsing ssh_elevate_credential_id and nullify ssh_elevate_cred…
Browse files Browse the repository at this point in the history
…ential if there is no ssh_credential
  • Loading branch information
saberlynx committed Jun 4, 2021
1 parent ca53722 commit 3143f57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
11 changes: 9 additions & 2 deletions gsa/src/gmp/commands/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
Expand Down
1 change: 1 addition & 0 deletions gsa/src/gmp/models/target.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const TARGET_CREDENTIAL_NAMES = [
'snmp_credential',
'ssh_credential',
'esxi_credential',
'ssh_elevate_credential',
];

class Target extends Model {
Expand Down
22 changes: 13 additions & 9 deletions gsa/src/web/pages/targets/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3143f57

Please sign in to comment.