Commit graph

6667 commits

Author SHA1 Message Date
Robin Sommer
7a95f5322c Moving src/protocols to src/analyzer/protocols.
This is for consistency with where readers/writers are located: inside
the subdirectories of the corresponding code.
2013-04-16 14:29:11 -07:00
Robin Sommer
e6eddbd918 Missing dependency. 2013-04-16 14:28:23 -07:00
Robin Sommer
aeddca6523 More API documentation. 2013-04-16 14:28:23 -07:00
Bernhard Amann
70c020e412 well, with this commit synchronizing the data structure should work..
...if we had consistent hashing.
2013-04-16 05:16:32 -07:00
Jon Siwek
037d582b0e FileAnalysis: add custom libmagic database.
- It's derived from the magic database of libmagic 5.14, but with most
  everything not related to mime types removed.

- The custom database is always used by default for mime detection, but
  the more verbose file type detection will fall back on the default
  libmagic installation's database.  The result is: mime type strings
  are now guaranteed to be consistent across platforms, but the verbose
  file type descriptions are not.

- The custom database gets installed in $prefix/share/bro/magic, and
  should even be extensible if files with new patterns are added inside
  the directory.

- The search path for the mime magic database can be controlled via
  BROMAGIC environment variable.

- Remove mime_desc field from ftp.log.

- Stop using the mime/file type canonifier with unit tests.

- libmagic >= 5.04 is now a requirement.
2013-04-12 11:58:19 -05:00
Jon Siwek
b8c98b8bf7 FileAnalysis: change terminology s/action/analyzer 2013-04-11 14:53:54 -05:00
Jon Siwek
e81f2ae7b0 FileAnalysis: libmagic tweaks.
Remove verbose file type detection and automatically strip out charset
from mime type.
2013-04-11 13:11:46 -05:00
Jon Siwek
2fba37e277 FileAnalysis: add bif for setting timeout interval 2013-04-11 12:08:46 -05:00
Jon Siwek
e2fbee9054 FileAnalysis: add more params to some events. 2013-04-11 11:24:18 -05:00
Seth Hall
e0df278de6 Merge remote-tracking branch 'origin/topic/jsiwek/faf-experimental' into topic/seth/file-analysis-exe-analyzer
Conflicts:
	src/file_analysis.bif
2013-04-10 22:59:11 -04:00
Seth Hall
8beb75d985 Checkpoint. 2013-04-10 22:57:54 -04:00
Jon Siwek
2747e839fb FileAnalysis: insert explicit event queue flush points.
And added an event called "event_queue_flush_point" to mark where that
occured in the event stream.  The FAF now uses an explicit event queue
flush instead of buffering input in order to wait for a file handle to
be returned from script-layer.
2013-04-10 16:48:10 -05:00
Bernhard Amann
5291bb29f2 and also serialize the other things we need 2013-04-10 16:05:24 -04:00
Jon Siwek
d9321e2203 FileAnalysis: remove some file events.
The file_new event now takes over the function of file_type, file_bof,
and file_bof_buffer.
2013-04-10 14:34:23 -05:00
Bernhard Amann
240d667e30 ok, this bug was hard to find.
hyperloglog.h was missing guards and randomly deleting memory at
addresses equal to variable contents.

I am not entirely sure why that did not crash before...
2013-04-10 13:45:21 -04:00
Bernhard Amann
a37ffab0ea serialization compiles.
Not entirely sure if it works too...
2013-04-10 13:15:31 -04:00
Jon Siwek
a2d9b47bcd FileAnalysis: finish switching hooks to events. 2013-04-10 11:13:43 -05:00
Robin Sommer
eb94c6becd Fixing ref counting bug. 2013-04-09 17:38:01 -07:00
Robin Sommer
2002787c6e A set of interface changes in preparation for merging into BinPAC++
branch.
2013-04-09 17:16:27 -07:00
Robin Sommer
52cd02173d Removing event groups. 2013-04-09 16:49:47 -07:00
Jon Siwek
641154f8e8 FileAnalysis: checkpoint in middle of big reorganization.
- FileAnalysis::Info is now just a record used for logging, the fa_file
  record type is defined in init-bare.bro as the analogue to a
  connection record.

- Starting to transfer policy hook triggers and analyzer results to
  events.
2013-04-09 15:49:58 -05:00
Bernhard Amann
53d6f3aae7 rework cardinality interface to use opaque.
I like it better...
2013-04-07 23:05:14 +02:00
Bernhard Amann
c08d285497 Merge remote-tracking branch 'origin/topic/robin/thread-cleanup' into topic/bernhard/thread-cleanup 2013-04-07 20:45:05 +02:00
Bernhard Amann
2cc1f82425 Merge remote-tracking branch 'origin/master' into topic/bernhard/thread-cleanup 2013-04-07 20:43:47 +02:00
Robin Sommer
1a30a57816 Porting syslog analyzer as another example.
The diff to this commit shows what "porting" involves ...

This also adds a small test for syslog.
2013-04-05 13:13:30 -07:00
Robin Sommer
d5865c67cb Removing some debugging output. 2013-04-05 12:40:09 -07:00
Robin Sommer
2bbce6b15f Documenting Analyzer API, plus some cleanup. 2013-04-04 18:38:12 -07:00
Robin Sommer
897be0e147 Giving analyzer/ its own CMakeLists.txt.
Also moving src/analyzer.bif to src/analyzer/analyzer.bif, along with
the infrastructure to build/incude bif code at other locations.

We should generally move to having per-directory CMakeLists.txt. I'll
convert the others over later.
2013-04-04 16:53:21 -07:00
Robin Sommer
bccaea6883 Adding options Analyzer::disable_all to disable all analyzers at
startup.

One can then selectively enable the ones one wants inside a bro_init()
handler.
2013-04-04 15:24:15 -07:00
Robin Sommer
b122b39874 Removing all Analyzer::Available() methods. 2013-04-04 15:15:33 -07:00
Robin Sommer
40ca718e90 Removing the --use-binpac switch. 2013-04-03 13:40:49 -07:00
Robin Sommer
bfda42b9e9 Removing legacy binpac analyzer for DNS and HTTP. 2013-04-03 13:40:45 -07:00
Seth Hall
42a05e9570 Merge remote-tracking branch 'origin/topic/jsiwek/file-analysis' into topic/seth/file-analysis-exe-analyzer 2013-04-03 14:05:13 -04:00
Seth Hall
a624dd61c0 Merge remote-tracking branch 'origin/topic/jsiwek/file-analysis' into topic/seth/file-analysis-exe-analyzer
Conflicts:
	src/file_analysis/ActionSet.cc
2013-04-03 10:56:38 -04:00
Jon Siwek
393d35dc60 Revert "FileAnalysis: optimize get_file_handle event queueing."
This reverts commit fc267d010d.

There were some diffs caused by this in external test suites I'm
unsure about, I'm going to go over optimizations more closely in
a different branch.
2013-04-03 09:49:39 -05:00
Seth Hall
d19b8b0266 Checkpoint for discussion. 2013-04-03 00:51:33 -04:00
Jon Siwek
fc267d010d FileAnalysis: optimize get_file_handle event queueing.
When a file handle is needed and the last event in the queue is also
a get_file_handle event with the same arguments, instead of queueing
a new event, just remember to cache/re-use the resulting handle from
the previous event.  This depends on get_file_handle handlers not
changing global state that is also used to derive the file handle
string.
2013-04-02 16:21:51 -05:00
Jon Siwek
390358b70c FileAnalysis: Fix compile error. 2013-04-02 09:54:06 -05:00
Bernhard Amann
fd51db1c89 purely aesthetical - make whitespacing fit bro coding style.
Second step will be to change the bifs a bit...
2013-04-02 11:24:03 +02:00
Bernhard Amann
b5cdf13469 and re-add a function that I apparently deleted accidentally 2013-04-02 00:35:37 +02:00
Robin Sommer
e0c4bd1a82 Lots of cleanup and API documentation for the analyzer/* classes.
I've used the opportunity to also cleanup DPD's expect_connection()
infrastructure, and renamed that bif to schedule_analyzer(), which
seems more appropiate. One can now also schedule more than one
analyzer per connection.

TODOs:
        - "make install" is probably broken.
        - Broxygen is probably broken for plugin-defined events.
        - event groups are broken (do we want to keep them?)
        - parallel btest is broken, but I'm not sure why ...
          (tests all pass individually, but lots of error when running
          in parallel; must be related to *.bif restructuring).
        - Document API for src/plugin/*
        - Document API for src/analyzer/Analyzer.h
        - Document API for scripts/base/frameworks/analyzer
2013-04-01 13:12:21 -07:00
Seth Hall
cb040b6da4 Checkpoint 2013-04-01 09:00:07 -04:00
Robin Sommer
19c1816ebb Infrastructure for modularizing protocol analyzers.
There's now a new directory "src/protocols/", and the plan is for each
protocol analyzer to eventually have its own subdirectory in there
that contains everything it defines (C++/pac/bif). The infrastructure
to make that happen is in place, and two analyzers have been
converted to the new model, HTTP and SSL; there's no further
HTTP/SSL-specific code anywhere else in the core anymore (I believe :-)

Further changes:

    - -N lists available plugins, -NN lists more details on what these
      plugins provide (analyzers, bif elements). (The latter does not
      work for analyzers that haven't been converted yet).

    - *.bif.bro files now go into scripts/base/bif/; and
      scripts/base/bif/plugins/ for bif files provided by plugins.

    - I've factored out the bifcl/binpac CMake magic from
      src/CMakeLists.txt to cmake/{BifCl,Binpac}

    - There's a new cmake/BroPlugin that contains magic to allow
      plugins to have a simple CMakeLists.txt. The hope is that
      eventually the same CMakeLists.txt can be used for compiling a
      plugin either statically or dynamically.

    - bifcl has a new option -c that changes the code it generates so
      that it can be used with a plugin.

TODOs:
    - "make install" is probably broken.
    - Broxygen is probably broken for plugin-defined events.
    - event groups are broken (do we want to keep them?)
2013-03-29 19:59:31 -07:00
Jon Siwek
83f47d6f7a FileAnalysis: first pass over documentation. 2013-03-29 13:41:37 -05:00
Jon Siwek
3642ecc73e FileAnalysis: misc. tweaks/fixes.
- Add a timeout flag to file_analysis.log so it's easy to tell what
  has had at least one timeout trigger happen.

- Fix ftp-data service tag not being set for reused connections.

- Fix HTTP::Incorrect_File_Type because mime types returned by FAF have
  the charset still in them, but the HTTP::mime_types_extensions table
  does not and it requires an exact string match. (still ugly)

- Add TRIGGER_NEW_CONN to track files going over multiple connections.

- Add an initial file/mime type guess for non-linear file transfers.

- Fix a case where file/mime type detection would never be attempted
  if the start of the file was a content gap.

- Improve mime type tracking of HTTP byte-range/partial-content,
  even if the requests are pipelined or over multiple connections.

- I changed the modbus.events test because having the baseline output
  be 80+ MB is nuts and it was sensitive to connection record redefs.
2013-03-28 16:59:29 -05:00
Seth Hall
e0276384e7 Merge remote-tracking branch 'origin/topic/jsiwek/file-analysis' into topic/seth/file-analysis-exe-analyzer
Conflicts:
	src/CMakeLists.txt
	src/file_analysis.bif
	src/file_analysis/Info.cc
2013-03-28 00:21:01 -04:00
Jon Siwek
abaa5d3eaf FileAnalysis: fix memory leak when adding actions. 2013-03-27 16:31:25 -05:00
Jon Siwek
f5d8ed299d Fix memory leak in HashVal subclass ctors.
The instantiation of OpaqueType here is ref'd by the Val ctor, which
has a corresponding deref in the Val dtor, but a deref is still needed
for the instantiation itself.
2013-03-27 16:22:23 -05:00
Jon Siwek
dce3e6448f FileAnalysis: fix a memory leak. 2013-03-27 14:50:15 -05:00
Jon Siwek
704c705e7b Merge branch 'master' into topic/jsiwek/file-analysis 2013-03-27 14:13:05 -05:00