Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delta reports to alerts #743

Merged
merged 2 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gsad/src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7729,7 +7729,9 @@ append_alert_method_data (GString *xml, params_t *data, const char *method)
&& strcmp (name, "submethod") == 0)
|| (strcmp (method, "Start Task") == 0
&& strcmp (name, "start_task_task") == 0)
|| strcmp (name, "details_url") == 0)
|| strcmp (name, "details_url") == 0
|| strcmp (name, "delta_type") == 0
|| strcmp (name, "delta_report_id") == 0)
xml_string_append (xml,
"<data><name>%s</name>%s</data>",
name,
Expand Down
1 change: 1 addition & 0 deletions ng/src/gmp/commands/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const method_data_fields = [
'scp_report_format', 'smb_credential', 'smb_file_path', 'smb_report_format',
'smb_share_path', 'tp_sms_hostname', 'tp_sms_credential',
'tp_sms_tls_certificate', 'tp_sms_tls_workaround',
'delta_type', 'delta_report_id',
];
const condition_data_fields = [
'severity', 'direction', 'at_least_filter_id',
Expand Down
4 changes: 4 additions & 0 deletions ng/src/gmp/models/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export const METHOD_TYPE_TIPPING_POINT = 'TippingPoint SMS';
export const EMAIL_NOTICE_INCLUDE = '0';
export const EMAIL_NOTICE_ATTACH = '2';

export const DELTA_TYPE_NONE = 'None';
export const DELTA_TYPE_PREVIOUS = 'Previous';
export const DELTA_TYPE_REPORT = 'Report';

const create_values = data => {
const value = is_empty(data.__text) ? undefined : data.__text;
const values = {value};
Expand Down
7 changes: 7 additions & 0 deletions ng/src/web/pages/alerts/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ class AlertComponent extends React.Component {
verinice_credential_id),

method_data_URL: value(method.data.URL, ''),
method_data_delta_type: value(alert.method.data.delta_type, ''),
method_data_delta_report_id: value(alert.method.data.delta_report_id,
''),
tasks,
title: _('Edit Alert {{name}}', {name: shorten(alert.name)}),
});
Expand Down Expand Up @@ -560,6 +563,8 @@ class AlertComponent extends React.Component {
method_data_verinice_server_url,
method_data_verinice_server_credential,
method_data_URL,
method_data_delta_type,
method_data_delta_report_id,
report_formats,
tasks,
} = this.state;
Expand Down Expand Up @@ -657,6 +662,8 @@ class AlertComponent extends React.Component {
method_data_verinice_server_credential=
{method_data_verinice_server_credential}
method_data_URL={method_data_URL}
method_data_delta_type={method_data_delta_type}
method_data_delta_report_id={method_data_delta_report_id}
tasks={tasks}
onClose={this.closeAlertDialog}
onNewScpCredentialClick={this.openScpCredentialDialog}
Expand Down
45 changes: 45 additions & 0 deletions ng/src/web/pages/alerts/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import {
METHOD_TYPE_SOURCEFIRE,
METHOD_TYPE_VERINICE,
METHOD_TYPE_TIPPING_POINT,
DELTA_TYPE_NONE,
DELTA_TYPE_PREVIOUS,
DELTA_TYPE_REPORT,
} from 'gmp/models/alert.js';

import PropTypes from '../../utils/proptypes.js';
Expand Down Expand Up @@ -205,6 +208,8 @@ const DEFAULTS = {
method_data_tp_sms_hostname: '',
method_data_tp_sms_tls_workaround: NO_VALUE,
method_data_URL: '',
method_data_delta_type: DELTA_TYPE_NONE,
method_data_delta_report_id: '',
name: _('Unnamed'),
report_formats: [],
result_filters: [],
Expand Down Expand Up @@ -506,6 +511,44 @@ class AlertDialog extends React.Component {
</FormGroup>
}

{is_task_event &&
<FormGroup title={_('Delta Report')} flex="column">
<Divider flex="column">
<Radio
title={_('None')}
name="method_data_delta_type"
value={DELTA_TYPE_NONE}
checked={values.method_data_delta_type === DELTA_TYPE_NONE}
onChange={onValueChange}
/>

<Radio
title={_('Previous completed report of the same task')}
name="method_data_delta_type"
value={DELTA_TYPE_PREVIOUS}
checked={values.method_data_delta_type === DELTA_TYPE_PREVIOUS}
onChange={onValueChange}
/>

<Divider>
<Radio
title={_('Report with ID')}
name="method_data_delta_type"
value={DELTA_TYPE_REPORT}
checked={values.method_data_delta_type === DELTA_TYPE_REPORT}
onChange={onValueChange}
/>
<TextField
grow="1"
name="method_data_delta_report_id"
value={values.method_data_delta_report_id}
onChange={onValueChange}
/>
</Divider>
</Divider>
</FormGroup>
}

<FormGroup title={_('Method')}>
<Select
name="method"
Expand Down Expand Up @@ -675,6 +718,8 @@ AlertDialog.propTypes = {
filter_id: PropTypes.idOrZero,
method: PropTypes.string,
method_data_URL: PropTypes.string,
method_data_delta_type: PropTypes.string,
method_data_delta_report_id: PropTypes.string,
method_data_defense_center_ip: PropTypes.string,
method_data_defense_center_port: PropTypes.numberOrNumberString,
method_data_details_url: PropTypes.string,
Expand Down