Commit graph

872 commits

Author SHA1 Message Date
Jon Siwek
1b4e0116f4 Allow BRO_DEFAULT_LISTEN_ADDRESS to control broker listen address
This environment variable is now set to listen only on IPv4 loopback
when running unit tests (instead of using the default INADDR_ANY).

This also moves some of the @loads out from init-bare.bro into a new
init-frameworks-and-bifs.bro in order to better support calling BIFs
(like `getenv`) from variable initializations in those particular
frameworks.
2018-06-01 15:38:11 -05:00
Jon Siwek
fe478877c6 Change Intel framework to round-robin insertion events across proxies 2018-05-24 14:36:22 -05:00
Jon Siwek
45178f3051 Add a counter for number of alive nodes within a given cluster pool 2018-05-24 14:33:35 -05:00
Jon Siwek
95ea84e60e Fix how cluster framework tracks worker count 2018-05-24 14:32:45 -05:00
Robin Sommer
fe7e1ee7f0 Merge topic/actor-system throug a squashed commit. 2018-05-18 22:39:23 +00:00
Stephen Hosom
6611d28920 Fix for BIT-1927: notice/extend-email relocation
This is a fairly straightforward change. Previously, users had no
control over whether this script was loaded. By relocating it to
policy, users can now choose whether or not this is necessary
functionality without modifying core Bro scripts.
2018-05-10 09:13:52 -04:00
Seth Hall
e5e1037e91 Fix subnet expiration in the intel framework. 2018-04-27 16:42:19 -04:00
Daniel Thayer
f3e42874b8 Improve config framework documentation comments
Fixed typos and formatting.
2018-03-15 14:16:00 -05:00
Robin Sommer
fff4db5145 Merge remote-tracking branch 'origin/topic/johanna/config'
Closes BIT-1900.

* origin/topic/johanna/config:
  Use port_mgr->Get() in the input framework config changes.
  Allow the empty field separator to be empty; use in config framework.
  Fix small bug in config reader.
  Fix segmentation fault when parsing sets containing invalid elements.
  Add config framework.
2018-02-07 14:10:48 -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
Jon Siwek
3495b2fa9d Fix problems with SumStats non-cluster.bro script
* Add proper namespace scoping to a 'SumStats::process_epoch_result'
  scheduled event.

* Fix iterator invalidation within 'SumStats::process_epoch_result'

* Give 'SumStats::process_epoch_result' a copy of the result table so
  that the SumStats framework can clear the original and move on to the
  next epoch immediately.

* The previous baseline of the basic sumstats unit test did look wrong
  to me and probably was actually indicative of the iterator invalidation
  problem.

Thanks to Jim Mellander for reporting the issues.
2018-01-18 11:14:39 -06:00
Jon Siwek
5ed5587b5c Merge remote-tracking branch 'origin/topic/feature/logging-filter-list'
* origin/topic/feature/logging-filter-list:
  Logging: implement get_filter_names and small fixes.

Removed some superfluous existence checks before deleting table indices.

BIT-1890 #merged
2018-01-17 16:17:43 -06: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
Justin Azoff
43b2b9806e add a max_line_length flag to ContentLine_Analyzer
In ContentLine_Analyzer, prevent excessively long lines being assembled.
The line length will default to just under 16MB, but can be overriden on
a per-analyzer basis.  This is done for the finger,ident, and irc
analyzers.
2017-11-03 16:25:26 -04:00
Justin Azoff
fa88646eec problem: broctl can trigger intel reporter error
a broctl print triggers this error

    Reporter::ERROR    no such index (Cluster::nodes[Intel::p$descr])
    /usr/local/bro/share/bro/base/frameworks/intel/./cluster.bro, line 39

when broctl connects p$descr is empty.  It should probably be set to
'control' somewhere inside broctl, but that would only fix broctl, not
other clients.

diff --git a/aux/bro-aux b/aux/bro-aux
index 02f710a43..43f4b90bb 160000
--- a/aux/bro-aux
+++ b/aux/bro-aux
@@ -1 +1 @@
-Subproject commit 02f710a436dfe285bae0d48d7f7bc498783e11a8
+Subproject commit 43f4b90bbaf87dae1a1073e7bf13301e58866011
diff --git a/aux/broctl b/aux/broctl
index e960be2c1..d3e6cdfba 160000
--- a/aux/broctl
+++ b/aux/broctl
@@ -1 +1 @@
-Subproject commit e960be2c192a02f1244ebca3ec31ca57d64e23dc
+Subproject commit d3e6cdfba496879bd55542c668ea959f524bd723
diff --git a/aux/btest b/aux/btest
index 2810ccee2..e638fc65a 160000
--- a/aux/btest
+++ b/aux/btest
@@ -1 +1 @@
-Subproject commit 2810ccee25f6f20be5cd241155f12d02a79d592a
+Subproject commit e638fc65aa12bd136594451b8c185a7a01ef3e9a
diff --git a/scripts/base/frameworks/intel/cluster.bro b/scripts/base/frameworks/intel/cluster.bro
index 820a5497a..e75bdd057 100644
--- a/scripts/base/frameworks/intel/cluster.bro
+++ b/scripts/base/frameworks/intel/cluster.bro
@@ -32,7 +32,7 @@ event remote_connection_handshake_done(p: event_peer)
 	{
 	# When a worker connects, send it the complete minimal data store.
 	# It will be kept up to date after this by the cluster_new_item event.
-	if ( Cluster::nodes[p$descr]$node_type == Cluster::WORKER )
+	if ( p$descr in Cluster::nodes && Cluster::nodes[p$descr]$node_type == Cluster::WORKER )
 		{
 		send_id(p, "Intel::min_data_store");
 		}
2017-09-28 09:34:38 -04:00
Daniel Thayer
823fba1713 Fix ascii writer to not discard a ".gz" file extension
When Bro writes a compressed log, it uses a file extension of ".gz".
However, upon log rotation the ascii writer script function
"default_rotation_postprocessor_func" was discarding the ".gz"
file extension.  Fixed so that the correct file extension is
preserved after rotation.
2017-08-25 15:39:12 -05: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
Jon Siwek
4d06ee85ce Merge branch 'topic/corelight/ascii-gzip' of https://github.com/corelight/bro
* 'topic/corelight/ascii-gzip' of https://github.com/corelight/bro:
  Add gzip log writing to the ascii writer.
2017-05-22 00:10:09 -05:00
Johanna Amann
ff998dfa43 Lessen cluster node of notice suppression.
With this commit, the data structure that is transfered for notice
suppression is much smaller than before, not including potentially
complex data structures like the fa_file record.
2017-05-03 13:28:16 -07: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
Seth Hall
ff4d624ebe Minor documentation fixes. 2017-03-09 12:18:35 -05: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
809660d48a Tiny mime-type fix from Dan Caselden. 2017-02-14 07:21:00 -08: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
Jan Grashoefer
209a560cc6 Fixed intel expiration reset.
Reinserting the same indicator did not reset the expiration timer for
the indicator in the underlying data store.

Addresses BIT-1790
2017-02-09 19:36:05 +01:00
Seth Hall
645ec39f4b New file types sigs from Keith Lehigh. 2017-01-31 23:33:58 -05:00
Seth Hall
04d41dce5c Tiny xlsx file signature fix.
Thanks to Dan Caselden for noticing!
2016-12-08 08:32:45 -05:00
Daniel Thayer
475682ba7f Fix minor typos in documentation
Some of these fixes are for broken links in the auto-generated docs.
2016-11-14 09:50:19 -06:00
Daniel Thayer
5745213326 Fix minor typos in documentation of various scripts 2016-11-11 14:08:17 -06:00
Daniel Thayer
aa8d200e80 Fix various typos in the openflow framework docs 2016-11-09 14:29:03 -06:00
Daniel Thayer
462eaefc43 Fix some warnings seen while building the docs
Removed references in the docs to a few identifiers that aren't
defined in any Bro scripts.
2016-11-09 14:16:42 -06:00
Daniel Thayer
3057d2b8fb Fix various typos in the NetControl docs
Also fixed warnings that were seen while building the docs
with "make doc".
2016-11-08 15:25:28 -06:00
Seth Hall
15f5deed87 Add a files framework signature for VIM tmp files. 2016-11-02 11:51:38 -04:00
Jan Grashoefer
8c024ca094 Handle removing non-existent intel items.
The intel framework raises a reporter info on removing non-existent
intel items. An according test case has been added.

Fixes #1679.
2016-09-21 00:37:38 +02:00
Jan Grashoefer
cb53a930a2 Separated file and default info added to matches. 2016-09-20 02:04:15 +02:00
Johanna Amann
ff114709db Merge remote-tracking branch 'origin/topic/jazoff/bit-1649'
* origin/topic/jazoff/bit-1649:
  Track outstanding_global_views updates by uid
  Also track recent_global_view_keys on manager

BIT-1649 #merged
2016-08-16 12:11:09 -07:00
Johanna Amann
6e769db23b Log extensions: series of small fixes and new tests.
The extensions now work with optional types, as well with complex types
(like subrecords). Not returning a record in the ext_func no longer
crashes bro.

The default_ext_func was switched to return void in
cases where no extension revord is defined (was bool).

I also got rid of the offsets in the indices - with the rest of the
implementation, that was not really necessary and made the code more
complex.
2016-08-10 14:14:03 -07:00
Seth Hall
79e49e1ab5 Change the function for log extension to take a path only and update tests.
We were having stack overflow issues creep in with the self-referential
field for the log extension function.
2016-08-10 13:53:27 -04:00
Seth Hall
5f6565d62c Final changes to log framework ext code.
The "metadata" functionality has been renamed to "ext" to
represent that the logs are being extended.  The function that
returns the record which is used to extend the log now receives
a log filter as it's single argument.

The field name "unrolling" is now renamed to "scope" so the variables
names now look like this: "Log::default_scope_sep"
2016-08-10 12:43:32 -04:00
Seth Hall
a60ce35103 Merge remote-tracking branch 'origin/master' into topic/seth/log-framework-ext 2016-08-10 10:28:04 -04:00
Seth Hall
4a3dfe69b1 Add an argument to "disable_analyzer" to not do a reporter message by default.
If the analyzer is not found directly attached to the connection,
useless error messages are being output.  There are now several
cases where analyzers are attached within other analyzers so the
connection itself doesn't know about the analyzer.  This hides
these useless messages.
2016-08-09 10:22:31 -04:00
Seth Hall
86665e381b Merge branch 'master' into topic/seth/smb 2016-08-08 15:47:39 -04:00
Seth Hall
520ac8d92c Merge remote-tracking branch 'origin/master' into topic/seth/smb
# Conflicts:
#	scripts/base/protocols/dce-rpc/main.bro
#	scripts/base/protocols/ntlm/main.bro
#	scripts/policy/protocols/smb/smb1-main.bro
#	src/analyzer/protocol/smb/smb-common.pac
#	src/analyzer/protocol/smb/smb-strings.pac
#	src/analyzer/protocol/smb/smb1-com-locking-andx.pac
#	src/analyzer/protocol/smb/smb1-com-logoff-andx.pac
#	src/analyzer/protocol/smb/smb1-com-nt-create-andx.pac
#	src/analyzer/protocol/smb/smb1-com-open-andx.pac
#	src/analyzer/protocol/smb/smb1-com-read-andx.pac
#	src/analyzer/protocol/smb/smb1-com-session-setup-andx.pac
#	src/analyzer/protocol/smb/smb1-com-transaction-secondary.pac
#	src/analyzer/protocol/smb/smb1-com-transaction.pac
#	src/analyzer/protocol/smb/smb1-com-tree-connect-andx.pac
#	src/analyzer/protocol/smb/smb1-com-write-andx.pac
#	src/analyzer/protocol/smb/smb1-protocol.pac
2016-08-08 15:46:49 -04:00
Seth Hall
117b5c3ac7 Lots of SMB1 parsing fixes. 2016-08-08 15:36:07 -04:00
Robin Sommer
84b372a772 Merge remote-tracking branch 'origin/topic/johanna/rule-reasons'
BIT-1655 #merged

* origin/topic/johanna/rule-reasons:
  NetControl: allow reasons in remove_rule calls.
2016-08-05 18:48:19 -07:00