Commit graph

427 commits

Author SHA1 Message Date
Johanna Amann
0e44b91cd9 Merge remote-tracking branch 'origin/topic/seth/log-framework-ext'
* origin/topic/seth/log-framework-ext:
  Log extensions: series of small fixes and new tests.
  Change the function for log extension to take a path only and update tests.
  Final changes to log framework ext code.
  Add logging framework metadata mechanism.
  Add unrolling separator & field name map to logging framework.
2016-08-11 07:47:13 -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
Robin Sommer
3adad5e19a Fix some Coverity warnings. 2016-08-02 11:38:29 -07:00
Robin Sommer
5b73345b73 Merge remote-tracking branch 'origin/topic/johanna/bit-1181'
BIT-1181 #merged

* origin/topic/johanna/bit-1181:
  Input: Further small changes to error handling
  Add error events to input framework.
2016-07-26 14:52:27 -07:00
Robin Sommer
cc67acdcfe Merge remote-tracking branch 'origin/topic/johanna/bit-1325'
BIT-1325 #merged

* origin/topic/johanna/bit-1325:
  Enable SQLite shared cache mode.
2016-07-26 14:39:01 -07:00
Johanna Amann
6b9abe85a7 Add error events to input framework.
This change introduces error events for Table and Event readers. Users
can now specify an event that is called when an info, warning, or error
is emitted by their input reader. This can, e.g., be used to raise
notices in case errors occur when reading an important input stream.

Example:

event error_event(desc: Input::TableDescription, msg: string, level: Reporter::Level)
	{
	...
	}

event bro_init()
	{
	Input::add_table([$source="a", $error_ev=error_event, ...]);
	}

For the moment, this converts all errors in the Asciiformatter into
warnings (to show that they are non-fatal) - the Reader itself also has
to throw an Error to show that a fatal error occurred and processing
will be abort.

It might be nicer to change this and require readers to mark fatal
errors as such when throwing them.

Addresses BIT-1181
2016-07-22 19:45:28 -07:00
Johanna Amann
bd4c32460b SQLite writer: Remove unused string formatting function. 2016-07-22 14:53:31 -07:00
Johanna Amann
4968a5c654 Enable SQLite shared cache mode.
This allows all threads accessing the same database to share sqlite
objects. This, for example, fixes the issue with several threads
simultaneously writing to the same database file.

See https://www.sqlite.org/sharedcache.html

Addresses BIT-1325
2016-07-21 12:10:20 -07:00
Johanna Amann
94e242f2fd Input/Logging: Make operator explicit
This fixes a long-standing todo for once we switch to C++11.
2016-06-27 12:09:31 -07:00
Seth Hall
3e3f6f13cc Add logging framework metadata mechanism.
Example script coming soon.
2016-05-24 09:28:07 -04:00
Seth Hall
b28801ce95 Add unrolling separator & field name map to logging framework.
- When a log record is being "unrolled" (sub-records flattened
   out into a single record), it's now possible to choose the
   character/string to separate the outer name from the inner
   name.  This can be used to work around the problems
   with ElasticSearch 2.0 not supporting dots "." in field names.
   This value can be provided per-filter as well as a global
   default value.
 - Log fields can be renamed by providing a table per-filter
   (or a global default) to rename fields for any log writer.
   The name translation is performed after unrolling so the
   value in the field name table must match whatever is being
   used to separate field names.

   For example if the unrolling separator was set to "*":
	redef Log::default_unrolling_sep = "*";

   The field name map would need to reflect it:
	redef Log::default_field_name_map = {
		["id*orig_h"] = "src",
		["id*orig_p"] = "src_port",
		["id*resp_h"] = "dst",
		["id*resp_p"] = "dst_port",
	};
2016-05-16 12:28:45 -04:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Robin Sommer
9260638948 Removing error check if an ASCII writer has been properly finished.
Turns out that in error situations, the final finish message might not
reach the writer anymore, as communication between the threads will be
shut down. Instead of aborting, we now just clean up in that case and
proceed. This isn't changing any other behaviour. The original error
check was in place mostly for helping debug the data flow between the
threads anyways.

Addresses BIT-1331.
2015-04-15 09:55:15 -07:00
Jon Siwek
9e53722b57 Rename comm/ directories to broker/ 2015-03-05 17:02:25 -06:00
Jon Siwek
fa08083a92 Rename broker-related namespaces.
c++ namespace "comm" -> bro_broker
script module "Comm" -> BrokerComm
script module "Store" -> BrokerStore
2015-03-05 16:20:51 -06:00
Jon Siwek
25a4d0ebed Improve remote logging via broker.
Only send fields with the &log attribute.
2015-03-05 14:07:06 -06:00
Jon Siwek
69693663eb Disable a stream's remote logging via broker if it fails.
If there's something invalid about the stream like trying to log an
unsupported data type, don't keep trying to send remote logs.
2015-03-05 11:53:50 -06:00
Robin Sommer
dfc88094ab Merge remote-tracking branch 'origin/topic/jsiwek/broker'
* origin/topic/jsiwek/broker: (34 commits)
  Update broker submodule.
  Update broker submodule.
  broker integration: add missing baselines for doc tests
  broker integration: add prof.log statistics
  broker integration: add high-level usage documentation
  broker integration: add API documentation (broxygen/doxygen)
  broker integration: fix memory leak, add leak tests
  Update broker submodule.
  Improve comm tests.
  Fix gcc compile warnings.
  broker integration: fix unit tests to work when broker is not enabled.
  Add --enable-c++11 configure flag.
  broker integration: add (un)publish/(un)advertise functions
  broker integration: add knobs to set auto publish/advertise behavior
  broker integration: move listen port for unit tests to a btest variable
  broker integration: add events for incoming connection status updates
  broker integration: adapt to change in expiration_time
  Update coverage unit test baselines.
  broker integration: add Comm::enable function
  broker integration: process debug/diagnostic reports from broker
  ...

Conflicts:
	cmake
	testing/btest/Baseline/plugins.hooks/output
2015-03-02 17:10:15 -08:00
Johanna Amann
ee290c3d7a Crashing bug in WriterBackend when deserializing WriterInfo where config
is present. Testcase crashes on unpatched versions of Bro.

Found by Aaron Eppert <aeppert@gmail.com>.

This (probably) fixes the crash issue with sqlite a few people have
reported on the mailing list in the past.
2015-02-23 13:54:44 -08:00
Johanna Amann
d63dfb0c6f Fix wrong value test in WriterBackend. Found by Aaron Eppert (aeppert@gmail.com) 2015-02-23 10:43:10 -08:00
Jon Siwek
b06d82cced broker integration: add API documentation (broxygen/doxygen)
Also changed asynchronous data store query code a bit; trying to make
memory management and handling of corner cases a bit clearer (former
maybe could still be better, but I need to lookup queries by memory
address to associate response cookies to them, and so wrapping pointers
kind of just gets in the way).
2015-02-17 10:50:57 -06:00
Jon Siwek
2b598e3d5a broker integration: add remote logging
It now works a bit differently than before: whether to send a remote log
write is now a property of the logging stream, not the logging filter
and it's now up the the receiver side filters to instantiate the desired
writer.  i.e. the sender now has no say in what the receiver should use
as the log writer backend.

Under the new style of remote logging, the "Log::enable_remote_logging"
option is repurposed to set the default behavior for new logging
streams.  There's also "Comm::{enable,disable}_remote_logging()" to
explicitly set the desired behavior for a given logging stream.  To
receive remote logs, one calls "Comm::subscribe_to_logs(<topic>)", where
senders implicitly use topics of the form "bro/log/<stream id>".
2015-01-26 14:24:42 -06:00
Robin Sommer
8737eae906 Move DataSeries and ElasticSearch into plugins. 2014-08-08 18:32:21 -07:00
Robin Sommer
8031da4ee7 More polishing of some of the branche's changes. 2014-08-08 18:32:05 -07:00
Robin Sommer
aa731eeaec Final fixes, preparing for merge. 2014-07-31 10:49:50 -07:00
Robin Sommer
f4cbcb9b03 Converting log writers and input readers to plugins. 2014-07-20 19:17:58 +02:00
mlaterman
413871af79 DataSeries compilation issue fixed.
BIT-1121 #merged
2014-06-26 17:25:07 -07:00
Jon Siwek
d7d5497436 Improve/standardize some malloc/realloc return val checks. 2014-04-29 15:26:19 -05:00
Jon Siwek
e8a5ea8844 Refactor various hex escaping code. 2014-04-18 13:19:50 -05:00
Robin Sommer
80d7a1482c Merge remote-tracking branch 'origin/topic/jsiwek/ascii-log-memleak-fix'
* origin/topic/jsiwek/ascii-log-memleak-fix:
  Refactor initialization of ASCII log writer options.
  Fix a memory leak in ASCII log writer.
2014-04-17 18:01:41 -05:00
Jon Siwek
c9b40f1ca7 Change how input/logging threads set their name.
Setting the thread name on every heartbeat uses a mild amount of
cycles and there's not much benefit to doing it there to get the
additional info regarding the number of processed messages since thread
names usually get truncated to 16 characters and omit that part anyway.
2014-04-15 16:36:47 -05:00
Jon Siwek
2a5b209f6d Refactor initialization of ASCII log writer options. 2014-04-15 12:50:10 -05:00
Jon Siwek
13d8908a8d Fix a memory leak in ASCII log writer. 2014-04-14 16:53:49 -05:00
Jon Siwek
0c82b6aa14 Fix a couple nits reported by Coverity.
An unnecessary null pointer check and uninitialized scalar fields.
Don't expect these to be actual problems, but easy enough to fix in
order to silence Coverity.
2014-04-01 11:00:10 -05:00
Seth Hall
9d6c8769ea Quick fix to the ElasticSearch writer. 2014-03-28 08:37:37 -04:00
Robin Sommer
8b241947d6 Fixing a few cases of undefined behaviour introduced by recent
formatter work.

Thanks, Coverity!
2014-03-14 08:45:36 -07:00
Robin Sommer
ff261ea626 Merge remote-tracking branch 'origin/topic/seth/json-formatter'
* origin/topic/seth/json-formatter:
  Updating a couple of tests.
  Expanded support for modifying the timestamp format in the JSON formatter.
  Ascii input reader now supports all config options per-input stream.
  Added an option to the JSON formatter to use ISO 8601 for timestamps.
  Refactored formatters and updated the the writers a bit.

Includes some minor bugfixes and cleanup at various places, including
in old code.
2014-03-13 16:50:56 -07:00
Seth Hall
c591e4f57f Expanded support for modifying the timestamp format in the JSON formatter. 2014-03-12 10:01:59 -04:00
Seth Hall
c9aaf9e753 Added an option to the JSON formatter to use ISO 8601 for timestamps.
- It's not *exactly* ISO 8601 which doesn't seem to support
   subseconds, but subseconds are very important to us and
   most things that support ISO8601 seem to also support subseconds
   in the way I'm implemented it.
2014-03-10 14:22:35 -04:00
Seth Hall
a56c343715 Refactored formatters and updated the the writers a bit.
- Formatters have been abstracted similarly to readers and writers now.
 - The Ascii writer has a new option for writing out logs as JSON.
 - The Ascii writer now has all options availble as per-filter
   options as well as global.
2014-03-10 10:42:59 -04:00
Robin Sommer
69ef268a44 Fixing compile problems with some versions of libc++.
Reported by Craig Leres.
2014-01-13 09:31:23 -08:00
Jon Crussell
cb6f6467c7 Fixed Segmentation fault in SQLite Writer.
Segmentation fault caused by accessing fields with pos which is
one-based for setting SQLite field values. Fix is to simply subtract one
from pos. Discovered when trying to store HTTP traffic to a SQLite
database with the following Bro script:

event bro_init() {
  local filter: Log::Filter = [
    $name = "sqlite",
    $path = "http",
    $config = table(["tablename"] = "http_logs"),
    $writer = Log::WRITER_SQLITE
  ];

  Log::add_filter(HTTP::LOG, filter);
}
2013-11-10 22:02:24 -08:00
Bernhard Amann
363cfb8506 rename the dbname configuration option to tablename.
Sorry for this - I noticed that I named this option quite unfortunately
while writing the documentation.

The patch also removes the dbname configuration option from the sqlite
input reader - it was not used there at all anymore (and I did not notice
that).
2013-10-17 12:24:40 -07:00
Robin Sommer
d127d8d01d Merge remote-tracking branch 'origin/topic/jsiwek/coverity'
* origin/topic/jsiwek/coverity:
  Fix uninitialized (or unused) fields.
  Remove logically dead code.
  Remove dead/unfinished code in unary not expr.
  Fix logic for failed DNS TXT lookups.
  A couple null ptr checks.
  Improve return value checking and error handling.
  Remove unused variable assignments, dead code.
  Prevent division/modulo by zero in scripts.
  Fix unintentional always-false condition.
  Fix invalidated iterator usage.
  Fix DNS_Mgr iterator mismatch.
  Set safe umask when creating script profiler tmp files.
  Fix nesting/indent level whitespace mismatch.
  Add checks to avoid improper negative values use.

BIT-1085 #merged
2013-10-02 11:05:49 -07:00
Jon Siwek
775ec6795e Fix uninitialized (or unused) fields. 2013-09-27 10:13:52 -05:00
Jon Siwek
daf5d0d098 Improve return value checking and error handling. 2013-09-24 17:38:22 -05:00
Robin Sommer
601cdbc6cf Fixing an always false condition.
Reported by clang.
2013-09-23 11:48:56 -07:00