Commit graph

433 commits

Author SHA1 Message Date
Jon Siwek
da9f91fc19 Add env. variables to override Broker listen/connect retry intervals
And use them to default retries to 1sec for all unit tests.
2018-08-16 12:16:03 -05:00
Jon Siwek
2d47586473 Merge remote-tracking branch 'origin/topic/johanna/config-framework-fixes'
* origin/topic/johanna/config-framework-fixes:
  Fix test that fails now that options are automatically redefable.
  Make options redef-able by default.
  Ascii formatter: do not complain about port text.
  Make parsing of booleans a little bit more lenient.
2018-08-13 10:54:39 -05:00
Jon Siwek
9f12b56105 Misc. unit test improvements 2018-08-10 16:58:27 -05:00
Johanna Amann
26ea1999ec Ascii formatter: do not complain about port text.
The ascii formatter already was happy to read ports in the form
"42/tcp"; however it emitted a warning message for each line.

This patch fixes this and adds a bit more testing for the existing
behavior.
2018-08-10 11:29:35 -07:00
Johanna Amann
116079a9ad Make parsing of booleans a little bit more lenient.
This makes the input framework (and everything else that uses the Ascii
parser) accept 0 and 1 as valid values for booleans.
2018-08-10 10:03:22 -07:00
Vern Paxson
88fd7510c6 reap the fruits of v += e 2018-07-26 12:51:36 -07:00
Robin Sommer
0f74e1eedd Add serialization group to clustered config framework tests. 2018-07-24 01:39:39 +00:00
Robin Sommer
f4cd567f84 Merge remote-tracking branch 'origin/topic/johanna/config-cluster'
BIT-1958 #merged

* origin/topic/johanna/config-cluster:
  Add vector to read_config_cluster test.
  Fix special-case-bug for vectors in UnaryExpr.
  Config: another cluster test-case, this time reading in a file.
  Add sending of values to nodes that dropped out.
  Continue work on config framework clusterization.
  Teach Option::set to unwrap Broker::Data values
  Start clusterizing configuration framework.
2018-07-24 01:36:59 +00:00
Johanna Amann
f3d4ba51af Add vector to read_config_cluster test.
It works now after fixing the vector-any-UnaryExpr Bro bug.
2018-07-20 13:41:44 -07:00
Jon Siwek
6215d45f10 Improve control framework id-update/test output 2018-07-20 11:59:40 -05:00
Johanna Amann
da58f9d4a6 Merge remote-tracking branch 'origin/master' into topic/johanna/config-cluster 2018-07-18 09:56:01 -07:00
Jon Siwek
d245513e0a Improve some netcontrol unit tests 2018-07-18 09:51:49 -05:00
Jon Siwek
bf67076cdc Improve an input framework unit test 2018-07-17 17:51:52 -05:00
Jon Siwek
15d74ac081 BIT-1941: improve unit test stability
Mostly trying to standardize the way tests sleep for arbitrary amounts
of time to make it easier to tell at which particular point the
unit test actually may need the timeout interval increased (or else
debugged further).
2018-07-03 15:00:52 -05:00
Jon Siwek
df3ce608e3 Fix unstable cluster/logging test 2018-07-03 10:25:14 -05:00
Jon Siwek
a6ddc882c3 Fix unstable config framework test 2018-07-03 09:34:33 -05:00
Johanna Amann
30c259864c Config: another cluster test-case, this time reading in a file.
This test-case has actually revealed an interesting issue - it works as
is, but as soon as one adds a vector, one gets the fun error-message

fatal error in any: BroType::AsVectorType (any/vector) (any)

This will require a bit more digging :).
2018-06-29 13:34:05 -07:00
Johanna Amann
c28f1ae0ce Add sending of values to nodes that dropped out.
The only node that cannot be recovered is the manager - and the manager
should just re-read its own configuration and be ok :)
2018-06-29 13:10:00 -07:00
Johanna Amann
d6990119db Continue work on config framework clusterization.
This does not currently work.
2018-06-27 10:47:17 -07:00
Jon Siwek
3679b0d963 Teach Option::set to unwrap Broker::Data values 2018-05-31 12:45:44 -05:00
Johanna Amann
44dfcb7c6a Start clusterizing configuration framework.
This is not finished and currently does not work due Broker not liking
to serialize into any types.
2018-05-29 14:08:05 -07:00
Jon Siwek
fe478877c6 Change Intel framework to round-robin insertion events across proxies 2018-05-24 14:36:22 -05:00
Robin Sommer
fe7e1ee7f0 Merge topic/actor-system throug a squashed commit. 2018-05-18 22:39:23 +00:00
Daniel Thayer
075edbdd2b Sort output of the missing-file-initially.bro test
The output needs to be sorted to ensure that the test doesn't fail.
2018-05-09 14:30:22 -05:00
Jon Siwek
5572d05921 Merge remote-tracking branch 'origin/topic/dnthayer/test-improvements'
* origin/topic/dnthayer/test-improvements:
  Fix the ip-broken-header.bro test on macOS
  Improve reliability of the logging rotate.bro test
  Improve reliability of missing-file-initially.bro test

BIT-1929 #merged
2018-05-01 18:29:59 -05:00
Seth Hall
c973375f1f Add subnet intel expiration to a test. 2018-04-27 19:55:22 -04:00
Daniel Thayer
6600556f51 Improve reliability of the logging rotate.bro test
Occasionally a few lines in the first part of the output file were
not in the expected order (this seems to be caused by each line in the
output being created by a process that is run in the background but
bro doesn't wait for it to finish).  Fixed by sorting the output.
2018-04-23 12:31:59 -05:00
Daniel Thayer
e16cc13667 Improve reliability of missing-file-initially.bro test
This test has failed numerous times on Travis CI.  Fixes to make this
test more reliable:  create the does-not-exist.dat file atomically, and
increase wait time after starting bro in order to give all input
streams a chance to try to read the input file.

Also added the input stream name to the test output, in order to make
output easier to understand if the test fails again.
2018-04-23 12:26:16 -05:00
Daniel Thayer
873049ce12 Fix the config framework several-files.bro test
The test script needs to wait until the Input::end_of_data event has
been raised for each of the config input files.
2018-02-12 15:05:38 -06:00
Robin Sommer
0e83bd3193 Fixing unstable test. 2018-02-07 14:21:25 -08:00
Johanna Amann
ac9fd000e0 Merge remote-tracking branch 'origin/master' into topic/johanna/config 2018-01-29 14:43:20 -08:00
Johanna Amann
196994a48d Allow the empty field separator to be empty; use in config framework.
This small change allows the empty field separator to be empty. This
means that we can represent an empty list by a empty input string, which
was not possible before.

Before, an empty empty field separator meant that there is no empty
field - to get back to this behavior one now has to set the empty field
separator to a string that is guaranteed to not be part of the input
data. Note that we did not use "empty" empty field separators anywhere
and I am not aware of this being used by anyone - the new behavior seems
like it is much more useful in practice.

This also changes the config framework to interpret empty lists as...
empty, instead of interpreting them as lists that have one zero-length
element; this seems like the saner default.
2018-01-29 14:22:59 -08:00
Johanna Amann
01005e99af Fix small bug in config reader.
The configure reader had a small bug that caused the tracking of changed
variables to be incorrect after the second update. This resulted in
change-events for unchanged variables.
2018-01-29 14:22:56 -08:00
Johanna Amann
b0be6c90fe Fix segmentation fault when parsing sets containing invalid elements.
Currently the destructor would try to free unallocated memory. This
could e.g. be triggered by the input framework reading a set with an
invalid element.
2018-01-29 14:22:44 -08:00
Johanna Amann
a4a9bf4199 Logging: implement get_filter_names and small fixes.
get_filter_names(id: ID) : set[string] returns the names of the current
list of filters for a specified log stream.

Furthermore this commit makes a number of logging functions more robust
by checking existence of values before trying to modify them. This
commit also really implements (and tests) the enable_stream function.
2018-01-17 09:47:20 -08:00
Seth Hall
7cb6cf24a6 Functions for retrieving files by their id.
There are two new script level functions to query and lookup files
from the core by their IDs.  These are adding feature parity for
similarly named functions for files.  The function prototypes are
as follows:

  Files::file_exists(fuid: string): bool
  Files::lookup_File(fuid: string): fa_file
2018-01-09 12:16:17 -05:00
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
Daniel Thayer
aee307f02b Add more test cases to ascii-double.bro 2017-11-02 16:16:06 -05:00
Daniel Thayer
75647a448c Add test to verify that log rotation works with gzipped logs 2017-09-15 12:17:31 -05:00
Daniel Thayer
c251245538 Fix a netcontrol test that often fails
The catch-and-release.bro test was failing whenever three conditions
were all true:  sorting the netcontrol.log before comparing to
the baseline, the presence of LC_ALL=C in btest.cfg changes the sort
order, and sometimes the timestamp increases slightly beginning
with one of the rule_id == 5 lines.

As a result of these three conditions, the sorted order of the lines
with rule_id of 5 were different than the baseline.

Fixed by not sorting netcontrol.log, as this doesn't seem necessary.
2017-08-07 16:26:17 -05:00
Johanna Amann
3bb05693d9 Add canonifier to catch and release test that should fix test failures. 2017-07-28 09:40:58 -07:00
Seth Hall
71c9945f26 Several fixes and improvements for software version parsing.
- Addresses Philip Romero's question from the Bro mailing list.
 - Adds Microsoft Edge as a detected browser.
 - We are now unescaping encoded characters in software names.
2017-07-13 02:22:03 -04:00
Daniel Thayer
e9102f3de4 Remove loading of listen.bro in tests that do not need it
Removed the loading of "frameworks/communication/listen" from some
tests that don't need that functionality.  This is to avoid
serializing these tests.
2017-05-24 21:28:56 -05:00
Johanna Amann
c868a19a28 Add gzip log writing to the ascii writer.
This feature can be enabled globally for all logs by setting
LogAscii::gzip_level to a value greater than 0.

This feature can be enabled on a per-log basis by setting gzip-level in
$confic to a value greater than 0.
2017-04-24 13:15:32 -07:00
Johanna Amann
bdc693e72a NetControl: small rule_error changes
* add rule_error test for acld plugin

* add namespace for rule_error calls in OpenFlow
2017-04-07 10:26:34 -07:00
Daniel Thayer
ca51dfc9c7 Fix a test that was failing on some platforms
Fixed by sorting the .stderr file, since the ordering of lines was
not consistent on all platforms.
2017-03-22 14:37:37 -05:00
Johanna Amann
6544e36564 Remove cluster catch and release.
This test keeps failing intermittently because of timing issues that are
surprisingly hard to fix.
2017-03-15 08:00:36 -07:00
Johanna Amann
b6e6302b40 Ascii reader error changes - fix small bugs
The changes are now a bit more succinct with less code changes required.
Behavior is tested a little bit more thoroughly and a memory problem
when reading incomplete lines was fixed. ReadHeader also always directly
returns if header reading failed.

Error messages now are back to what they were before the change, if the
new behavior is not used.

I also tweaked the documentation text a bit.
2017-03-03 12:42:44 -08:00
Seth Hall
75744d22bc Input's ascii reader is now more resilient.
By default, the ASCII reader does not fail on errors anymore.
If there is a problem parsing a line, a reporter warning is
written and parsing continues.  If the file is missing or can't
be read, the input thread just tries again on the next heartbeat.

Options have been added to recreate the previous behavior...

const InputAscii::fail_on_invalid_lines: bool;
and
const InputAscii::fail_on_file_problem: bool;

They are both set to `F` by default which makes the input readers
resilient to failure.
2017-02-23 23:13:12 -05:00
Seth Hall
ffa34180df Merge branch 'topic/jgras/bit-1790' of https://github.com/J-Gras/bro into topic/seth/BIT-1790 2017-02-10 09:39:27 -05:00