hawat.blueprints.filters.forms module

This module contains custom reporting filter management forms for Hawat.

class hawat.blueprints.filters.forms.AdminFilterForm(*args, **kwargs)[source]

Bases: BaseFilterForm

Class representing reporting filter create form.

group = <UnboundField(QuerySelectField, (l'Group:',), {'query_factory': <function get_available_groups>, 'allow_blank': False})>
class hawat.blueprints.filters.forms.BaseFilterForm(*args, **kwargs)[source]

Bases: BaseItemForm

Class representing base reporting filter form.

cancel = <UnboundField(SubmitField, (l'Cancel',), {})>
categories = <UnboundField(SelectMultipleField, (l'Categories:',), {'validators': [<wtforms.validators.Optional object>], 'filters': [<function BaseFilterForm.<lambda>>]})>
description = <UnboundField(TextAreaField, (l'Description:',), {'validators': [<wtforms.validators.DataRequired object>]})>
detectors = <UnboundField(SelectMultipleField, (l'Detectors:',), {'validators': [<wtforms.validators.Optional object>], 'filters': [<function BaseFilterForm.<lambda>>]})>
enabled = <UnboundField(RadioField, (l'State:',), {'validators': [<wtforms.validators.InputRequired object>], 'choices': [(True, l'Enabled'), (False, l'Disabled')], 'filters': [<function str_to_bool>], 'coerce': <function str_to_bool>})>
filter = <UnboundField(TextAreaField, (l'Filter:',), {'validators': [<wtforms.validators.Optional object>, <function check_filter>]})>
name = <UnboundField(StringField, (l'Name:',), {'validators': [<wtforms.validators.DataRequired object>, <wtforms.validators.Length object>, <function check_null_character>]})>
preview = <UnboundField(SubmitField, (l'Preview',), {})>
sources = <UnboundField(CommaListField, (l'Source IPs:',), {'validators': [<wtforms.validators.Optional object>, <function check_network_record_list>], 'widget': <wtforms.widgets.core.TextArea object>})>
submit = <UnboundField(SubmitField, (l'Submit',), {})>
type = <UnboundField(SelectField, (l'Type:',), {'validators': [<wtforms.validators.DataRequired object>], 'choices': [('basic', l'Basic'), ('advanced', l'Advanced')]})>
valid_from = <UnboundField(SmartDateTimeField, (l'Valid from:',), {'validators': [<wtforms.validators.Optional object>]})>
valid_to = <UnboundField(SmartDateTimeField, (l'Valid to:',), {'validators': [<wtforms.validators.Optional object>]})>
class hawat.blueprints.filters.forms.FilterSearchForm(*args, **kwargs)[source]

Bases: BaseSearchForm

Class representing simple user search form.

dt_from = <UnboundField(SmartDateTimeField, (l'Creation time from:',), {'validators': [<wtforms.validators.Optional object>], 'description': l'Lower time boundary for item creation time. Timestamp is expected to be in the format <code>YYYY-MM-DD hh:mm:ss</code> and in the timezone according to the user`s preferences.'})>
dt_to = <UnboundField(SmartDateTimeField, (l'Creation time to:',), {'validators': [<wtforms.validators.Optional object>], 'description': l'Upper time boundary for item creation time. Timestamp is expected to be in the format <code>YYYY-MM-DD hh:mm:ss</code> and in the timezone according to the user`s preferences.'})>
group = <UnboundField(QuerySelectField, (l'Group:',), {'query_factory': <function get_available_groups>, 'allow_blank': True, 'description': l'Search for filters belonging to particular group.'})>
static is_multivalue(field_name)[source]

Check, if given form field is a multivalue field.

Parameters

field_name (str) – Name of the form field.

Returns

True, if the field can contain multiple values, False otherwise.

Return type

bool

search = <UnboundField(StringField, (l'Name, filter, description:',), {'validators': [<wtforms.validators.Optional object>, <wtforms.validators.Length object>, <function check_null_character>], 'filters': [<function FilterSearchForm.<lambda>>, <method 'strip' of 'str' objects>], 'description': l'Filter`s name, content or description. Search is performed even in the middle of the strings.'})>
sortby = <UnboundField(SelectField, (l'Sort by:',), {'validators': [<wtforms.validators.Optional object>], 'choices': [('createtime.desc', l'by creation time descending'), ('createtime.asc', l'by creation time ascending'), ('name.desc', l'by netname descending'), ('name.asc', l'by netname ascending'), ('hits.desc', l'by number of hits descending'), ('hits.asc', l'by number of hits ascending'), ('last_hit.desc', l'by time of last hit descending'), ('last_hit.asc', l'by time of last hit ascending')], 'default': 'name.asc'})>
state = <UnboundField(SelectField, (l'State:',), {'validators': [<wtforms.validators.Optional object>], 'choices': [('', l'Nothing selected'), ('enabled', l'Enabled'), ('disabled', l'Disabled')], 'default': '', 'description': l'Search for filters with particular state.'})>
type = <UnboundField(SelectField, (l'Type:',), {'validators': [<wtforms.validators.Optional object>], 'choices': [('', l'Nothing selected'), ('basic', l'Basic'), ('advanced', l'Advanced')], 'default': '', 'description': l'Search for filters of particular type.'})>
class hawat.blueprints.filters.forms.PlaygroundFilterForm(*args, **kwargs)[source]

Bases: FlaskForm

Class representing IP geolocation search form.

event = <UnboundField(TextAreaField, (l'IDEA event:',), {'validators': [<wtforms.validators.DataRequired object>, <function check_event>]})>
filter = <UnboundField(TextAreaField, (l'Filtering rule:',), {'validators': [<wtforms.validators.DataRequired object>, <function check_filter>]})>
submit = <UnboundField(SubmitField, (l'Check',), {})>
hawat.blueprints.filters.forms.check_event(_form, field)[source]

Callback for validating IDEA event JSON.

hawat.blueprints.filters.forms.check_filter(_form, field)[source]

Callback for validating Pynspect filter.

hawat.blueprints.filters.forms.get_available_groups()[source]

Query the database for list of all available groups.