zeek/testing/btest/core
Johanna Amann db6f028003 Add config framework.
The configuration framework consists of three mostly distinct parts:

* option variables
* the config reader
* the script level framework

I will describe the three elements in the following.

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).

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.

option variable
===============

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:

option testbool: bool = T;

function option_changed(ID: string, new_value: bool): bool
  {
  print fmt("Value of %s changed from %s to %s", ID, testbool, new_value);
  return new_value;
  }

event bro_init()
  {
  print "Old value", testbool;
  Option::set_change_handler("testbool", option_changed);
  Option::set("testbool", F);
  print "New value", testbool;
  }

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:

[option name][tab/spaces][new variable value]

so, for example:

testaddr 2607:f8b0:4005:801::200e
testinterval 60
testtime 1507321987
test_set a	b	c	d	erdbeerschnitzel

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:

type Idx: record {
  option_name: string;
};

type Val: record {
  option_val: string;
};

global currconfig: table[string] of string = table();

event InputConfig::new_value(name: string, source: string, id: string, value: any)
  {
  print id, value;
  }

event bro_init()
  {
  Input::add_table([$reader=Input::READER_CONFIG, $source="../configfile", $name="configuration", $idx=Idx, $val=Val, $destination=currconfig, $want_record=F]);
  }

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:

redef Config::config_files += {configfile};

export {
  option testbool : bool = F;
}

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.
2017-11-29 13:46:59 -08:00
..
icmp BIT-342: add "icmp_sent_payload" event. 2015-03-18 16:16:24 -05:00
leaks Fix the test group name in some broker test files 2017-04-07 12:24:29 -05:00
pcap Fix test core.pcap.dumper to work on OpenBSD 2016-12-01 16:35:54 -06:00
tcp Change TCP analysis to process connections without the initial SYN as 2016-07-11 17:18:32 -07:00
tunnels Fix OOB read in Sessions.cc 2017-10-19 10:29:29 -07:00
bits_per_uid.bro Add bits_per_uid unit test, addressing BIT0-1016. 2013-08-28 16:12:11 -05:00
check-unused-event-handlers.test Add a canonifier to a unit test's output. 2015-03-30 10:23:52 -05:00
checksums.test Update tests (use weird.log instead of stderr) 2012-05-11 17:09:01 -05:00
conn-size-threshold.bro Add high level api for thresholding that holds lists of thresholds 2015-04-17 06:57:58 -07:00
conn-uid.bro Remove connection compressor (addresses #559). 2012-02-27 11:35:25 -06:00
connection_flip_roles.bro Improve analysis of TCP SYN/SYN-ACK reversal situations. 2014-03-11 17:03:59 -05:00
disable-mobile-ipv6.test Update tests (use weird.log instead of stderr) 2012-05-11 17:09:01 -05:00
discarder.bro Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
div-by-zero.bro Prevent division/modulo by zero in scripts. 2013-09-20 16:36:00 -05:00
dns-init.bro Merge remote-tracking branch 'origin/topic/jsiwek/fix-dns-double-free' 2011-12-01 16:40:07 -08:00
enum-redef-exists.bro Fix segfault when an existing enum identifier is added again with a 2016-07-05 17:54:10 -07:00
erspan.bro Implement ERSPAN support. 2017-02-03 12:29:22 -08:00
ether-addrs.bro Moved link-layer addresses into endpoints. 2016-06-02 01:46:26 +02:00
event-arg-reuse.bro Merge remote-tracking branch 'origin/topic/robin/event-args' 2017-11-21 13:24:07 -06:00
expr-exception.bro Reworking thread termination logic. 2012-07-19 21:21:53 -07:00
fake_dns.bro Teach async DNS lookup builtin-functions about BRO_DNS_FAKE. 2014-03-10 16:51:04 -05:00
file-caching-serialization.test Changes to open-file caching limits and uncached file unserialization. 2012-05-03 13:13:58 -05:00
global_opaque_val.bro Fix global opaque val segfault, addresses BIT-1071 2013-08-29 17:17:40 -05:00
history-flip.bro Fix layer 2 connection flipping. 2017-01-30 15:13:56 -08:00
ip-broken-header.bro Fix OOB read in Sessions.cc 2017-10-19 10:29:29 -07:00
ipv6-atomic-frag.test Update IPv6 atomic fragment unit test to filter output of ICMPv6. 2012-04-10 11:09:07 -05:00
ipv6-flow-labels.test FileAnalysis: add unit tests covering current protocol integration. 2013-03-19 15:50:05 -05:00
ipv6-frag.test Add unit test for IPv6 fragment reassembly. 2012-03-12 15:26:51 -05:00
ipv6_esp.test Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
ipv6_ext_headers.test Improve handling of IPv6 Routing Type 0 headers. 2012-03-28 13:49:28 -05:00
ipv6_zero_len_ah.test Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
load-duplicates.bro Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
load-pkg.bro Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
load-prefixes.bro Fixes for script auto-documentation. 2011-08-08 19:50:45 -05:00
load-relative.bro Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
load-unload.bro Quick pass over unit tests, adding -b flag to bro so they run faster. 2012-11-30 17:44:36 -06:00
mobile-ipv6-home-addr.test Add support for mobile IPv6 Mobility Header (RFC 6275). 2012-04-09 14:39:00 -05:00
mobile-ipv6-routing.test Add support for mobile IPv6 Mobility Header (RFC 6275). 2012-04-09 14:39:00 -05:00
mobility-checksums.test Fix mobility checksums unit test. 2012-05-17 14:47:09 -05:00
mobility_msg.test Add support for mobile IPv6 Mobility Header (RFC 6275). 2012-04-09 14:39:00 -05:00
mpls-in-vlan.bro Support for MPLS over VLAN. 2014-02-14 12:07:24 -08:00
negative-time.test Ignoring packets with negative timestamps. 2016-05-23 13:22:22 -07:00
nop.bro Fixing bug causing crash when running without arguments. 2011-07-07 19:56:48 -07:00
option-errors.bro Add config framework. 2017-11-29 13:46:59 -08:00
option-priorities.bro Add config framework. 2017-11-29 13:46:59 -08:00
option-redef.bro Add config framework. 2017-11-29 13:46:59 -08:00
option-runtime-errors.bro Add config framework. 2017-11-29 13:46:59 -08:00
pppoe.test Adding a test for PPPoE support. 2012-10-24 01:05:01 -04:00
print-bpf-filters.bro Another test fix. 2013-07-18 21:34:02 -07:00
q-in-q.bro Add support for 802.1ah (Q-in-Q). 2013-03-22 12:38:43 -04:00
radiotap.bro Improved Radiotap support and a test. 2016-01-19 04:10:44 -05:00
raw_packet.bro Refactor to make bro use a common Packet object. 2015-05-29 10:37:39 -04:00
reassembly.bro Extending rexmit_inconsistency() event to receive an additional 2015-10-26 14:16:08 -07:00
recursive-event.bro Fixing test portability. 2016-06-15 09:05:36 -07:00
reporter-error-in-handler.bro Avoiding infinite loops when an error message handlers triggers errors 2011-07-01 10:04:27 -07:00
reporter-fmt-strings.bro Fix reporter using part of the actual message as a format string 2011-08-12 23:24:44 -07:00
reporter-parse-error.bro Renaming the Logger to Reporter. 2011-07-01 09:22:33 -07:00
reporter-runtime-error.bro Renaming the Logger to Reporter. 2011-07-01 09:22:33 -07:00
reporter-type-mismatch.bro Renaming the Logger to Reporter. 2011-07-01 09:22:33 -07:00
reporter.bro Renaming reporter_message to report_info. 2011-07-07 19:56:25 -07:00
truncation.test Fix OOB read in Sessions.cc 2017-10-19 10:29:29 -07:00
vlan-mpls.bro Hopefully the last major script reorganization. 2011-08-05 23:09:53 -04:00
when-interpreter-exceptions.bro Another attempt to improve core.when-interpreter-exceptions unit test. 2013-12-11 14:28:23 -06:00
x509-generalizedtime.bro Refactor X509 generalizedtime support and test. 2015-09-18 12:46:49 -07:00