{#- ############################################################################
MACROS FOR RENDERING CHARTS AND TABLES.
These macros encapsulate common functionality when generating various charts
and tables within the Mentat GUI. There are macros responsible for rendering
HTML as well as for rendering JavaScript, all with code reusability in mind.
############################################################################ -#}
{#- ============================================================================
Content rendering snippets.
Following snippets contain working pieces of HTML or JavaScript and are not
intended to be used separatelly. They should be considered internal for the
purposes of this library.
============================================================================ -#}
{#-
Render HTML columns that will contain chart and its related dataset table.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
bool scrollable_table: Make the viewport of the dataset table scrollable.
bool with_full: Include options for downloading full unabridged dataset.
bool start_invisible: Adds `invisible` class to the chart toolbar
to later be removed once the data is actually obtained.
-#}
{%- macro _snippet_columns(chart_id, scrollable_table = True, with_full = False, start_invisible = False) %}
{%- endmacro %}
{#-
Render HTML columns that will contain chart and its related dataset table,
but in this case make the column containing the table toggable and hidden
by default.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
bool scrollable_table: Make the viewport of the dataset table scrollable.
bool with_full: Include options for downloading full unabridged dataset.
bool start_invisible: Adds `invisible` class to the chart toolbar
to later be removed once the data is actually obtained.
-#}
{%- macro _snippet_columns_toggable(chart_id, scrollable_table = True, with_full = False, start_invisible = False) %}
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given timeline
chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_chart_timeline(chart_id, cfg_params) %}
// Render the timeline chart '{{ chart_id }}'.
render_chart_timeline_multi(
'{{ chart_id }}_chart',
dstl_to_chart(
{{ chart_id }}_dataset,
{{ chart_id }}_series,
),
{
'xlabel': '{{ _("Date") }}',
'ylabel': '{{ _("Count [#]") }}'{%- if 'timezone' in cfg_params %},
'timezone': '{{ cfg_params['timezone'] }}'
{%- endif %}
}
);
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given pie
chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_chart_pie(chart_id, cfg_params) %}
// Render pie chart for dataset '{{ chart_id }}'.
render_chart_pie(
'{{ chart_id }}_chart',
{{ chart_id }}_dataset{%- if cfg_params and 'value_format' in cfg_params and cfg_params['value_format'] %},
{ 'value_formatter': {{ cfg_params['value_format'] }}() }{%- endif %}
);
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given horizontal
bar chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_chart_hbar(chart_id, cfg_params) %}
// Render horizontal bar chart for dataset '{{ chart_id }}'.
render_chart_hbar(
'{{ chart_id }}_chart',
{{ chart_id }}_dataset{%- if cfg_params and 'value_format' in cfg_params and cfg_params['value_format'] %},
{ 'value_formatter': {{ cfg_params['value_format'] }}() }{%- endif %}
);
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given timeline
dataset table.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_table_timeline(chart_id, cfg_params) %}
// Render the timeline table '{{ chart_id }}'.
render_table_timeline_multi(
'{{ chart_id }}_table',
[
{'ident': '_date', 'key': '{{ _("Date") }}'}
].concat(
{{ chart_id }}_series
).concat([
{'ident': '_sum', 'key': '{{ _("Sum") }}'}
]),
{{ chart_id }}_dataset,
GLOBAL_TABLE_COLS_STATS
);
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given generic
dataset table.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_table_dict(chart_id, cfg_params) %}
{%- set tmplabel = cfg_params['value_label'] %}
{%- if not tmplabel %}{%- set tmplabel = _('Count') %}{%- endif %}
// Render table for dataset '{{ chart_id }}'.
render_table_dict(
'{{ chart_id }}_table',
[
{'ident': 'key', 'label': '{{ _('Name') }}'},
{'ident': 'value', 'label': '{{ tmplabel }}'},
{'ident': 'share', 'label': '{{ _('Share') }}'},
],
{{ chart_id }}_dataset,
GLOBAL_TABLE_COLS_STATS,
{%- if cfg_params and 'csag_name' in cfg_params and cfg_params['csag_name'] %}
Hawat.get_csag('{{ cfg_params['csag_name'] }}'),
{%- else %}
null,
{%- endif %}
{%- if cfg_params %}
{
{%- if 'value_format' in cfg_params and cfg_params['value_format'] %}
'value_formatter': {{ cfg_params['value_format'] }}(),
{%- endif %}
{%- if 'kwargs' in cfg_params and cfg_params['kwargs'] %}
'kwargs': {{ cfg_params['kwargs'] | tojson | safe }},
{%- endif %}
{%- if 'with_table_stats' in cfg_params %}
'with_table_stats': {{ cfg_params['with_table_stats'] | tojson | safe }},
{%- endif %}
}
{%- endif %}
);
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given generic
dataset table.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_table_mdict(chart_id, cfg_params, dict_key) %}
{%- set tmplabel = cfg_params['value_label'] %}
{%- if not tmplabel %}{%- set tmplabel = _('Count') %}{%- endif %}
// Render table for dataset '{{ chart_id }}'.
render_table_mdict(
'{{ chart_id }}_table',
[
{'ident': 'label', 'label': '{{ _('Name') }}'},
{'ident': 'value', 'label': '{{ tmplabel }}'},
{'ident': 'share', 'label': '{{ _('Share') }}'},
],
{{ chart_id }}_dataset[0].values,
GLOBAL_TABLE_COLS_STATS,
data.totals ? data.totals.{{ dict_key }} : data.cnt_events,
{%- if cfg_params and 'csag_name' in cfg_params and cfg_params['csag_name'] %}
Hawat.get_csag('{{ cfg_params['csag_name'] }}'),
{%- else %}
null,
{%- endif %}
{%- if cfg_params %}
{
{%- if 'value_format' in cfg_params and cfg_params['value_format'] %}
'value_formatter': {{ cfg_params['value_format'] }}(),
{%- endif %}
{%- if 'kwargs' in cfg_params and cfg_params['kwargs'] %}
'kwargs': {{ cfg_params['kwargs'] | tojson | safe }},
{%- endif %}
{%- if 'with_table_stats' in cfg_params %}
'with_table_stats': {{ cfg_params['with_table_stats'] | tojson | safe }},
{%- endif %}
}
{%- endif %}
);
{%- endmacro %}
{%- macro _subsnippet_ecbks_chart(chart_id) %}
// Event handler for downloading chart as SVG.
$("#{{ chart_id }}_export_svg").click(function () {
chart = $("#{{ chart_id }}_chart svg").get(0);
serializer = new XMLSerializer();
data = serializer.serializeToString(chart);
blob = new Blob([data], {type: "image/svg+xml"}),
url = window.URL.createObjectURL(blob);
this.href = url;
this.target = '_blank';
// target filename
this.download = 'export_{{ chart_id }}.svg';
});
{%- endmacro %}
{%- macro _subsnippet_ecbks_csv(chart_id, as_timeline = False, suffix = '', subvar = '') %}
// Event handler for downloading chart dataset as CSV.
$("#{{ chart_id }}_export_csv{{ suffix }}").click(function () {
{%- if as_timeline %}
data = lols_to_csv(
loos_to_lols_kw(
[
{ ident: '_date', key: '{{ _("Date") }}' }
].concat(
{{ chart_id }}_series{{ suffix }}
),
{{ chart_id }}_dataset{{ suffix }},
)
);
{%- else %}
data = lols_to_csv(
loos_to_lols(
[['{{ _("Name") }}', '{{ _("Count") }}']],
{{ chart_id }}_dataset{{ suffix }}{{ subvar }},
'label'
)
);
{%- endif %}
blob = new Blob([data], {type: "text/csv"}),
url = window.URL.createObjectURL(blob);
this.href = url;
this.target = '_blank';
// target filename
this.download = 'export_{{ chart_id }}{{ suffix }}.csv';
});
{%- endmacro %}
{%- macro _subsnippet_ecbks_json(chart_id, suffix = '', subvar = '') %}
// Event handler for downloading chart dataset as JSON.
$("#{{ chart_id }}_export_json{{ suffix }}").click(function () {
data = JSON.stringify({{ chart_id }}_dataset{{ suffix }}{{ subvar }});
blob = new Blob([data], {type: "application/json"}),
url = window.URL.createObjectURL(blob);
this.href = url;
this.target = '_blank';
// target filename
this.download = 'export_{{ chart_id }}{{ suffix }}.json';
});
{%- endmacro %}
{#-
Render JavaScript code responsible handling JavaScript events related to given
timeline chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
bool with_full: Include options for downloading full unabridged dataset.
-#}
{%- macro _snippet_ecbks_timeline(chart_id, cfg_params, with_full = False) %}
// Enable necessary event callbacks to appropriate DOM elements.
// unbind click event listener
$("#{{ chart_id }}_toggle").off('click');
// Event handler for toggling dataset table.
$("#{{ chart_id }}_toggle").click(function () {
$("#{{ chart_id }}_content").toggleClass("col-md-12 col-md-6");
$("#{{ chart_id }}_sidebar").toggleClass("collapsed");
$("#{{ chart_id }}_sidebar").trigger("resizeCharts");
return false;
});
{{ _subsnippet_ecbks_chart(chart_id) }}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = True) }}
{{ _subsnippet_ecbks_json(chart_id) }}
{%- if with_full %}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = True, suffix = '_full') }}
{{ _subsnippet_ecbks_json(chart_id, suffix = '_full') }}
{%- endif %}
{%- endmacro %}
{#-
Render JavaScript code responsible handling JavaScript events related to given
generic chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
bool with_full: Include options for downloading full unabridged dataset.
-#}
{%- macro _snippet_ecbks_dict(chart_id, cfg_params, with_full = False) %}
// Append necessary event handlers for dataset '{{ chart_id }}'.
{{ _subsnippet_ecbks_chart(chart_id) }}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = False) }}
{{ _subsnippet_ecbks_json(chart_id) }}
{%- if with_full %}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = False, suffix = '_full') }}
{{ _subsnippet_ecbks_json(chart_id, suffix = '_full') }}
{%- endif %}
{%- endmacro %}
{#-
Render JavaScript code responsible handling JavaScript events related to given
generic chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
bool with_full: Include options for downloading full unabridged dataset.
-#}
{%- macro _snippet_ecbks_mdict(chart_id, cfg_params, with_full = False) %}
// Append necessary event handlers for dataset '{{ chart_id }}'.
{{ _subsnippet_ecbks_chart(chart_id) }}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = False, subvar = '[0].values') }}
{{ _subsnippet_ecbks_json(chart_id, subvar = '[0].values') }}
{%- if with_full %}
{{ _subsnippet_ecbks_csv(chart_id, as_timeline = False, suffix = '_full', subvar = '[0].values') }}
{{ _subsnippet_ecbks_json(chart_id, suffix = '_full', subvar = '[0].values') }}
{%- endif %}
{%- endmacro %}
{#-
Render JavScript code responsible for either rendering the charts if data
is available otherwise for appending the rendering function to the
rendering_functions.
-#}
{%- macro _snippet_handle_rendering(data_var_name, dict_key) %}
{%- if data_var_name %}
document.addEventListener('DOMContentLoaded', () => {
render({{ data_var_name }})
});
{%- elif dict_key %}
(rendering_functions['{{ dict_key }}'] ??= []).push(render);
{%- else %}
console.error('data_var_name nor dict_key are defined, skipping rendering');
{%- endif %}
{%- endmacro %}
{#- ============================================================================
Public chart and dataset table rendering macros.
============================================================================ -#}
{#-
Calculate dataset from given list of requested keys and render it as TIMELINE
chart with appropriate toggable data table.
dict full_data: Full statistical data as dictionary structure.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string list_keys: List of requested subkeys from which the target dataset will
be constructed.
string dict_key: name under which the rendering function will be stored.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro render_chart_timeline_list(full_data, data_var_name, id_prefix, list_keys, dict_key = '', cfg_params = {}) %}
{%- set chart_id = 'chart_timeline_' + id_prefix %}
{{ _snippet_columns_toggable(chart_id) }}
{%- endmacro %}
{#-
Render given dataset in single dictionary as TIMELINE chart with appropriate
data table.
dict full_data: Full statistical data as dictionary structure. This structure
will be checked whether it actually contains the requested dict_key subkey.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string dict_key: Name of the subkey in given full_data dictionary structure
containing data from which to actually generate the TIMELINE chart.
dict cfg_params: Additional chart configuration and customization parameters.
This macro expects, that the data structure under dict_key within the full_data
is going to be a dictionary. In case it does not exist appropriate information
will be presented to the user instead of the chart.
-#}
{%- macro render_chart_timeline_dict(full_data, data_var_name, id_prefix, dict_key, cfg_params = {}) %}
{%- set chart_id = 'chart_timeline_' + id_prefix + '_' + dict_key %}
{%- if not (full_data or data_var_name) or dict_key in full_data %}
{{ _snippet_columns_toggable(chart_id, with_full = True, start_invisible = not (full_data or data_var_name) or dict_key not in full_data) }}
{%- else %}
{%- call macros_site.render_alert('warning', False) %}
{{ _('No data available to render in this chart.') }}
{%- endcall %}
{%- endif %}
{%- endmacro %}
{#-
Render given dataset from given list of data series as PIE chart with appropriate
data table.
dict full_data: Full statistical data as dictionary structure.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string list_keys: List of requested subkeys from which the target dataset will
be constructed.
string dict_key: name under which the rendering function will be stored.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro render_dataset_pie_list(full_data, data_var_name, id_prefix, list_keys, dict_key = '', cfg_params = {}) %}
{%- set chart_id = 'chart_pie_' + id_prefix %}
{{ _snippet_columns(chart_id, scrollable_table = False) }}
{%- endmacro %}
{#-
Render given dataset in single dictionary as PIE chart with appropriate data table.
dict full_data: Full statistical data as dictionary structure. This structure
will be checked whether it actually contains the requested dict_key subkey.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string dict_key: Name of the subkey in given full_data dictionary structure
containing data from which to actually generate the PIE chart.
dict cfg_params: Additional chart configuration and customization parameters.
This macro expects, that the data structure under dict_key within the full_data
is going to be a dictionary. In case it does not exist appropriate information
will be presented to the user instead of the chart.
-#}
{%- macro render_dataset_pie_dict(full_data, data_var_name, id_prefix, dict_key, cfg_params = {}) %}
{%- set chart_id = 'chart_pie_' + id_prefix + '_' + dict_key %}
{%- if not (full_data or data_var_name) or dict_key in full_data %}
{{ _snippet_columns(chart_id, scrollable_table = False, with_full = True, start_invisible = not (full_data or data_var_name) or dict_key not in full_data) }}
{%- else %}
{%- call macros_site.render_alert('warning', False) %}
{{ _('No data available to render in this chart.') }}
{%- endcall %}
{%- endif %}
{%- endmacro %}
{#-
Render given dataset in single dictionary as HORIZONTAL BAR chart with appropriate
data table.
dict full_data: Full statistical data as dictionary structure. This structure
will be checked whether it actually contains the requested dict_key subkey.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string dict_key: Name of the subkey in given full_data dictionary structure
containing data from which to actually generate the PIE chart.
dict cfg_params: Additional chart configuration and customization parameters.
This macro expects, that the data structure under dict_key within the full_data
is going to be a dictionary. In case it does not exist appropriate information
will be presented to the user instead of the chart.
-#}
{%- macro render_dataset_hbar_dict(full_data, data_var_name, id_prefix, dict_key, cfg_params = {}) %}
{%- set chart_id = 'chart_hbar_' + id_prefix + '_' + dict_key %}
{%- if not (full_data or data_var_name) or dict_key in full_data %}
{{ _snippet_columns(chart_id, scrollable_table = False, with_full = True, start_invisible = not (full_data or data_var_name) or dict_key not in full_data) }}
{%- else %}
{%- call macros_site.render_alert('warning', False) %}
{{ _('No data available to render in this chart.') }}
{%- endcall %}
{%- endif %}
{%- endmacro %}
{#- ============================================================================
High-level chart rendering macros.
============================================================================ -#}
{#-
Render tab panel navigation for common list of IDEA event charts.
dict statistics: Full statistical data as dictionary structure. This structure
will be inspected during rendering whether it contains required subkeys.
string id_prefix: Prefix for all subsequent unique identifiers.
list hide_sections: List of section names to hide.
list only_sections: List of section names to show. (useful with
render_empty = True)
bool render_empty: Render the section even in case the required key does not
exist in the data.
bool active_first: Highlight the first section as active.
string active_section: The name of the section that should be active on load (takes precedence over active_first)
function get_url_func: function which will return url to redirect to if the section
name is not present in statistics (useful with render_empty = True)
-#}
{%- macro render_dashboard_nav(statistics, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, active_section = None, get_url_func = None) %}
{%- set tmp = {'cntr': 0} %}
{%- for chsection in (
('abuses', _('abuses')),
('analyzers', _('analyzers')),
('asns', _('ASNs')),
('categories', _('categories')),
('category_sets', _('category sets')),
('countries', _('countries')),
('detectors', _('detectors')),
('detectorsws', _('detector software')),
('detector_types', _('detector tags')),
('sources', _('sources')),
('targets', _('targets')),
('source_ports', _('source ports')),
('target_ports', _('target ports')),
('protocols', _('protocols')),
('source_types', _('source types')),
('target_types', _('target types')),
('classes', _('classes')),
('severities', _('severities'))
) -%}
{%- if chsection[0] not in hide_sections and (not only_sections or chsection[0] in only_sections) %}
{%- if chsection[0] in statistics or render_empty %}
{%- if tmp.update({'cntr': tmp['cntr'] + 1}) %}{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endmacro %}
{#-
Render tab panels for common list of IDEA event charts.
dict statistics: Full statistical data as dictionary structure. This structure
will be inspected during rendering whether it contains required subkeys.
string id_prefix: Prefix for all subsequent unique identifiers.
list hide_sections: List of section names to hide.
list only_sections: List of section names to show. (useful with
render_empty = True)
bool render_empty: Render the section even in case the required key does not
exist in the data.
bool active_first: Highlight the first section as active.
string active_section: The name of the section that should be active on load (takes precedence over active_first)
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro render_dashboard_panels(statistics, statistics_var_name, id_prefix, hide_sections = [], only_sections = None, render_empty = False, active_first = False, active_section = None, cfg_params = {}) %}
{%- set tmp = {'cntr': 0} %}
{%- for chsection in (
(
'abuses',
_('Number of events per abuse'),
_('This view shows total numbers of IDEA events aggregated according to a source abuse group. The source abuse group is assigned according to all source addresses contained in the event, multiple source abuse groups can therefore be assigned to the event and the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'analyzers',
_('Number of events per analyzer'),
_('This view shows total numbers of IDEA events aggregated according to an analyzer. In the context of Mentat system and IDEA events the analyzer is a name of a software that detected or emited the IDEA event. Multiple analyzers can be assigned to the event and therefore the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'asns',
_('Number of events per ASN'),
_('This view shows total numbers of IDEA events aggregated according to a source autonomous system number (ASN). The source ASN is assigned according to all source addresses contained in the event, multiple source ASNs can therefore be assigned to the event and the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'categories',
_('Number of events per category'),
_('This view shows total numbers of IDEA events aggregated according to a category. Multiple categories can be assigned to the event and therefore the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'category_sets',
_('Number of events per category set'),
_('This view shows total numbers of IDEA events aggregated according to a category set. The category set is a string concatenation of alphabetically ordered unique set of all event categories and so it provides different grouped view of the event category statistics.'),
'single',
None
),
(
'countries',
_('Number of events per country'),
_('This view shows total numbers of IDEA events aggregated according to a source country. The source country is assigned according to all source addresses contained in the event, multiple source countries can therefore be assigned to the event and the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'detectors',
_('Number of events per detector'),
_('This view shows total numbers of IDEA events aggregated according to a detector. In the context of Mentat system and IDEA events the detector is an unique name of the node on which the IDEA event was detected or emited.'),
'single',
None
),
(
'detectorsws',
_('Number of events per detector software'),
_('This view shows total numbers of IDEA events aggregated according to a detector software. The detector software is a string concatenation of detector and analyzer names. Because an event may contain multiple analyzer names, multiple detector software strings can be produced for each event and the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'detector_types',
_('Number of events per detector type'),
_('This view shows total numbers of IDEA events aggregated according to a detector type. In the context of Mentat system and IDEA events each detector is an unique name of the node on which the IDEA event was detected or emited and each may be assigned one or more tags to describe its type. Because an event may contain multiple detector type tags, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'sources',
_('Number of events per source IP'),
_('This view shows total numbers of IDEA events aggregated according to a source IP address. Because an event may contain multiple source IP addresses, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
'ips'
),
(
'targets',
_('Number of events per target IP'),
_('This view shows total numbers of IDEA events aggregated according to a target IP address. Because an event may contain multiple target IP addresses, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
'ips'
),
(
'source_ports',
_('Number of events per source port'),
_('This view shows total numbers of IDEA events aggregated according to a source port. Because an event may contain multiple source ports, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
'ports'
),
(
'target_ports',
_('Number of events per target port'),
_('This view shows total numbers of IDEA events aggregated according to a target port. Because an event may contain multiple target ports, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
'ports'
),
(
'protocols',
_('Number of events per protocol/service'),
_('This view shows total numbers of IDEA events aggregated according to a protocol or service. Because an event may contain multiple protocols, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'source_types',
_('Number of events per source type'),
_('This view shows total numbers of IDEA events aggregated according to a source type. Because an event may contain multiple source type tags, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'target_types',
_('Number of events per target type'),
_('This view shows total numbers of IDEA events aggregated according to a target type. Because an event may contain multiple target type tags, the total numbers in these charts may differ from the total number of events displayed in the table above.'),
'multi',
None
),
(
'classes',
_('Number of events per class'),
_('This view shows total numbers of IDEA events aggregated according to an event classification. The event class is a catalogization mechanism similar to the categories. It is however internal only to Mentat system and attempts to group different events describing the same type of incidents.'),
'single',
None
),
(
'severities',
_('Number of events per severity'),
_('This view shows total numbers of IDEA events aggregated according to an event severity. The event severity is internal only to Mentat system and is assigned by predefined set of rules based on the event classification.'),
'single',
None
)
) -%}
{%- if chsection[0] not in hide_sections and (not only_sections or chsection[0] in only_sections) %}
{%- if chsection[0] in statistics or render_empty %}
{{ chsection[1] }}
{%- if chsection[0] not in statistics %}
{%- endif %}
{{ chsection[2] }}
{%- if chsection[0] in statistics %}
{%- set _stats = statistics %}
{%- set _stats_var_name = statistics_var_name %}
{%- else %}
{%- set _stats = None %}
{%- set _stats_var_name = None %}
{%- endif %}
{%- if not _stats_var_name and permission_can('power') %}
{{ macros_site.render_sql_queries([], key=chsection[0]) }}
{{ macros_site.render_timemarks([], key=chsection[0], show_to_render_time=False) }}
{%- endif %}
{%- if 'timeline' in statistics %}
{{ render_chart_timeline_dict(
_stats,
_stats_var_name,
'{}_per'.format(id_prefix.replace('-', '_')),
chsection[0],
cfg_params = cfg_params
)
}}
{%- endif %}
{%- set _dummy = cfg_params.update({'csag_name': chsection[4] or chsection[0]}) -%}
{%- if chsection[3] == 'single' %}
{%- set _dummy = cfg_params.update({'with_table_stats': True}) -%}
{{ render_dataset_pie_dict(
_stats,
_stats_var_name,
'{}_per'.format(id_prefix.replace('-', '_')),
chsection[0],
cfg_params
)
}}
{%- elif chsection[3] == 'multi' %}
{%- set _dummy = cfg_params.update({'with_table_stats': False}) -%}
{{ render_dataset_hbar_dict(
_stats,
_stats_var_name,
'{}_per'.format(id_prefix.replace('-', '_')),
chsection[0],
cfg_params
)
}}
{%- endif %}
{%- if tmp.update({'cntr': tmp['cntr'] + 1}) %}{%- endif %}