Commit graph

203 commits

Author SHA1 Message Date
Bernhard Amann
e7f1200f9f Merge remote-tracking branch 'origin' into topic/bernhard/input-threads 2012-03-22 12:41:44 -07:00
Robin Sommer
d8d7dd4d53 Merge remote-tracking branch 'origin/topic/jsiwek/ipv6-literals'
* origin/topic/jsiwek/ipv6-literals:
  Change IPv6 literal constant syntax to require encasing square brackets
2012-03-13 15:33:43 -07:00
Robin Sommer
c78a391635 Merge remote-tracking branch 'origin/topic/jsiwek/remove-match'
* origin/topic/jsiwek/remove-match:
  Remove the match expression (addressed #753).
2012-03-13 14:55:40 -07:00
Jon Siwek
bf3f184a01 Change IPv6 literal constant syntax to require encasing square brackets
This is to avoid ambiguity between compressed hex notation and
module namespacing, both which use "::". E.g.: "aaaa::bbbb" could
be an identifier or an IPv6 address, but "[aaaa::bbbb]" is now
clearly the address.

Also added IPv6 mixed notation to allow an IPv4 dotted-decimal
address to be specified in the lower 32-bits.
2012-03-13 13:47:07 -05:00
Bernhard Amann
f6c6387c52 Merge branch 'topic/bernhard/input' into topic/bernhard/input-threads
most stuff is inplace, logging framework needs a few changes merged before continuing here...

Conflicts:
	src/CMakeLists.txt
	src/LogMgr.h
	src/logging/Manager.cc
	src/main.cc
2012-02-06 10:54:07 -08:00
Jon Siwek
713e3ac5d0 Add "# @no-test" tag to blacklist statements from test coverage analysis.
It can apply to either single statements:

    print "don't cover"; # @no-test

or a block of statements:

    if ( F )
        { # @no-test
        ...
        }
2012-01-13 14:52:58 -06:00
Bernhard Amann
59967d40ac Merge remote-tracking branch 'origin/master' into topic/bernhard/input
Conflicts:
	src/LogMgr.cc
	src/LogMgr.h
2011-12-19 12:36:53 -08:00
Jon Siwek
8394829fb1 Broxygen fix for function parameter recognition; better than 80b2451. 2011-12-16 11:59:55 -06:00
Jon Siwek
3b91df8cf5 Allow Broxygen markup "##<" for more general use. 2011-12-16 11:21:49 -06:00
Jon Siwek
80b24513e7 Fix Broxygen confusing scoped id at start of line as function parameter. 2011-12-07 17:08:38 -06:00
Bernhard Amann
78b24da7e4 start support for annotation for log field types.
commit before rolling part of it back...
2011-12-05 15:02:03 -08:00
Jon Siwek
cec4600d2e Fixing compiler warnings (addresses #388) 2011-11-01 14:44:38 -05:00
Robin Sommer
63b46a0ae2 Fixing a bunch of format strings.
Also leveraging GCC if available to check format specificier.

Closes #567.
2011-10-18 17:39:40 -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
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
Jon Siwek
1730496d12 Remove the 'net' type from Bro (addresses #535).
Incremented the serialization data format version in the process.
2011-08-17 19:03:34 -05:00
Jon Siwek
495e987938 Remove $Id$ tags 2011-08-04 15:21:18 -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
54c14025d9 Fix reST file name associated w/ stdin when in doc mode (closes #497) 2011-07-20 16:13:22 -05: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
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
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
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
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
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
73fa60f769 Resolving a conflict in scan.l.
Caused by changes made while working on the way loaded scripts are tracked
(commit 9de6e9170c to master branch) that
didn't take into account an unmerged commit on the policy-scripts-new branch
(56a946568a).

(re-added warning comments that were removed in the former commit since they
still seem relevant now)
2011-06-27 13:08:30 -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
ded395007f Merge remote branch 'origin/topic/jsiwek/script-load-cleanup'
* origin/topic/jsiwek/script-load-cleanup:
  Cleaning up the script loading implementation.
  Fix baseline for core.conn-id (now core.conn-uid) test.
2011-06-25 17:11:54 -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
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
Seth Hall
00f4751ada Merge remote branch 'origin/master' into topic/policy-scripts-new 2011-06-14 13:02:19 -04:00
Robin Sommer
5bd8caa7a0 Merge remote branch 'origin/topic/gregor/rpc'
Note, I haven't gone through the script-level code as that will change
soon anyway.
2011-06-13 17:56:28 -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
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
Jon Siwek
56a946568a More changes to how Bro generates docs for scripts in subdirs of BROPATH
The output reST filename now reflects the subdir information (by flattening
'/' path separators into the '^' character).  This is to prevent file name
conflicts when generated reST docs, but during the CMake 'doc' target to
build HTML docs, everything gets unflattened.
2011-05-16 20:17:58 -05:00
Jon Siwek
aec63df90f BroBifDoc was unneeded; now dead code, so removed. 2011-05-04 22:01:01 -05:00
Jon Siwek
d919ebed58 Bro's doc mode now terminates after processing bro_init but before net_run
Generated script reST documentation is also written out at this time
instead of at the end of lexical scanning.

The persistence serializer will no longer write out Bro's state to the
.state directory when in doc mode.
2011-05-04 21:33:21 -05:00
Robin Sommer
13a492091f Merge remote branch 'origin/topic/robin/logging-internals'
Includes some additional cleanup.
2011-04-20 21:30:41 -07:00
Robin Sommer
0590d899f6 Constness tweak. 2011-04-18 16:50:13 -07:00
Robin Sommer
e7bde27f2d Merge remote branch 'origin/topic/jsiwek/doc-framework' 2011-04-18 14:54:23 -07:00
Jon Siwek
bd523f2905 Automatic reST doc markup for event/function params/return comments
For a bro script that is documented like:

  ## ...
  ## bar: ...
  ## Returns: ...
  global foo(bar: string): string;

the generated reST documentation will automatically substitute meaningful
markup (reST field lists) for the parameter and return type comments
2011-04-04 12:29:48 -05:00
Robin Sommer
38a1aa5a34 &log keyword, and vector logging.
The &log keyword now operates as discussed:

    - When associated with individual record fields, it defines them
      as being logged.

    - When associated with a complete record type, it defines all fields
      to be logged.

    - When associated with a record extension, it defines all added
      fields to be logged.

    Note that for nested record types, the inner fields must likewise
    be declared with &log. Consequently, conn_id is now declared with
    &log in bro.init.

Vectors are now allowed to be logged and will be recorded as an
ordered set of items.
2011-03-28 18:14:05 -07:00
Jon Siwek
c2f0332b5f Removing lexical scanner recognition of "## Author:" comments.
This functionality is better done manually by the script writer
embedding reST into the script summary section (##! comments).
This allows flexibility in choosing between different methods
to convey the same information (e.g. ":Author: <author>" or
the ".. codeauthor:: <author>" directive that Sphinx
configurations can recognize).
2011-03-24 09:51:47 -05:00
Jon Siwek
037a6906af Canonicalize "##" and "## " stylized comments, revise record/enum documentation tracking
The documentation framework now sees "##Text" and "## Text" as
equivalent documentation comments.  This prevents unintentional
indentation in the generated reST as a result of the later style, but
still allows embedded reST markup that relies on indentation of more
than two spaces to work as expected.

Comments associated with record fields and enums values are able
to span multiple "##"-stylized comments, allowing for more robust
reST markup to be embedded.

The documentation framework now tracks record fields through
a new CommentedTypeDecl subclass of TypeDecl that the parser constructs
in parallel with the real TypeDecl.
2011-03-23 16:08:18 -05:00
Jon Siwek
e0a77cb794 Auto-doc framework now handles multiple script authors more conveniently. 2011-03-21 14:03:11 -05:00
Jon Siwek
5fbcde7344 Teach Desc class how to (optionally) use spaces for indentation.
And (to be consistent with current conventions for reST documentation)
update places in the auto-documentation-generation framework
where tabs were used in the generated reST.
2011-03-21 13:49:53 -05:00
Jon Siwek
c4ca6f098c Changes to scanner and parser to allow record field comments.
The scanner can now be told to start/stop producing new token types that
assist in documenting record field types (and eventually enums also).

TOK_DOC:
    Produced on "##" style comments; documents the field that follows.

TOK_POST_DOC:
    Produced on "##<" style comments; documents the previous field.
2011-03-14 13:10:49 -05:00
Jon Siwek
1bad6e3a95 Changes to auto-document dpd_config (port analysis) script settings. 2011-03-05 16:11:26 -06:00