Please merge topic/johanna/config

Description

Please merge topic/johanna/config

contains an implementation of the
configuration framework as it was discussed in an earlier thread bro-dev.

Convenience link for diff: https://github.com/bro/bro/compare/topic/johanna/config

Please attribute this change to Corelight.

Main changes are:

option variables

The option keyword allows variables to be specified as run-tine options.
Such variables cannot be changed using normal assignments. Instead, they
can be changed using Option::set. It is possible to "subscribe" to
options and be notified when an option value changes.

Change handlers can also change values before they are applied; this
gives them the opportunity to reject changes. Priorities can be
specified if there are several handlers for one option.

Example script:

config reader

The config reader provides a way to read configuration files back into
Bro. Most importantly it automatically converts values to the correct
types. This is important because it is at least inconvenient (and
sometimes near impossible) to perform the necessary type conversions in
Bro scripts themselves. This is especially true for sets/vectors.

Configuration generally look like this:

so, for example:

The reader uses the option name to look up the type that variable has in
the Bro core and automatically converts the value to the correct type.

Example script use:

Script-level config framework

The script-level framework ties these two features together and makes
them a bit more convenient to use. Configuration files can simply be
specified by placing them into Config::config_files. The framework also
creates a config.log that shows all value changes that took place.

Usage example:

The file is now monitored for changes; when a change occurs the
respective option values are automatically updated and the value change
is written to config.log.

Other changes

Internally, this commit also performs a range of changes to the Input
manager; it marks a lot of functions as const and introduces a new
ValueToVal method (which could in theory replace the already existing
one - it is a bit more powerful).

Another small change to the input framework allows the definition of an
empty set to be an empty string - this is not just useful for the config
framework (where it is the default), but could be desired behavior for
a range of cases.

This also changes SerialTypes to have a subtype for Values, just as
Fields already have it; I think it was mostly an oversight that this was
not introduced from the beginning. This should not necessitate any code
changes for people already using SerialTypes.

The branch also fixes a segfault that could be caused by the input framework
reading data that could not be parsed into a set.

Environment

None

Assignee

Robin Sommer

Reporter

Johanna Amann

Labels

None

External issue ID

None

Components

Fix versions

Affects versions

Priority

Normal
Configure