Commit graph

394 commits

Author SHA1 Message Date
Robin Sommer
e8339d5c63 Merge remote-tracking branch 'origin/topic/bernhard/file-analysis-x509'
* origin/topic/bernhard/file-analysis-x509:
  Forgot the preamble for the new leak test
  (hopefully) last change -> return real opaque vec instead of any_vec
  Fix dump-events - it cannot be used with ssl anymore, because openssl does not give the same string results in all versions.
  Finishing touches of the x509 file analyzer.
  Revert change to only log certificates once per hour.
  Change x509 log - now certificates are only logged once per hour.
  Fix circular reference problem and a few other small things.
  X509 file analyzer nearly done. Verification and most other policy scripts work fine now.
  Add verify functionality, including the ability to get the validated chain. This means that it is now possible to get information about the root-certificates that were used to secure a connection.
  Second try on the event interface.
  Backport crash fix that made it into master with the x509_extension backport from here.
  Make x509 certificates an opaque type
  rip out x509 code from ssl analyzer. Note that since at the moment the file analyzer does not yet re-populate the info record that means quite a lot of information is simply not available.
  parse out extension. One event for general extensions (just returns the openssl-parsed string-value), one event for basicconstraints (is a certificate a CA or not) and one event for subject-alternative-names (only DNS parts).
  Very basic file-analyzer for x509 certificates. Mostly ripped from the ssl-analyzer and the topic/bernhard/x509 branch.
2014-03-14 09:53:07 -07:00
Bernhard Amann
285de1390a Forgot the preamble for the new leak test 2014-03-13 16:20:49 -07:00
Bernhard Amann
3f52eeacda Fix dump-events - it cannot be used with ssl anymore, because openssl
does not give the same string results in all versions.

Add leak test for x509 verify and fix small leak (type).
2014-03-13 15:41:57 -07:00
Robin Sommer
126bd298fe Merge remote-tracking branch 'origin/topic/jsiwek/dns_fake'
* origin/topic/jsiwek/dns_fake:
  Teach async DNS lookup builtin-functions about BRO_DNS_FAKE.
2014-03-13 14:27:44 -07:00
Jon Siwek
066473b1f1 Improve analysis of TCP SYN/SYN-ACK reversal situations.
- Since it's just the handshake packets out of order, they're no
  longer treated as partial connections, which some protocol analyzers
  immediately refuse to look at.

- The TCP_Reassembler "is_orig" state failed to change, which led to
  protocol analyzers sometimes using the wrong value for that.

- Add a unit test which exercises the Connection::FlipRoles() code
  path (i.e. the SYN/SYN-ACK reversal situation).

Addresses BIT-1148.
2014-03-11 17:03:59 -05:00
Jon Siwek
da338c8ffe Teach async DNS lookup builtin-functions about BRO_DNS_FAKE.
And enable fake DNS mode for test suites.

Addresses BIT-1134.
2014-03-10 16:51:04 -05:00
Robin Sommer
02ab000b81 Merge remote-tracking branch 'origin/master' into topic/robin/http-connect
Conflicts:
	scripts/base/protocols/ssl/consts.bro
2014-03-02 13:55:13 -08:00
Robin Sommer
338d521003 Fixing removal of support analyzers, plus some tweaking and cleanup of
CONNECT code.

Removal of support analyzers was broken. The code now actually doesn't
delete them immediately anymore but instead just flags them as
disabled. They'll be destroyed with the parent analyzer later.

Also includes a new leak tests exercising the CONNECT code.

Lines starting # with '#' will be ignored, and an empty message aborts
the commit. # On branch topic/robin/http-connect # Changes to be
committed: # modified: scripts/base/protocols/http/main.bro #
modified: scripts/base/protocols/ssl/consts.bro # modified:
src/analyzer/Analyzer.cc # modified: src/analyzer/Analyzer.h #
modified: src/analyzer/protocol/http/HTTP.cc # new file:
testing/btest/core/leaks/http-connect.bro # modified:
testing/btest/scripts/base/protocols/http/http-connect.bro # #
Untracked files: # .tags # changes.txt # conn.log # debug.log # diff #
mpls-in-vlan.patch # newfile.pcap # packet_filter.log # reporter.log #
src/PktSrc.cc.orig # weird.log #
2014-03-02 13:52:32 -08:00
Bernhard Amann
80c319b522 adjust timings of a few leak tests.
Without the longer timeouts, these consistently fail for me
on caddy when doing "make test".
2014-02-26 14:47:40 -08:00
Jon Siwek
2636d3aee7 Add memory leak unit test for SNMP. 2014-02-18 15:58:53 -06:00
Robin Sommer
ba81aa4387 Support for MPLS over VLAN.
Patch by Chris Kanich.

BIT-1017 #merged
2014-02-14 12:07:24 -08:00
Robin Sommer
a57f0ef9a0 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Increase timeouts of some unit tests.
  Fix memory leak in modbus analyzer.
  add channel_id tls extension number.
2014-02-13 12:45:02 -08:00
Jon Siwek
e844727e73 Increase timeouts of some unit tests. 2014-02-12 17:03:51 -06:00
Robin Sommer
d81bfed45d Fixing memory leaks in input framework. 2014-02-06 17:58:56 -08:00
Robin Sommer
4621745906 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Also use exec-module test to check for leaks.
2014-01-30 16:02:22 -08:00
Bernhard Amann
62b3cb0a5b Also use exec-module test to check for leaks. 2014-01-28 12:28:12 -08:00
Robin Sommer
3f47c5bc87 Merge remote-tracking branch 'origin/master' into topic/robin/dynamic-plugins-2.3 2014-01-24 20:26:00 -08:00
Jon Siwek
9b12967d40 Improve gap reporting in TCP connections that never see data.
The previous behavior was to accomodate SYN/FIN/RST-filtered traces by
not reporting missing data (via the content_gap event) for such
connections.  The new behavior always reports gaps for connections that
are established and terminate normally, but sequence numbers indicate
that all data packets of the connection were missed.  The behavior can
be reverted by redef'ing "detect_filtered_trace".
2014-01-24 16:21:02 -06:00
Jon Siwek
5b3573394e Improve TCP FIN retransmission handling.
In the case multiple FIN packets are seen from a TCP endpoint (e.g.
when one is retransmitted), only the first counted towards a byte in the
sequence space.  This could cause a subsequent FIN packet to induce an
incorrect wrap around in the sequence numbers (e.g.  the retransmitted
FIN packet now is one sequence number behind the the first) and
misleadingly large connection sizes.  The change is to always treat a
FIN packet as counting one byte in to the sequence space.
2014-01-24 15:51:58 -06:00
Robin Sommer
fdd386a898 A test with a plugin exercising all hooks. 2014-01-22 14:35:31 -08:00
Robin Sommer
ea01a1be30 Reworking plugin interface to not rely on macros.
The Plugin.cc file is now just a standard class, with the interface
changed a bit to make it more easy to write. However, there're still
some conventions that one must follow to make everything work (like
using the right namespace structure).

This commit also includes the option to compile built-in plugins
dynamically instead of statically by adding
SET(BRO_PLUGIN_BUILD_DYNAMIC TRUE) to their CMake config. This hasn't
been tested much yet, and I'm still undecided if it's somethign we
would want to do by default--but we could now if wanted. :)

Also some minor other cleanup of plugin APIs and built infrastructure.

All tested on MacOS only currently.
2014-01-20 13:39:11 -08:00
Jon Siwek
7717a3eb67 BIT-867 - Support GRE tunnel decapsulation.
This includes enhanced GRE headers.  GRE tunnels are treated just like
IP-in-IP tunnels by parsing past the GRE header in between the delivery
and payload IP packets.
2014-01-16 16:03:04 -06:00
Robin Sommer
b91b62b2b1 Test updates. 2013-12-16 11:57:57 -08:00
Robin Sommer
a80dd10215 Updates of the dynamic plugin code.
Includes:

    - Cleanup of the plugin API, in particular generally changing
      const char* to std::string

    - Renaming environment variable BRO_PLUGINS to BRO_PLUGIN_PATH,
      defaulting to <prefix>/lib/bro/plugins

    - Reworking how dynamic plugins are searched and activated. See
      doc/devel/plugins.rst for details.

    - New @load-plugin directive to explicitly activate a plugin

    - Support for Darwin. (Linux untested right now)

    - The init-plugin updates come with support for "make test", "make
      sdist", and "make bdist" (see how-to).

    - Test updates.

Notes: The new hook mechanism, which allows plugins to hook into Bro's
core a well-defined points, is still essentially untested.
2013-12-16 11:57:56 -08:00
Jon Siwek
63c36d58f3 Another attempt to improve core.when-interpreter-exceptions unit test.
lookup_hostname("localhost") occassionally timed out (after allowed 10
secs) when running test suite on some systems.  Not sure why, but
changed to use the Exec module for when block conditions instead as the
scope of the test doesn't depend on a particular type of condition, it
just needs something that will work reliably/quickly.
2013-12-11 14:28:23 -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
2ea6011186 Improve a unit test involving 'when' conditionals.
May fix a sporadic failure, in which case it was just not getting enough
time to run or lookup_hostname() taking longer than ~3 seconds.  Else,
the new output should give more hints on what's going wrong.  In any
case, termination conditions for the test are now explicit.
2013-12-03 16:51:36 -06: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
Jon Siwek
1750e351c4 Prevent division/modulo by zero in scripts.
Integral/floating-point division/modulo by zero in C++ is undefined
behavior, so to prevent such cases in a script from crashing Bro,
they're now reported as an error (with script location information) and
the event handler in which it occurred returns immediately.
2013-09-20 16:36:00 -05:00
Jon Siwek
7799a86a7f Adjust HLL cluster leak test so leaks trigger a failure. 2013-09-04 16:53:58 -05:00
Jon Siwek
3939b629ae Adjust DNS memory leak test to actually fail if there's a leak. 2013-09-04 16:49:04 -05:00
Jon Siwek
62de5678f7 Fix memory leak in DNS TXT lookups. 2013-09-04 16:47:44 -05:00
Robin Sommer
295987c8d0 Making the confidence configurable. 2013-08-31 10:34:50 -07:00
Robin Sommer
4dcf8fc0db Merge remote-tracking branch 'origin/topic/bernhard/hyperloglog'
* origin/topic/bernhard/hyperloglog: (32 commits)
  add clustered leak test for hll. No issues.
  make gcc happy
  (hopefully) fix refcounting problem in hll/bloom-filter opaque vals. Thanks Robin.
  re-use same hash class for all add operations
  get hll ready for merging
  and forgot a file...
  adapt to new structure
  fix opaqueval-related memleak.
  make it compile on case-sensitive file systems and fix warnings
  make error rate configureable
  add persistence test not using predetermined random seeds.
  update cluster test to also use hll
  persistence really works.
  well, with this commit synchronizing the data structure should work.. ...if we had consistent hashing.
  and also serialize the other things we need
  ok, this bug was hard to find.
  serialization compiles.
  change plugin after feedback of seth
  Forgot a file. Again. Like always. Basically.
  do away with old file.
  ...
2013-08-30 11:30:05 -07:00
Bernhard Amann
2dd0d057e6 Merge remote-tracking branch 'origin/master' into topic/bernhard/hyperloglog
Conflicts:
	src/NetVar.cc
	src/NetVar.h
2013-08-30 08:43:47 -07:00
Jon Siwek
dc2e3d6e04 Fix global opaque val segfault, addresses BIT-1071
The opaque types need to be created before scripts are parsed.
2013-08-29 17:17:40 -05:00
Bernhard Amann
4cd20c6375 add clustered leak test for hll. No issues. 2013-08-29 14:01:22 -07:00
Jon Siwek
fb8b78840b Fix bloom filter memory leaks. 2013-08-29 11:24:24 -05:00
Jon Siwek
7a2972d0e4 Add bits_per_uid unit test, addressing BIT0-1016. 2013-08-28 16:12:11 -05:00
Jon Siwek
57b193593d Make mem leak tests able to time out.
This is a workaround for what seems to be a deadlock in gperftools
(seen in their 2.0 and 2.1 releases) that happens occasionally.
2013-08-15 14:27:02 -05:00
Jon Siwek
db7b6661fe Fix a unit test outdated by recent sumstats changes. 2013-08-09 09:50:05 -05:00
Robin Sommer
d349520745 Another test fix.
The classic "uniq -c" is not portable ...
2013-07-18 21:34:02 -07:00
Robin Sommer
006e370ee0 Canonyfying the output of core.print-bpf-filters.
I couldn't figure out why it's not stable but it doesn't seem to
matter for now unless more such situations show up.
2013-07-18 19:58:19 -07:00
Seth Hall
8322bbfd62 Small test fixes. 2013-07-09 23:28:09 -04:00
Robin Sommer
2ea1f483db Bringing back test for enable_auto_protocol_capture_filters (formerly
all_packets).
2013-07-08 13:06:03 -07:00
Seth Hall
5f8ee93ef0 Merge remote-tracking branch 'origin/master' into topic/seth/analyzer-framework
Conflicts:
	scripts/base/init-default.bro
	scripts/base/protocols/dns/main.bro
	scripts/base/protocols/ftp/main.bro
	scripts/base/protocols/http/main.bro
	scripts/base/protocols/irc/main.bro
	scripts/base/protocols/smtp/main.bro
	scripts/base/protocols/ssh/main.bro
	scripts/base/protocols/ssl/main.bro
	scripts/base/protocols/syslog/main.bro
	src/main.cc
	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
2013-07-04 23:07:52 -04:00
Robin Sommer
a5cb605b1d Fixing test that was accidentally broken. 2013-06-03 20:10:48 -07:00
Robin Sommer
4ccd6d76fd Fixing tests.
Part of this involves making the file-analysis tests independent of
specific hash values. I've done that only partially though.
2013-05-17 18:14:35 -07:00
Robin Sommer
eb637f9f3e Merge remote-tracking branch 'origin/master' into topic/robin/plugins
Thanks to git this merge was less troublesome that I was afraid it
would be. Not all tests pass yet though (and file hashes have changed
unfortunately).

Conflicts:
	cmake
	doc/scripts/DocSourcesList.cmake
	scripts/base/init-bare.bro
	scripts/base/protocols/ftp/main.bro
	scripts/base/protocols/irc/dcc-send.bro
	scripts/test-all-policy.bro
	src/AnalyzerTags.h
	src/CMakeLists.txt
	src/analyzer/Analyzer.cc
	src/analyzer/protocol/file/File.cc
	src/analyzer/protocol/file/File.h
	src/analyzer/protocol/http/HTTP.cc
	src/analyzer/protocol/http/HTTP.h
	src/analyzer/protocol/mime/MIME.cc
	src/event.bif
	src/main.cc
	src/util-config.h.in
	testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/istate.events-ssl/receiver.http.log
	testing/btest/Baseline/istate.events-ssl/sender.http.log
	testing/btest/Baseline/istate.events/receiver.http.log
	testing/btest/Baseline/istate.events/sender.http.log
2013-05-16 17:58:48 -07:00
Jon Siwek
ec50cad9db Merge branch 'master' into topic/jsiwek/file-analysis
Conflicts:
	scripts/base/protocols/ftp/main.bro
	src/OpaqueVal.h
	testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
2013-05-06 10:21:16 -05:00