Commit graph

114 commits

Author SHA1 Message Date
Robin Sommer
05e6289719 Catching out-of-memory in patricia tree code.
Based on patch by Bill Parker.
2012-12-03 15:42:43 -08:00
Robin Sommer
7ddbca8b35 Merge remote-tracking branch 'origin/topic/jsiwek/subnet-literal-const'
* origin/topic/jsiwek/subnet-literal-const:
  Add parsing rules for IPv4/IPv6 subnet literal constants, addresses #888

Closes #888.
2012-10-24 15:37:49 -07:00
Jon Siwek
46d225cc5b Add parsing rules for IPv4/IPv6 subnet literal constants, addresses #888
This fixes specifying IPv4 subnets in IPv4-mapped-IPv6 format with a
mask length relative to the 128 bits of the mapped IPv6 address.
2012-10-22 15:57:21 -05:00
Daniel Thayer
15033a2b62 Allow faster rebuilds in certain cases
Previously, when rebuilding with a different "--prefix" or "--scriptdir",
all Bro source files were recompiled.  With this change, only util.cc
is recompiled.  Instead of specifying command-line preprocessor
macros on all source files, a header file is regenerated when needed
which only util.cc includes.
2012-10-12 16:54:26 -05:00
Robin Sommer
4da209d3b1 Installing a handler for running out of memory in "new".
Bro will now print an error message in that case rather than abort
with an uncaught exception.
2012-08-16 11:49:51 -07:00
Robin Sommer
4ba038070f Tweaking writer API for failed rotations.
There are now two FinishedRotation() methods, one that triggers
post-processing and one that doesn't. There's also insurance built in
against a writer not calling either (or both), in which case we abort
with an internal error.
2012-07-28 16:38:22 -07:00
Robin Sommer
951444ee73 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  and remove superflous print.
  add testcase for subrecords and events add missing binary testcase (Baseline is in master, testcase is missing for some reason) make error output for nonmatching event types much more verbose
  Add more error handling for close() calls.
  add testcase for subrecords to input framework tests
2012-07-26 14:34:58 -07:00
Jon Siwek
734e5f68d3 Add more error handling for close() calls. 2012-07-26 12:40:12 -05:00
Jon Siwek
4abcfa1f66 Fix complaint from valgrind about uninitialized memory usage. 2012-07-25 12:42:46 -05:00
Robin Sommer
f5214c0793 Merge remote-tracking branch 'origin/topic/bernhard/input-fixes'
* origin/topic/bernhard/input-fixes:
  fix problem with possible access to unititialized memory (thanks robin :) )
  and just to be a little bit careful - add check if the field description is long enough. Otherwise there might possibly be an access of uninitialized memory, when someone reads a file that contains just #fields without any following field descriptions.
  and like nearly always - forgot the baseline.
  Input framework now accepts escaped ascii values as input.
  make reading ascii logfiles work when the input separator is different from \t.
2012-07-24 15:08:35 -07:00
Bernhard Amann
f887535f1c fix problem with possible access to unititialized memory
(thanks robin :) )
2012-07-23 17:28:27 -07:00
Robin Sommer
24aea295fa Merge branch 'topic/robin/master-test'
* topic/robin/master-test: (60 commits)
  Script fix for Linux.
  Updating test base line.
  Another small change to MsgThread API.
  Bug fix for BasicThread.
  make version_ok return true for TLSv12
  Sed usage in canonifier script didn't work on non-Linux systems.
  Changing HTTP DPD port 3138 to 3128.
  Temporarily removing tuning/logs-to-elasticsearch.bro from the test-all-policy.
  More documentation updates.
  Revert "Fixing calc_next_rotate to use UTC based time functions."
  Some documentation updates for elasticsearch plugin.
  Give configure a --disable-perftools option.
  Updating tests for the #start/#end change.
  Further threading and API restructuring for logging and input frameworks.
  Reworking forceful thread termination.
  Moving the ASCII writer over to use UNIX I/O rather than stdio.
  Further reworking the thread API.
  Reworking thread termination logic.
  If a thread doesn't terminate, we log that but not longer proceed (because it could hang later still).
  Removing the thread kill functionality.
  ...
2012-07-23 16:20:44 -07:00
Bernhard Amann
8e453663dd Input framework now accepts escaped ascii values as input.
I managed to completely forget to add unescaping to the input framework -
this should fix it. It now works with the exact same escaping that is
used by the writers (\x##).

Includes one testcase that seems to work - everything else still passes.
2012-07-23 12:43:42 -07:00
Robin Sommer
71fc2a1728 Another small change to MsgThread API.
Threads will now reliably get a call to DoFinish() no matter how the
thread terminates. This will always be called from within the thread,
whereas the destructor is called from the main thread after the child
thread has already terminated.

Also removing debugging code.

However, two problems remain with the ASCII writer (seeing them only
on MacOS):

    - the #start/#end timestamps contain only dummy values right now.
      The odd thing is that once I enable strftime() to print actual
      timestamps, I get crashes (even though strftime() is supposed to
      be thread-safe).

    - occassionally, there's still output missing in tests. In those
      cases, the file descriptor apparently goes bad: a write() will
      suddently return EBADF for reasons I don't understand yet.
2012-07-22 15:50:12 -07:00
Robin Sommer
e90918aa50 Moving the ASCII writer over to use UNIX I/O rather than stdio. 2012-07-19 21:22:28 -07:00
Robin Sommer
f6b883bafc Further reworking the thread API. 2012-07-19 21:22:28 -07:00
Robin Sommer
90763bb2f2 Merge branch 'robin/topic/writer-info'
* robin/topic/writer-info:
  Extending the log writer DoInit() API.
  Reworking log writer API to make it easier to pass additional information to a writer's initialization method.

Conflicts:
	src/logging/WriterBackend.cc
	src/logging/WriterBackend.h
	src/logging/WriterFrontend.cc
2012-07-02 15:20:37 -07:00
Jon Siwek
34ead91f99 Fix inconsistencies in random number generation.
The srand()/rand() interface was being intermixed with the
srandom()/random() one.  The later is now used throughout.

Changed the srand() and rand() BIFs to work deterministically if Bro
was given a seed file (addresses #825).  They also now wrap the
system's srandom() and random() instead of srand() and rand() as per
the above.
2012-06-29 16:24:31 -05:00
Robin Sommer
19eea409c3 Extending the log writer DoInit() API.
We now pass in a Info struct that contains:

    - the path name (as before)
    - the rotation interval
    - the log_rotate_base_time in seconds
    - a table of key/value pairs with further configuration options.

To fill the table, log filters have a new field "config: table[string]
of strings". This gives a way to pass arbitrary values from
script-land to writers. Interpretation is left up to the writer.

Also splits calc_next_rotate() into two functions, one of which is
thread-safe and can be used with the log_rotate_base_time value from
DoInit().

Includes also updates to the None writer:

    - It gets its own script writers/none.bro.

    - New bool option LogNone::debug to enable debug output. It then
      prints out all the values passed to DoInit(). That's used by a
      btest test to ensure the new DoInit() values are right.

    - Fixed a bug that prevented Bro from terminating..

(scripts.base.frameworks.logging.rotate-custom currently fails.
Haven't yet investigated why.)
2012-06-21 17:42:33 -07:00
Jon Siwek
74f3a32321 Enable Bro to communicate with peers over non-global IPv6 addresses.
This usually requires specifying an additional zone identifier
(see RFC 4007).  The connect() and listen() BIFs have been
changed to accept this zone identifier as an argument.
2012-05-17 12:59:20 -05:00
Jon Siwek
79afc834ce Add SHA1 and SHA256 hashing BIFs. (addresses #542)
Also refactor all internal MD5 stuff to use OpenSSL's.
2012-05-04 16:09:05 -05:00
Jon Siwek
1181444f37 Merge branch 'master' into topic/jsiwek/brofiler
Conflicts:
	src/main.cc
2012-01-11 10:57:44 -06:00
Robin Sommer
c1e656d89e In log headers, only escape information when necessary. 2011-12-19 08:44:41 -08:00
Robin Sommer
3220bbce55 Merge remote branch 'origin/topic/jsiwek/log-escaping'
* origin/topic/jsiwek/log-escaping:
  Add missing ascii writer options to log header.
  Escape the ASCII log's set separator (addresses #712)
  Rewrite ODesc character escaping functionality. (addresses #681)

Closes #712.
2011-12-19 06:37:54 -08:00
Jon Siwek
8f8290c852 Add simple profiling class to accumulate Stmt usage stats across runs.
Use the BROFILER_FILE environment variable to point to a file in
which Stmt usage statistics from Bro script-layer can be output.

This should be able to be used to check Bro script coverage that
that e.g. the entire test suite covers.
2011-11-27 15:57:18 -06:00
Robin Sommer
3b1f13b861 Merge remote-tracking branch 'origin/topic/jsiwek/compiler-warnings'
* origin/topic/jsiwek/compiler-warnings:
  Fixing compiler warnings (addresses #388)
2011-11-03 15:18:11 -07:00
Jon Siwek
cec4600d2e Fixing compiler warnings (addresses #388) 2011-11-01 14:44:38 -05:00
Robin Sommer
a08c478079 Fixing a number of reporter calls. 2011-10-06 21:26:49 -07:00
Robin Sommer
bd2e30f521 Merge remote-tracking branch 'origin/topic/dist-cleanup'
* origin/topic/dist-cleanup:
  Updating INSTALL
  Updating README
  Remove $Id$ tags
  Remove policy.old directory, adresses #511
2011-09-18 16:17:42 -07:00
Robin Sommer
db8ab89c3a Merge remote branch 'origin/topic/jsiwek/misc-doc-fixes'
* origin/topic/jsiwek/misc-doc-fixes:
  More tweaks to generated script docs.
  Various changes to documentation framework.

Closes #598.
2011-09-08 09:07:20 -07:00
Robin Sommer
c2501cec51 Merge remote branch 'origin/topic/gilbert/rand-pool'
* origin/topic/gilbert/rand-pool:
  Updating tests.
  Updated uid pools to use integer values instead of strings.
  Updating tests.
  Test no longer relevant.  Need a way to generate and test collisions.
  A few minor tweaks to make code less braindead.  Fixed-length piece of pool name now only used to hash when determinism is not required; otherwise, whole pool name is used.  Note that collisions between pool name hashes will lead to sensitivity to initialization order within the UID generator.
  Testing long (>32 character) pool names.
  Simple test to verify various pools are not affecting each other.
  Some working code.  Adds UID pools classified by string.  Just compiles and runs; need to go back through and make sure this code is actually doing what I want it to do.

Note, I've removed the collision detection. Seems unlikely to occur
and even if, it's not really that bad.
2011-09-07 16:17:59 -07:00
Jon Siwek
80e154ba3c Various changes to documentation framework.
- Reorganize top-level 'doc' Makefile target so submodules can easily
  add their own doc-generating routines to it.  e.g. the Bro project
  makes a placeholder 'doc' target, then adds 'restdoc', 'sphinxdoc';
  later Broccoli can add it's own target as a dependency for generating
  API docs.

- Fixed generated docs for BIFs not being organized under a base/
  subdirectory like the original source files.

- Fixed documentation style for function parameters not applying to
  functions declared as record fields.

- Misc. script documentation tweaks to address warnings given by Sphinx.
2011-09-07 10:02:15 -05:00
Gilbert Clark gc355804@ohio.edu
7bea71a2c2 Updated uid pools to use integer values instead of strings. 2011-08-15 15:47:39 -07:00
Gilbert Clark gc355804@ohio.edu
d46525dcca Merge branch 'master' into topic/gilbert/rand-pool 2011-08-14 22:21:59 -07:00
Gilbert Clark gc355804@ohio.edu
e21feb8487 A few minor tweaks to make code less braindead. Fixed-length piece of pool name now only used to hash when determinism is not required; otherwise,
whole pool name is used.  Note that collisions between pool name hashes will lead to sensitivity to initialization order within the UID generator.
2011-08-09 09:44:31 -07:00
Gilbert Clark gc355804@ohio.edu
9322c063cc Some working code. Adds UID pools classified by string. Just compiles
and runs; need to go back through and make sure this code is actually
doing what I want it to do.

Note: Added new function unique_id_from(pool: string, prefix: string)
that allows the user to explicitly specify a randomness pool to use when
generating unique IDs.
2011-08-08 22:12:40 -07:00
Jon Siwek
4ac6d0ae2e Fixes for script auto-documentation.
- Fixing the parts of the `make restdoc` and `make doc` process that were
  broken by the last Bro script re-organization

- Generated documentation for Bro scripts derived from BiFs now use the
  original BiF source file as the "original source file" link

- Renaming of the internal POLICYDEST definition and other misc places that
  refer to "policy" scripts; that terminology doesn't make total sense now

- Added a documentation blacklist reminder test that will fail if there's
  scripts that are blacklisted from being documentated because they're still
  in progress

- Some minor Bro script changes to fix small @load dependency errors

Addresses #543
2011-08-08 19:50:45 -05:00
Seth Hall
e60213ac11 Fixing default policy search path. 2011-08-06 00:46:12 -04:00
Seth Hall
597a4d6704 Hopefully the last major script reorganization.
- policy/ renamed to scripts/

- By default BROPATH now contains:
	- scripts/
	- scripts/policy
	- scripts/site

- *Nearly* all tests pass.

- All of scripts/base/ is loaded by main.cc
	- Can be disabled by setting $BRO_NO_BASE_SCRIPTS
	- Scripts in scripts/base/ don't use relative path loading to ease use of BRO_NO_BASE_SCRIPTS (to copy and paste that script).

- The scripts in scripts/base/protocols/ only (or soon will only) do logging and state building.

- The scripts in scripts/base/frameworks/ add functionality without causing any additional overhead.

- All "detection" activity happens through scripts in scripts/policy/.

- Communications framework modified temporarily to need an environment variable to actually enable (ENABLE_COMMUNICATION=1)
	- This is so the communications framework can be loaded as part
	  of the base without causing trouble when it's not needed.
	- This will be removed once a resolution to ticket #540 is reached.
2011-08-05 23:09:53 -04:00
Jon Siwek
495e987938 Remove $Id$ tags 2011-08-04 15:21:18 -05:00
Jon Siwek
454fd9578e Fixes to relative @load'ing.
The currently loading script's path is prepended (vs. appended) to
BROPATH to search for the @load'd file to prevent being overshadowed by
scripts/directories/packages in the normal BROPATH with the same name.

This extra search path should also only be prepended to BROPATH in the
case when the @load'd file we're looking for is actually relative
(i.e. the name starts with "./" or "../").
2011-07-23 20:46:35 -05:00
Robin Sommer
1a46d78584 Some small layout tweaks that didn't get committed with the last merge. 2011-07-22 13:35:29 -07:00
Jon Siwek
d97003892b Reimplementation of the @prefixes statement.
Any added prefixes are now used *after* all input files have been
parsed to look for a prefixed, flattened version of the input file
somewhere in BROPATH and, if found, load it.

For example, if "lcl" is in @prefixes, and site.bro is loaded, then
a file named "lcl.site.bro" that's in BROPATH would end up being
automatically loaded as well.  Packages work similarly, e.g. loading
"protocols/http" means a file named "lcl.protocols.http.bro" in BROPATH
gets loaded automatically.
2011-07-14 21:32:02 -05:00
Jon Siwek
e39a49833f Fix accidental overwrite of BROPATH copy. 2011-07-14 18:17:30 -05:00
Jon Siwek
e5e3bf28ec Make @load statements recognize relative paths.
For example a script can do "@load ./foo" to load a script named
foo.bro that lives in the same directory or "@load ../bar" to load
a script named bar.bro in the parent directory, even if those
directories are not contained in BROPATH.
2011-07-14 11:35:23 -05:00
Robin Sommer
5113b100d9 Making valgrind a bit more happy, and adding code that may or may not
help with #490 and #491.
2011-07-10 15:07:37 -07:00
Seth Hall
8bb240af99 Merge branch 'master' of ssh://git.bro-ids.org/bro 2011-07-08 01:46:01 -04:00
Seth Hall
0af6e47ccd Removed the policy subpaths from the Bro core. 2011-07-08 00:06:02 -04:00
Robin Sommer
eb0580c622 Fixing another memory leak.
This is the ConnVal leak that Gilbert also saw.
2011-07-07 19:46:40 -07:00
Robin Sommer
9709b1d522 Merge remote branch 'origin/topic/robin/reporting'
* origin/topic/robin/reporting:
  Syslog BiF now goes through the reporter as well.
  Avoiding infinite loops when an error message handlers triggers errors itself.
  Renaming the Logger to Reporter.
  Overhauling the internal reporting of messages to the user.

Updating a bunch of tests/baselines as well.

Conflicts:
	aux/broccoli
	policy.old/alarm.bro
	policy/all.bro
	policy/bro.init
	policy/frameworks/notice/weird.bro
	policy/notice.bro
	src/SSL-binpac.cc
	src/bro.bif
	src/main.cc
2011-07-01 13:59:21 -07:00