Commit graph

3113 commits

Author SHA1 Message Date
Robin Sommer
a7ced3228b Removing language.rare-events test which is no longer meaningful.
It relied on the now removed netstats_update event.
2011-06-25 18:10:40 -07:00
Robin Sommer
93894eed9b Overhauling the internal reporting of messages to the user.
The Logger class is now in charge of reporting all errors, warnings,
informational messages, weirds, and syslogs. All other components
route their messages through the global bro_logger singleton.

The Logger class comes with these reporting methods:

    void Message(const char* fmt, ...);
    void Warning(const char* fmt, ...);
    void Error(const char* fmt, ...);
    void FatalError(const char* fmt, ...); // Terminate Bro.
    void Weird(const char* name);
    [ .. some more Weird() variants ... ]
    void Syslog(const char* fmt, ...);
    void InternalWarning(const char* fmt, ...);
    void InternalError(const char* fmt, ...); // Terminates Bro.

See Logger.h for more information on these.

Generally, the reporting now works as follows:

    - All non-fatal message are reported in one of two ways:

        (1) At startup (i.e., before we start processing packets),
            they are logged to stderr.

        (2) During processing, they turn into events:

            event log_message%(msg: string, location: string%);
            event log_warning%(msg: string, location: string%);
            event log_error%(msg: string, location: string%);

            The script level can then handle them as desired.

            If we don't have an event handler, we fall back to
            reporting on stderr.

    - All fatal errors are logged to stderr and Bro terminates
      immediately.

    - Syslog(msg) directly syslogs, but doesn't do anything else.

The three main types of messages can also be generated on the
scripting layer via new Log::* bifs:

    Log::error(msg: string);
    Log::warning(msg: string);
    Log::message(msg: string);

These pass through the bro_logger as well and thus are handled in the
same way. Their output includes location information.

More changes:

    - Removed the alarm statement and the alarm_hook event.

    - Adapted lots of locations to use the bro_logger, including some
      of the messages that were previously either just written to
      stdout, or even funneled through the alarm mechanism.

    - No distinction anymore between Error() and RunTime(). There's
      now only one class of errors; the line was quite blurred already
      anyway.

    - util.h: all the error()/warn()/message()/run_time()/pinpoint()
      functions are gone. Use the bro_logger instead now.

    - Script errors are formatted a bit differently due to the
      changes. What I've seen so far looks ok to me, but let me know
      if there's something odd.

Notes:

    - The default handlers for the new log_* events are just dummy
      implementations for now since we need to integrate all this into
      the new scripts anyway.

    - I'm not too happy with the names of the Logger class and its
      instance bro_logger. We now have a LogMgr as well, which makes
      this all a bit confusing. But I didn't have a good idea for
      better names so I stuck with them for now.

      Perhaps we should merge Logger and LogMgr?
2011-06-25 16:40:54 -07:00
Seth Hall
cb3d312d5a Intel framework test passes now. 2011-06-24 16:10:13 -04:00
Seth Hall
0b918eb140 Reorganized some of the tests for consistency. 2011-06-24 15:40:56 -04:00
Jon Siwek
4f33dcf59e Updating software version parsing test.
Tweaked parsing code a bit catch a couple that were failing.
2011-06-24 13:27:35 -05:00
Jon Siwek
ecaae75e65 Reorganize where HTTP pipelining test lives. 2011-06-24 11:25:16 -05:00
Jon Siwek
b7b3e9c5a2 Tweak known-hosts test to explicitly do local asset tracking 2011-06-24 11:22:18 -05:00
Jon Siwek
e180761eb4 Update/improve known-services test. 2011-06-24 11:18:25 -05:00
Jon Siwek
555e42fdd2 First attempt to adapt istate.events unit test to new policy scripts.
The http.log that both sides produce is the same, but the
http-related events that each serializes into events.bst
don't look equivalent when read back and cause the test to fail.
2011-06-23 11:00:03 -05:00
Jon Siwek
dc4dc7c56a Update/improve known-hosts unit test. 2011-06-22 16:50:42 -05:00
Jon Siwek
ea1f819b3e Update core.vlan-mpls test to use new policy scripts. 2011-06-20 16:06:44 -05:00
Jon Siwek
fc66d88a04 Updating the packet filter tests to use new policy scripts. 2011-06-20 15:56:16 -05:00
Jon Siwek
ef79ab3562 Update baseline for core.load-pkg test
I removed the diff'ing against which scripts Bro outputs as loaded
because that's going to be sensitive to changes in which scripts
get loaded by default.  What really matters is the output that shows
that Bro was able to load the script via a directory's __load__.bro
2011-06-20 14:10:02 -05:00
Jon Siwek
2bb36a7d10 Fix language.rare-events test to use new policy scripts.
DroppedPackets now goes in notice.log by default so that log is the
new baseline.
2011-06-20 13:55:44 -05:00
Jon Siwek
c1638d7172 Fix logging remote tests to use new policy script organization. 2011-06-20 13:49:30 -05:00
Jon Siwek
83ffca5a4a Fix logging rotation tests.
By filtering the rotation output from Bro to weed out log streams
that the unit test didn't create (default logging streams).
2011-06-20 13:37:04 -05:00
Jon Siwek
3f436cf419 Merge branch 'master' into topic/jsiwek/pybroccoli-fixes 2011-06-20 12:18:20 -05:00
Jon Siwek
9de6e9170c Cleaning up the script loading implementation.
This change primarily improves the way Bro detects and prevents
the same script from being loaded twice.  It now compares inode
numbers instead of path names.
2011-06-20 12:10:09 -05:00
Jon Siwek
0f6a6ddc28 Fix baseline for core.conn-id (now core.conn-uid) test.
"conn-id.bro" was the name of a script in the policy/ directory that conn.bro
expected to @load, but when the unit test was also named "conn-id.bro",
it would be loaded twice during the test (once from conn.bro and once
as a command line argument to bro).  This means two event handlers were
registered in error and the baseline output contained duplicate lines
that can be removed.
2011-06-20 10:11:44 -05:00
Seth Hall
f30a8a3e21 Merge remote branch 'origin/master' into topic/policy-scripts-new 2011-06-16 22:02:09 -04:00
Seth Hall
32425ba4b0 Merge branch 'topic/policy-scripts-new' of ssh://git.bro-ids.org/bro into topic/policy-scripts-new 2011-06-16 22:01:57 -04:00
Robin Sommer
ff7b92ffc8 Fixing bug with logging &optional records.
Closes #476.
2011-06-16 17:24:15 -07:00
Jon Siwek
7b7b15a18c Update istate.pybroccoli test.
For changes made to broccoli-python repository in
commit dbc73389e3a8c17734815993626d83084eb93615
2011-06-16 16:35:10 -05:00
Jon Siwek
4f15628146 Fix logging.ascii-empty & logging.ascii-options test failures.
Logging to stdout for use in a baseline doesn't work well when
there may be scripts that get loaded by default (in this case,
packet-filter) and also do logging.  Instead just baseline against
the logs generated by the test in question.
2011-06-16 15:23:47 -05:00
Seth Hall
8b9c1f1dcd Merge remote branch 'origin/topic/jsiwek/pybroccoli-fixes' into topic/policy-scripts-new 2011-06-16 16:04:00 -04:00
Jon Siwek
626c028f4f Merge branch 'master' into topic/policy-scripts-new 2011-06-16 13:29:58 -05:00
Jon Siwek
55c7c42eb7 Fix istate.events-ssl test failing because of expired cert.
Replaced expired certificate w/ one that's valid for ~100 years.
2011-06-15 16:34:33 -05:00
Jon Siwek
303dba6372 Coerce event handler record arguments to correct record type.
This lets events be sent to bro that contain record arguments that
don't have to fill in all &optional record fields.

This corresponds to broccoli-python tests that were updated in
commit 8b87d8f61ef89162019cd4acc01be93700b0c588
2011-06-15 13:56:37 -05:00
Jon Siwek
4f6690776c Update pybroccoli test.
This corresponds to changes in the broccoli-python repository's
commit 5b843ecc02a5d04b281409a05cee3a947665cfd2
2011-06-15 12:41:48 -05:00
Jon Siwek
b7e5d4169e Fix (py)broccoli unit tests being skipped on Mac. 2011-06-15 12:33:35 -05:00
Seth Hall
a8893052ac Added some HTTP tests.
- Tests HTTP pipelining, MD5 summing and general HTTP handling.
- I checked over the baseline closely and it appears correct.
2011-06-15 13:29:04 -04:00
Seth Hall
844afba017 Added Apple Mail to the software parsing tests. 2011-06-14 13:40:29 -04:00
Seth Hall
00f4751ada Merge remote branch 'origin/master' into topic/policy-scripts-new 2011-06-14 13:02:19 -04:00
Seth Hall
c6bf94f276 First commit of intelligence framework.
- Data insertion and querying works.
- A few tests are implemented to show usage scenarios.
2011-06-10 16:52:46 -04:00
Jon Siwek
b4d70a22db Fixed core.load-pkg test w/ diff canonifier instead 2011-06-10 15:07:32 -05:00
Jon Siwek
9e747a040d Revert "Fix core.load-pkg unit test."
This reverts commit 80558a994a.
2011-06-10 15:01:35 -05:00
Jon Siwek
cb89440593 Fix language.wrong-delete-field test by running through abs path canonifier 2011-06-10 14:56:49 -05:00
Jon Siwek
90196b4dc8 Fix bifs.unique_id-rnd test failing because of wc output formatting 2011-06-10 13:27:08 -05:00
Jon Siwek
13c90fc732 Fix core.conn-id test on some platforms.
The output of some versions of `wc` (e.g. MacOS) seems to indent
their output while others don't, causing the baseline diff to fail.
So pipe to sed to get rid of spaces before diffing.
2011-06-10 12:17:10 -05:00
Jon Siwek
80558a994a Fix core.load-pkg unit test.
Removed the test's diff against baseline output that contained absolute
paths so that it will work across systems.  Also don't redirect anything
to stderr so that failure information shows up in btest diagnostic output.
2011-06-10 11:53:51 -05:00
Seth Hall
57531e0769 Merge remote branch 'origin/master' into topic/policy-scripts-new
Conflicts:
	policy/bro.init
	policy/ssl.bro
2011-06-07 23:26:03 -04:00
Robin Sommer
8266709e20 A new bif unique_id(prefix) that returns a string that's unique across
Bro instaces with high probablity.

"prefix" is a string that will be prepended to the returned ID.
2011-06-07 17:57:22 -07:00
Seth Hall
fbf207deda Merge remote branch 'origin/master' into topic/policy-scripts-new 2011-06-03 07:38:28 -04:00
Robin Sommer
a236dd0d3d Fixing typo in test. 2011-06-02 22:07:36 -07:00
Robin Sommer
fac328685b @load now supports loading a directory.
With a directory "foo" somewhere in BROPATH, "@load foo" now checks if
there's a file "foo/__load__.bro". If so, it reads that file in. (If
not, Bro reports the same error as before, complaining that it can't
read a directory).
2011-06-02 21:57:24 -07:00
Robin Sommer
5c0704eec8 ASCII logger now escapes non-printable characters.
Closes #450.
2011-06-01 22:33:44 -07:00
Jon Siwek
f0143c3c5f Merge branch 'master' into topic/policy-scripts-new 2011-05-18 11:44:45 -05:00
Jon Siwek
73a18714b3 Fix reST markup generated for record redefs.
They should have been using reST roles to xref the original record type
instead of a reST directive to declare a new type.
2011-05-17 15:27:45 -05:00
Jon Siwek
d69c3edf21 Fixes for more doc mode corner cases caused by type cloning.
"shallow" copying has to be done for any type that can contain
record types in order to accommodate record redefs that add fields.
2011-05-17 15:03:40 -05:00
Jon Siwek
e608aae0ba Merge remote-tracking branch 'origin/master' into topic/policy-scripts-new 2011-05-16 13:59:02 -05:00