From 155f12255e02138862b133fb4c17193941300f91 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 11 Aug 2023 08:59:08 +0200 Subject: [PATCH 1/3] Add: New "Port" field for SCP alert method The alert dialog and details now have a new "Port" field for the SCP alert method. --- src/gmp/commands/alerts.js | 1 + src/web/pages/alerts/component.js | 4 ++++ src/web/pages/alerts/dialog.js | 3 +++ src/web/pages/alerts/method.js | 7 +++++++ src/web/pages/alerts/scpmethodpart.js | 14 ++++++++++++++ 5 files changed, 29 insertions(+) diff --git a/src/gmp/commands/alerts.js b/src/gmp/commands/alerts.js index 53332500d6..0a38e5c6fd 100644 --- a/src/gmp/commands/alerts.js +++ b/src/gmp/commands/alerts.js @@ -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', diff --git a/src/web/pages/alerts/component.js b/src/web/pages/alerts/component.js index 97dbe70123..2893d5333b 100644 --- a/src/web/pages/alerts/component.js +++ b/src/web/pages/alerts/component.js @@ -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, '', @@ -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, @@ -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, @@ -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} diff --git a/src/web/pages/alerts/dialog.js b/src/web/pages/alerts/dialog.js index 6898e79510..354b547baf 100644 --- a/src/web/pages/alerts/dialog.js +++ b/src/web/pages/alerts/dialog.js @@ -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: '', @@ -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} @@ -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, diff --git a/src/web/pages/alerts/method.js b/src/web/pages/alerts/method.js index 943f24bef8..3c95b4250e 100644 --- a/src/web/pages/alerts/method.js +++ b/src/web/pages/alerts/method.js @@ -198,6 +198,13 @@ const Method = ({method = {}, details = false, reportFormats = []}) => { )} + {isDefined(data.scp_port?.value) && ( + + {_('Port')} + {data.scp_port.value} + + )} + {isDefined(credential) && isDefined(credential.id) && ( {_('Credential')} diff --git a/src/web/pages/alerts/scpmethodpart.js b/src/web/pages/alerts/scpmethodpart.js index ef6f86a650..54f24fe612 100644 --- a/src/web/pages/alerts/scpmethodpart.js +++ b/src/web/pages/alerts/scpmethodpart.js @@ -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'; @@ -45,6 +46,7 @@ const ScpMethodPart = ({ reportFormats, scpCredential, scpHost, + scpPort, scpKnownHosts, scpPath, scpReportFormat, @@ -83,6 +85,17 @@ const ScpMethodPart = ({ /> + + + +