Commit graph

197 commits

Author SHA1 Message Date
Robin Sommer
8bacb6eb3d New BiF record_field_vals() that returns the fields of a record in a
table with meta-information.

Example:

type r: record {
	a: count;
	b: string &default="Foo";
	c: double &optional;
	d: string &log;
};

event bro_init()
{
    local x: r = [$a=42, $d="Bar"];
    print record_fields(x);
}

This prints:

  {
  [a] = [type_name=record, log=F, value=42, default_val=<uninitialized>]
  [b] = [type_name=record, log=F, value=<uninitialized>, default_val=Foo],
  [c] = [type_name=record, log=F, value=<uninitialized>, default_val=<uninitialized>],
  [d] = [type_name=record, log=T, value=Bar, default_val=<uninitialized>],
  }

This is one more step in Seth's quest for full inspection support. :-)
2011-07-07 19:56:48 -07:00
Robin Sommer
084c2086a4 Fixing bug causing crash when running without arguments. 2011-07-07 19:56:48 -07:00
Robin Sommer
97b5f812c7 A new event bro_script_loaded() raised for each policy script loaded.
Also removing the -l command-line option as that can now be done at
the script-level.

A couple tests fail now that use -l. Leaving that until we have
script-level replacement.
2011-07-07 19:56:26 -07:00
Robin Sommer
df1b2f922b Renaming reporter_message to report_info.
Same change internally.
2011-07-07 19:56:25 -07: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
c738701ffd Cleaning up some testing stuff.
- The Makefiles now run btest with "-f diag.log" so that diangnostics
  output will always be written into that file.

- Makefiles now hardcode path to btest to avoid picking up the wrong version
  if in PATH.

- The canonifier scripts now live in testing/scripts, and they are
  used from both btest/ and external/.

- There's a new diff-remove-uids scripts that removed connection UIDs
  for diffing. The external/* tests now use that by default.

- Timestamp removal now has its own script: diff-remove-timestamps.
  diff-canonifier calls that.

- All Makefile have a "brief" target that runs btest with -b.

- The higher-level directories have Makefile to call the subdirs.
2011-07-05 18:47:08 -07:00
Robin Sommer
073358c488 Updating tests. 2011-07-01 18:57:03 -07:00
Robin Sommer
8432258db0 Merge remote branch 'origin/topic/jsiwek/pybroccoli-fixes'
* origin/topic/jsiwek/pybroccoli-fixes:
  Move event arg. record coercion check; now only done for recv'd remote events
  Update istate.pybroccoli test.
2011-07-01 18:56:27 -07:00
Robin Sommer
b520f98541 Updating test baselines. 2011-07-01 15:59:48 -07:00
Robin Sommer
bff8d39428 Fixing bug with even priorities potentially being ignored for the
handler.
2011-07-01 15:40:42 -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
Robin Sommer
64b60fd939 Updating README. 2011-07-01 10:08:58 -07:00
Robin Sommer
fb6a8cec19 Avoiding infinite loops when an error message handlers triggers errors
itself.

If an error is triggered inside one of the reporter_* handlers, the
message about that will now fall back to stderr.
2011-07-01 10:04:27 -07:00
Robin Sommer
66e2c3b623 Renaming the Logger to Reporter.
Also changing output to not include timestamps when we haven't started
processing packets yet.
2011-07-01 09:22:33 -07:00
Robin Sommer
4577787d9c Test for the HTTP problem in #488.
The test is currently failing until fixed.
2011-06-30 22:54:25 -07:00
Robin Sommer
a34e5e0973 Test for problem in DNS scripts.
It's currently failing.
2011-06-30 22:54:25 -07:00
Robin Sommer
80fcabdb47 Polishing the setup for external tests. 2011-06-30 22:54:25 -07:00
Robin Sommer
b57624aabf Adding new policy file test-all.bro that loads all other policies.
This is for testing only. There are also two test: one that checks
that test-all.bro loads correctly, and one that ensures that test-all
is actually loading all scripts found in policy/*.
2011-06-30 17:47:23 -07:00
Robin Sommer
e24d5d548c Checkpoint. 2011-06-30 16:56:02 -07:00
Robin Sommer
6f44fffcea Starting a small framework for doing regression testing with larger
traces and more complex Bro configurations.

That's "Type 2" in the terminology of
http://www-new.bro-ids.org/devel/projects/testing.html

This leverages btest as well and will replace the set of scripts that
the old private test-suite is using. It can accomodate tests with both
public and private traces.

This is a checkpoint commmit, not much there yet in terms of actual
testing. Also still need to figure out a mechanmism to allow for
different baselines based on which branch we're testing.
2011-06-30 16:55:45 -07:00
Jon Siwek
5a2cd265ab Update the generated script doc organization.
Added an additional master TOC index for Bro script packages that
automatically gets filled in at ``make doc`` time.  The master TOC
links to per-package indexes which contains links to all the scripts
contained within it along with their summary.  The per-package index
is also now automatically generated/derived from the path component
of the script passed into the rest_target() macro.
2011-06-30 16:58:20 -05:00
Jon Siwek
fe5f4b8e53 Changes to make generated script docs understand new policy/ hierarchy.
Added an arg to the search_for_files() util function that can return
the subpath of BROPATH's policy/ dir in which the loaded file is found.
This subpath is then used in both the the reST file's document title
(so that script's named e.g. "base.bro" actually have some context) and
in figuring out how to interlink with other generated docs of other
scripts that are found in @load directives.

I still need to overhaul things so the loading of "packages" is
documented in a meaningful way and that the CMake targets are able
to generate indexes for packages.
2011-06-30 11:37:15 -05:00
Jon Siwek
f307a3f408 Update core.vlan-mpls baseline.
conn UIDs changed because they're now also generated for notices.
2011-06-29 12:57:45 -05:00
Jon Siwek
3c055b16a5 Update core.conn-uid test/baseline.
All the UIDs in the baselines changed because they're now also
being generated for notices.
2011-06-29 12:49:07 -05:00
Jon Siwek
0d4be5d772 Fixing tests / updating baselines.
- core.load-unload: scripts that get loaded by default changed, so to
  make the test insensitive to that in the future, I changed the test
  to just check that the stdout is empty (the @unload'd script would have
  had output there)

- policy.frameworks.logging.rotate-custom: I saw that the ordering of
  the log postprocessor output caused a failure for me even though the
  overall content was the same, so it now sorts that part before diff'ing

- core.print-bpf-filters-ipv[4|6]: packet-filter log file name changed

- policy.protocols.conn.known-services: logging file names changes and
  local_nets is now in the Site module
2011-06-29 12:34:14 -05:00
Jon Siwek
1c30ce7e23 Merge branch 'master' into topic/jsiwek/pybroccoli-fixes 2011-06-27 16:00:50 -05:00
Seth Hall
c070cb31da Merge remote branch 'origin/master' into topic/policy-scripts-new
Conflicts:
	policy/bro.init
	testing/btest/language/rare-events.bro
2011-06-25 23:49:20 -04:00
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