Skip to content

Commit

Permalink
Merge pull request #3833 from greenbone/add-scp-alert-port
Browse files Browse the repository at this point in the history
Add: New "Port" field for SCP alert method
  • Loading branch information
timopollmeier authored Aug 11, 2023
2 parents c6ddd97 + 155f122 commit bed0437
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gmp/commands/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const method_data_fields = [
'scp_host',
'scp_known_hosts',
'scp_path',
'scp_port',
'scp_report_format',
'smb_credential',
'smb_file_path',
Expand Down
4 changes: 4 additions & 0 deletions src/web/pages/alerts/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ class AlertComponent extends React.Component {
DEFAULT_SCP_PATH,
),
method_data_scp_host: getValue(method.data.scp_host, ''),
method_data_scp_port: getValue(method.data.scp_port, 22),
method_data_scp_known_hosts: getValue(
method.data.scp_known_hosts,
'',
Expand Down Expand Up @@ -726,6 +727,7 @@ class AlertComponent extends React.Component {
method_data_scp_path: DEFAULT_SCP_PATH,
method_data_scp_report_format: report_format_id,
method_data_scp_host: undefined,
method_data_scp_port: 22,
method_data_scp_known_hosts: undefined,
method_data_send_port: undefined,
method_data_send_host: undefined,
Expand Down Expand Up @@ -958,6 +960,7 @@ class AlertComponent extends React.Component {
method_data_scp_report_format,
method_data_scp_path,
method_data_scp_host,
method_data_scp_port,
method_data_scp_known_hosts,
method_data_send_port,
method_data_send_host,
Expand Down Expand Up @@ -1079,6 +1082,7 @@ class AlertComponent extends React.Component {
method_data_scp_report_format={method_data_scp_report_format}
method_data_scp_path={method_data_scp_path}
method_data_scp_host={method_data_scp_host}
method_data_scp_port={method_data_scp_port}
method_data_scp_known_hosts={method_data_scp_known_hosts}
method_data_send_port={method_data_send_port}
method_data_send_host={method_data_send_host}
Expand Down
3 changes: 3 additions & 0 deletions src/web/pages/alerts/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const DEFAULTS = {
method_data_notice_report_format: DEFAULT_NOTICE_REPORT_FORMAT,
method_data_scp_path: DEFAULT_SCP_PATH,
method_data_scp_host: '',
method_data_scp_port: 22,
method_data_scp_known_hosts: '',
method_data_send_host: '',
method_data_send_port: '',
Expand Down Expand Up @@ -717,6 +718,7 @@ class AlertDialog extends React.Component {
reportFormats={report_formats}
scpCredential={values.method_data_scp_credential}
scpHost={values.method_data_scp_host}
scpPort={values.method_data_scp_port}
scpKnownHosts={values.method_data_scp_known_hosts}
scpPath={values.method_data_scp_path}
scpReportFormat={values.method_data_scp_report_format}
Expand Down Expand Up @@ -905,6 +907,7 @@ AlertDialog.propTypes = {
method_data_scp_host: PropTypes.string,
method_data_scp_known_hosts: PropTypes.string,
method_data_scp_path: PropTypes.string,
method_data_scp_port: PropTypes.number,
method_data_scp_report_format: PropTypes.id,
method_data_send_host: PropTypes.string,
method_data_send_port: PropTypes.string,
Expand Down
7 changes: 7 additions & 0 deletions src/web/pages/alerts/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ const Method = ({method = {}, details = false, reportFormats = []}) => {
</TableRow>
)}

{isDefined(data.scp_port?.value) && (
<TableRow>
<TableData>{_('Port')}</TableData>
<TableData>{data.scp_port.value}</TableData>
</TableRow>
)}

{isDefined(credential) && isDefined(credential.id) && (
<TableRow>
<TableData>{_('Credential')}</TableData>
Expand Down
14 changes: 14 additions & 0 deletions src/web/pages/alerts/scpmethodpart.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import withPrefix from '../../utils/withPrefix.js';

import Select from '../../components/form/select.js';
import FormGroup from '../../components/form/formgroup.js';
import Spinner from '../../components/form/spinner.js';
import TextField from '../../components/form/textfield.js';
import TextArea from '../../components/form/textarea.js';

Expand All @@ -45,6 +46,7 @@ const ScpMethodPart = ({
reportFormats,
scpCredential,
scpHost,
scpPort,
scpKnownHosts,
scpPath,
scpReportFormat,
Expand Down Expand Up @@ -83,6 +85,17 @@ const ScpMethodPart = ({
/>
</FormGroup>

<FormGroup title={_('Port')}>
<Spinner
name={prefix + 'scp_port'}
value={scpPort}
type="int"
onChange={onChange}
min={1}
max={65535}
/>
</FormGroup>

<FormGroup title={_('Known Hosts')}>
<TextArea
grow="1"
Expand Down Expand Up @@ -122,6 +135,7 @@ ScpMethodPart.propTypes = {
scpHost: PropTypes.string.isRequired,
scpKnownHosts: PropTypes.string.isRequired,
scpPath: PropTypes.string.isRequired,
scpPort: PropTypes.number.isRequired,
scpReportFormat: PropTypes.id,
onChange: PropTypes.func.isRequired,
onCredentialChange: PropTypes.func.isRequired,
Expand Down

0 comments on commit bed0437

Please sign in to comment.