Skip to content

Commit

Permalink
Add: Added report config options to alerts.
Browse files Browse the repository at this point in the history
Alert methods that use a report format should have an option to
also choose an optional report config. I added the report config
option to the methods: Email, SCP, Send to host, SMB and
verinice.PRO Connector. The Alemba vFire method is even more
complex and will be handled separately.
  • Loading branch information
jhelmold committed May 16, 2024
1 parent eb96599 commit 0a56ae8
Show file tree
Hide file tree
Showing 12 changed files with 528 additions and 37 deletions.
22 changes: 22 additions & 0 deletions src/gmp/commands/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ const method_data_fields = [
'subject',
'notice',
'notice_report_format',
'notice_report_config',
'message',
'notice_attach_format',
'notice_attach_config',
'message_attach',
'recipient_credential',
'submethod', // FIXME remove constant submethod!!!
Expand All @@ -57,20 +59,24 @@ const method_data_fields = [
'pkcs12_credential',
'verinice_server_url',
'verinice_server_credential',
'verinice_server_report_config',
'verinice_server_report_format',
'start_task_task',
'send_host',
'send_port',
'send_report_config',
'send_report_format',
'scp_credential',
'scp_host',
'scp_known_hosts',
'scp_path',
'scp_port',
'scp_report_config',
'scp_report_format',
'smb_credential',
'smb_file_path',
'smb_max_protocol',
'smb_report_config',
'smb_report_format',
'smb_share_path',
'tp_sms_hostname',
Expand All @@ -80,6 +86,7 @@ const method_data_fields = [
'delta_type',
'delta_report_id',
'report_formats',
'report_configs',
'vfire_base_url',
'vfire_credential',
'vfire_session_type',
Expand Down Expand Up @@ -127,6 +134,7 @@ class AlertCommand extends EntityCommand {
filter_id,
method,
report_format_ids,
report_config_ids,
...other
} = args;
const data = {
Expand All @@ -142,6 +150,7 @@ class AlertCommand extends EntityCommand {
method,
filter_id,
'report_format_ids:': report_format_ids,
'report_config_ids:': report_config_ids,
};
log.debug('Creating new alert', args, data);
return this.action(data);
Expand All @@ -158,6 +167,7 @@ class AlertCommand extends EntityCommand {
filter_id,
method,
report_format_ids = [],
report_config_ids = [],
...other
} = args;
const data = {
Expand All @@ -175,6 +185,8 @@ class AlertCommand extends EntityCommand {
filter_id,
'report_format_ids:':
report_format_ids.length > 0 ? report_format_ids : undefined,
'report_config_ids:':
report_config_ids.length > 0 ? report_config_ids : undefined,
};
log.debug('Saving alert', args, data);
return this.action(data);
Expand All @@ -190,6 +202,10 @@ class AlertCommand extends EntityCommand {
new_alert.get_report_formats_response.report_format,
format => parseModelFromElement(format, 'reportformat'),
);
new_alert.report_configs = map(
new_alert.get_report_configs_response.report_config,
config => parseModelFromElement(config, 'reportconfig'),
);
new_alert.credentials = map(
new_alert.get_credentials_response.credential,
credential => Credential.fromElement(credential),
Expand Down Expand Up @@ -222,6 +238,12 @@ class AlertCommand extends EntityCommand {
);
delete edit_alert.get_report_formats_response;

edit_alert.report_configs = map(
edit_alert.get_report_configs_response.report_config,
config => parseModelFromElement(config, 'reportconfig'),
);
delete edit_alert.get_report_configs_response;

edit_alert.credentials = map(
edit_alert.get_credentials_response.credential,
credential => Credential.fromElement(credential),
Expand Down
12 changes: 12 additions & 0 deletions src/web/pages/alerts/__tests__/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ describe('Alert Detailspage tests', () => {
reportformats: {
get: getEntities,
},
reportconfigs: {
get: getEntities,
},
settings: {manualUrl, reloadInterval},
user: {
currentSettings,
Expand Down Expand Up @@ -183,6 +186,9 @@ describe('Alert Detailspage tests', () => {
reportformats: {
get: getEntities,
},
reportconfigs: {
get: getEntities,
},
settings: {manualUrl, reloadInterval},
user: {
currentSettings,
Expand Down Expand Up @@ -223,6 +229,9 @@ describe('Alert Detailspage tests', () => {
reportformats: {
get: getEntities,
},
reportconfigs: {
get: getEntities,
},
settings: {manualUrl, reloadInterval},
user: {
currentSettings,
Expand Down Expand Up @@ -278,6 +287,9 @@ describe('Alert Detailspage tests', () => {
reportformats: {
get: getEntities,
},
reportconfigs: {
get: getEntities,
},
settings: {manualUrl, reloadInterval},
user: {
currentSettings,
Expand Down
Loading

0 comments on commit 0a56ae8

Please sign in to comment.