Commit graph

6667 commits

Author SHA1 Message Date
Jon Siwek
92d2fdd4a6 Close signature files after done parsing. 2013-12-05 13:22:50 -06:00
Jon Siwek
d3e908af3b Fix unlikely null ptr deref in broxygen::Manager. 2013-12-05 12:56:05 -06:00
Bernhard Amann
504d22b91b fix memory leak in input framework.
If the input framework was used to read event streams and
those streams contained records with more than one field, not all
elements of the threading Values were cleaned up.

The reason for this is, that the SendEventStreamEvent function
returned the number of record elements in the outmost record
instead of the number of unrolled elements in the whole vector.

This number is later used to determine how many objects to delete.

Also - add a whole bunch of leak checks for the input framework
that would have caught that and should cover quite a number of
use-cases.
2013-12-05 10:53:12 -08:00
Jon Siwek
be05d7b435 FreeBSD build fix addendum: unintended variable shadowing. 2013-12-05 11:15:02 -06:00
Jon Siwek
21df25d429 Fix build on FreeBSD.
basename(3)/dirname(3) const-ness may vary w/ platform.
2013-12-05 11:01:44 -06:00
Robin Sommer
81096820f3 Merge remote-tracking branch 'origin/topic/jsiwek/string-slicing-fix'
* origin/topic/jsiwek/string-slicing-fix:
  Support omission of string slice low/high indices, BIT-1097.
2013-12-04 13:45:47 -08:00
Jon Siwek
8515d3aa57 Support omission of string slice low/high indices, BIT-1097.
Omission of the low index defaults to 0:

    s = "12345"; s[:3] == "123"

Omission of the high index defaults to length of the string:

    s = "12345"; s[3:] == "45"
2013-12-04 15:11:48 -06:00
Robin Sommer
dda5e43aa9 Merge branch 'topic/robin/string-slicing-fix' 2013-12-04 12:42:22 -08:00
Robin Sommer
320f2d5ab6 Merge remote-tracking branch 'origin/topic/bernhard/ssl_ciphers_vector'
BIT-1011 #merged

* origin/topic/bernhard/ssl_ciphers_vector:
  Change ciphers in changes ciphers from a set to a vector.
2013-12-04 12:17:22 -08:00
Robin Sommer
dadfcde70e Merge branch 'topic/robin/event-dumper'
Changes:

   - Changing semantics of the new_event() meta event: it's raised
     only for events that have a handler defined. There are too many
     checks in Bro that prevent events wo/ handler from being even
     prepared to raise to do that differently.

   - Adding test case.

* topic/robin/event-dumper:
  New script misc/dump-events.bro, along with core support, that dumps events Bro is raising in an easily readable form.
  Prettyfing Describe() for record types.
2013-12-04 12:13:07 -08:00
Bernhard Amann
b7dc03bb82 Change ciphers in changes ciphers from a set to a vector.
This preserves the ordering of the cipher suites the client sent,
allowing e.g. better client fingerprinting.
2013-12-04 11:38:15 -08:00
Robin Sommer
18a23fbdb8 Merge remote-tracking branch 'origin/topic/jsiwek/string-slicing-fix'
* origin/topic/jsiwek/string-slicing-fix:
  Fix string slice notation, addresses BIT-1097.
2013-12-04 11:23:26 -08:00
Robin Sommer
3abf626908 Merge remote-tracking branch 'origin/topic/jsiwek/broxygen'
BIT-1098

* origin/topic/jsiwek/broxygen:
  Fix Broxygen-related compile errors.
  Add a Broxygen coverage test.
  Internal Broxygen organization/documentation/polish.
  Add unit tests for Broxygen config file targets.
  Change Broxygen config file format.
  Broxygen doc-related test updates.  Fix two regressions.
  A couple documentation fixes.
  Integrate new Broxygen functionality into Sphinx.
  Implement majority of Broxygen features delegated to Bro.
  Broxygen can now read a config file specifying particular targets.
  Remove unneeded Broxygen comments in scan.bro.
  Replace safe_basename/safe_dirname w/ SafeBasename/SafeDirname.
  Add BIF interface for retrieving comments/docs.
  Quick optimization to Broxygen doc gathering.
  Flesh out Broxygen doc-gathering skeleton.
  Refactor search_for_file() util function.
  Initial skeleton of new Broxygen infrastructure.
2013-12-04 11:14:19 -08:00
Jon Siwek
4014cdc277 Fix string slice notation, addresses BIT-1097.
Slice ranges were not correctly determined for negative indices and also
off by one in general (included one more element at the end of the
substring than what actually matched the index range).

It's now equivalent to Python slice notation.  Accessing a string at
a single index is also the same as Python except that an out-of-range
index returns an empty string instead of throwing an expection.
2013-12-03 14:39:21 -06:00
Jon Siwek
5aa04089af Unit test for broccoli vector support.
Broccoli clients can only recv events w/ vectors for now.

Also changed ordering of Bro type tag enum -- the addition of opaque
types changed the value of the vector type, making broccoli.h's
definition out of sync.  Probably could have just changed broccoli's
definition, but seems more correct to go back to using the same value
for vectors as they were before opaques.  It's also better in case
there's some other location I'm not aware of where the values are
replicated.
2013-12-03 11:28:06 -06:00
Robin Sommer
bda0c29f66 Restructuring the plugin API to accomodate hooks.
I got rid of the earlier separate InterpreterPlugin class. Instead
Plugin now has a set of virtual methods HookSomething()... that
plugins can override. For efficiency purposes, they however need to
register first that they are interested in a hook, otherwise the
virtual method will never be called. The idea is to extend the set of
hooks over time as we figure out what's useful.

This is a checkpoint commit that's essentially untested and probably
broken. It compiles, though.
2013-11-26 14:04:29 -08:00
Robin Sommer
555df1e7ea Checkpointing the dynamic plugin code.
This is essentially the code from the dynamic-plugin branch except for
some pieces that I have split out into separate, earlier commits.

I'm going to updatre things in this branch going forward.
2013-11-26 14:04:29 -08:00
Robin Sommer
7412470d66 Prettyfing Describe() for record types.
If a record type has a name and ODesc is set to short, we now print
the name instead of the full field list.
2013-11-26 14:04:29 -08:00
Robin Sommer
d727af097b Minor API changes to analyzers. 2013-11-26 11:22:23 -08:00
Robin Sommer
d34f23c8d4 A set of file analysis extensions.
- Enable manager to associate analyzers with a MIME type. With that,
  one can now say enable all analyzers for, e.g., "image/gif". This is
  exposed to script-land as

    Files::add_analyzers_for_mime_type(f: fa_file, mtype: string)

  For MIME types identified via libmagic, this happens automatically
  (via the file_new() handler in files/main.bro).

- Extend the analyzer API to better match that of protocol analyzers:

    - Adding unique analyzer IDs so that we can refer to instances
      from script-land.

    - Adding subtypes to Components so that a single analyzer
      implementation can support different types of analyzers
      internally.

    - Add an analyzer method SetTag() that allows to set the tag after
      construction.

    - Adding Init() and Done() methods for consistency with what other
      classes offer.

- Add debug logging to the file_analysis stream.

TODO: test cases missing for the new script-land functionality.
2013-11-26 11:20:14 -08:00
Robin Sommer
f0fe270029 Minor interface changes to provide more accessor methods for class
information.

In particular, adding a few const versions of methods.
2013-11-26 10:57:02 -08:00
Jon Siwek
9163935aba Fix Broxygen-related compile errors. 2013-11-25 16:08:46 -06:00
Jon Siwek
e58865af22 Internal Broxygen organization/documentation/polish. 2013-11-25 14:36:05 -06:00
Daniel Thayer
5b6468a302 Add documentation for event parameters
Added documentation that was missing for some event parameters, and
fixed documented name of event parameters.
2013-11-22 16:36:08 -06:00
Robin Sommer
de9f03b0bf New script misc/dump-events.bro, along with core support, that dumps events Bro is raising
in an easily readable form.

This is for debugging purposes, obviously.

Example, including only SMTP events:

    > bro -r smtp.trace misc/dump-events.bro DumpEvents::include=/smtp/

    [...]
    1254722768.219663 smtp_reply
                  [0] c: connection   = [id=[orig_h=10.10.1.4, orig_p=1470/tcp, resp_h=74.53.140.153, [...]
                  [1] is_orig: bool   = F
                  [2] code: count     = 220
                  [3] cmd: string     = >
                  [4] msg: string     = xc90.websitewelcome.com ESMTP Exim 4.69 #1 Mon, 05 Oct 2009 01:05:54 -0500
                  [5] cont_resp: bool = T

    1254722768.219663 smtp_reply
                  [0] c: connection   = [id=[orig_h=10.10.1.4, orig_p=1470/tcp, resp_h=74.53.140.153, [...]
                  [1] is_orig: bool   = F
                  [2] code: count     = 220
                  [3] cmd: string     = >
                  [4] msg: string     = We do not authorize the use of this system to transport unsolicited,
                  [5] cont_resp: bool = T
    [...]
2013-11-22 14:20:00 -08:00
Robin Sommer
08c7dd3d71 Prettyfing Describe() for record types.
If a record type has a name and ODesc is set to short, we now print
the name instead of the full field list.
2013-11-22 13:54:40 -08:00
Daniel Thayer
6f06705c23 Fix typos in BIF documentation
Fixed typos in documentation of hexstr_to_bytestring.
Also added documentation that was missing for function parameters
and return values of other BIFs.
2013-11-22 14:49:16 -06:00
Jon Siwek
e3f74dc319 Change Broxygen config file format.
"<type> <pattern> <output-file>" seems a more natural order for
specifying targets.
2013-11-22 14:37:07 -06:00
Jon Siwek
98dcfc64a8 Broxygen doc-related test updates. Fix two regressions.
- Fix automatic function parameter documentation formatting for
  record fields that are functions.

- Document redefs in a fixed order.
2013-11-22 14:18:24 -06:00
Jon Siwek
96ba5c82a3 Merge branch 'master' into topic/jsiwek/broxygen 2013-11-21 15:46:55 -06:00
Jon Siwek
9967aea52c Integrate new Broxygen functionality into Sphinx.
Add a "broxygen" domain Sphinx extension w/ directives to allow
on-the-fly documentation to be generated w/ Bro and included in files.

This means all autogenerated reST docs are now done by Bro.  The odd
CMake/Python glue scipts which used to generate some portions are now
gone.  Bro and the Sphinx extension handle checking for outdated docs
themselves.

Parallel builds of `make doc` target should now work (mostly because
I don't think there's any tasks that can be done in parallel anymore).

Overall, this seems to simplify things and make the Broxygen-generated
portions of the documentation visible/traceable from the main Sphinx
source tree.  The one odd thing still is that per-script documentation
is rsync'd in to a shadow copy of the Sphinx source tree within the
build dir.  This is less elegant than using the new broxygen extension
to make per-script docs, but rsync is faster and simpler.  Simpler as in
less code because it seems like, in the best case, I'd need to write a
custom Sphinx Builder to be able to get that to even work.
2013-11-21 14:34:32 -06:00
Vlad Grigorescu
9e0b0f9187 Basic RADIUS support - checkpoint 2013-11-19 20:20:36 -05:00
Jon Siwek
4f6d01000a Implement majority of Broxygen features delegated to Bro.
Still have to update the Sphinx integration.
2013-11-14 14:00:51 -06:00
Robin Sommer
3d1fd6ca5e Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Fix the irc_reply event for certain server message types.
2013-11-11 13:48:50 -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
Seth Hall
1e43dfc46a Fix the irc_reply event for certain server message types. 2013-11-08 16:49:03 -05:00
Jon Siwek
bdd359d58c Broxygen can now read a config file specifying particular targets.
Though nothing currently gets built as most dependency/outdated
checks and doc-generation methods are still skeleton code.
2013-11-05 16:40:24 -06:00
Jon Siwek
3046013d69 Replace safe_basename/safe_dirname w/ SafeBasename/SafeDirname.
So errors can be better handled.
2013-11-04 11:42:39 -06:00
Jon Siwek
b38efa58d0 Merge branch 'master' into topic/jsiwek/broxygen
Conflicts:
	testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
2013-10-30 16:20:48 -05:00
Jon Siwek
3a99aaaf0a Add BIF interface for retrieving comments/docs.
The new BIFs:
    - get_identifier_comments
    - get_script_comments
    - get_package_readme
    - get_record_field_comments
2013-10-30 16:07:57 -05:00
Jon Siwek
22d35d2c8c Fix thread processing/termination conditions.
A thread that is done/killed should signify that the thread manager has
some processing to do -- it needs to process any messages in its out
queue, join the thread, and delete it.  Otherwise the thread manager
may reach a state where it makes no progress in processing the last
remaining done/killed thread.
2013-10-29 14:40:07 -05:00
Robin Sommer
64812daa50 Next version of the threading queue deadlock fix.
We now just use the read/write counters, as suggested by Gilbert.
2013-10-26 19:15:43 -07:00
Robin Sommer
15e72d1422 Merge remote-tracking branch 'origin/topic/bernhard/alternative-deadlock-fix'
* origin/topic/bernhard/alternative-deadlock-fix:
  alternative deadlock issue fix.
2013-10-25 11:10:08 -07:00
Bernhard Amann
2ac0d77f06 alternative deadlock issue fix.
This fix also fixes the deadlock issue without putting any
new strain into the main packet processing path.

Instead of occasionally returning true in MaybeReady sometime,
we occasionally process threads if time_mgr time is not running.

If time_mgr time is running, we have heartbeat messages that will
trigger processing in any case -- processing always checks the
exact state of the Queues.

This fix probably also means that we can remove the communication
loads from all input framework tests and run them all simultaneously.
2013-10-24 23:39:16 -07:00
Robin Sommer
c980d1055e Fix for input readers occasionally dead-locking.
Bernhard and I tracked it down we believe: the thread queue could
deadlock in certain cases. As a fix we tuned the heuristic for telling
if a queue might have input to occasionaly err on the safe side by
flagging "yes", so that processing will proceed.

It's a bit unfortunate to apply this fix last minute before the
release as it could potentially impact performance if the heuristic
fails to often. We believe the chosen parmaterization should be fine ...
2013-10-24 18:21:24 -07:00
Robin Sommer
5c80fd169f Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  change temporary workaround to permanent fix.

Conflicts:
	src/input/readers/Ascii.cc
2013-10-24 16:33:11 -07:00
Bernhard Amann
9a58a28da0 change temporary workaround to permanent fix.
According to Howard Hinnant, in use cases like ours you
need to call file->sync() to synchronize the internal ifstream
buffer with the file.

See http://stackoverflow.com/questions/19558376/clang-3-3-xcode-libc-stdgetline-does-not-read-data-after-calling-ifstream
2013-10-24 15:46:16 -07:00
Robin Sommer
1f91b2936e Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  rework libc++ patch to use AvailabilityMacros.h instead of Availability.h

Conflicts:
	src/input/readers/Ascii.cc
2013-10-24 14:01:44 -07:00
Bernhard Amann
c640e29193 rework libc++ patch to use AvailabilityMacros.h instead of Availability.h
AvailabilityMacros.h was introduced in 10.2, Availability is only available in
10.5+ - this increases backwards compatibility.
2013-10-24 13:34:17 -07:00
Robin Sommer
26c01468f5 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  temporary osx mavericks libc++ issue workaround.
  Change test of identify_data BIF to ignore charset.
2013-10-24 13:07:49 -07:00