Commit graph

111 commits

Author SHA1 Message Date
Daniel Thayer
18bd74454b Rename all scripts to have ".zeek" file extension 2019-04-11 21:12:40 -05:00
Jon Siwek
49a30d61cf Fix memory leak due to enum type/val circular references
Introduced in 2982765128
2019-01-29 18:28:13 -06:00
Jon Siwek
2982765128 Pre-allocate and re-use Vals for bool, int, count, enum and empty string 2019-01-09 18:29:23 -06:00
Jon Siwek
08c64112f0 Document variable argument list BIFs using ellipsis
Instead of a single parameter: "va_args: any".
2018-05-31 13:14:57 -05:00
Johanna Amann
bfe94641cf Fix another gcc7 warning.
Warning is:

/home/johanna/bro/master/src/Type.cc: In member function 'virtual bool IndexType::DoUnserialize(UnserialInfo*)':
/home/johanna/bro/master/src/Type.cc:548:60: warning: enum constant in boolean context [-Wint-in-bool-context]
  indices = (TypeList*) BroType::Unserialize(info, TYPE_LIST);
                                                            ^
/home/johanna/bro/master/src/Type.cc: In member function 'virtual bool FuncType::DoUnserialize(UnserialInfo*)':
/home/johanna/bro/master/src/Type.cc:868:61: warning: enum constant in boolean context [-Wint-in-bool-context]
  args = (RecordType*) BroType::Unserialize(info, TYPE_RECORD);
                                                             ^
/home/johanna/bro/master/src/Type.cc:872:62: warning: enum constant in boolean context [-Wint-in-bool-context]
  arg_types = (TypeList*) BroType::Unserialize(info, TYPE_LIST);

This one is a really nice catch in my opinion. GCC is completely correct
- the 2nd argument to Unserialize is a bool. This means that all these
calls always evaluate to Unserialize(info, true). Which is equivalent
with the default, so I just removed the type from the call.

This was probably caused by someone thinking of BroVal::Unserialize,
which needs the type as the 2nd argument.
2017-12-05 11:30:06 -08:00
Johanna Amann
e7611e8521 Fix memory leak in EnumType.
Introduced in ca3f7eadbe.

This took a while to find.
2016-08-10 18:12:26 -07:00
Robin Sommer
ca3f7eadbe Fix segfault when an existing enum identifier is added again with a
different value.

Addresses BIT-931.

Also switching the internal enum ID map to storing std::string for
easier memory management.
2016-07-05 17:54:10 -07:00
Robin Sommer
2233521de7 Merge remote-tracking branch 'origin/topic/johanna/netcontrol'
BIT-1550 #merged

* origin/topic/johanna/netcontrol: (72 commits)
  Update baselines and news
  Move prefixtable back to all IPv6 internal handling.
  NetControl: Add functions to search for rules affecting IPs/subnets
  Add check_subnet bif that allows exact membership test for subnet tables.
  Rewrite internal handling of rules.
  Add bif that allows searching for all matching subnets in table.
  Add signaling of succesful initialization of plugins to NetControl.
  Add rule hooks to the acld plugin.
  Add new logfiles for shunting and drops to netcontrol
  Extend NetControl logging and fix bugs.
  Update OpenFlow API and events.
  small acld plugin fix
  Revert "introduce &weaken attribute"
  Fix crash when printing type of recursive structures.
  Testcase for crash when a record contains a function referencing a record.
  Rename Pacf to NetControl
  fix acld plugin to use address instead of subnet (and add functions for conversion)
  implement quarantine
  miscelaneous missing bits and pieces
  Acld implementation for Pacf - Bro side.
  ...
2016-03-11 14:29:23 -08:00
Johanna Amann
c5a14d1bc1 Fix crash when printing type of recursive structures.
Also slightly fix indentation in Type.h
2016-02-03 13:22:05 -08:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Jon Siwek
48fccb3bce BIT-1350: improve record coercion type checking.
For a field of the same name in both the target type and the coerced
type, a type mismatch is now reported as an error at parse-time.
2015-04-27 16:37:40 -05:00
Jon Siwek
011e2cdd32 Improve use of &deprecated on functions.
- Don't report warnings on function definition if declaration is marked
  deprecated.
- Allow &deprecated to apply to a standalone function definition.
2015-01-21 12:27:09 -06:00
Jon Siwek
87962a48dd Add a new attribute: &deprecated.
While scripts are parsed, a warning is raised for each usage of an
identifier marked as &deprecated.  This also works for BIFs.

Addresses BIT-924, BIT-757.
2015-01-21 09:40:50 -06:00
Jon Siwek
3caecadf0a Fix Broxygen's rendering of opaque types.
BIT-1245 #close
2014-09-08 19:05:01 -05:00
Robin Sommer
8031da4ee7 More polishing of some of the branche's changes. 2014-08-08 18:32:05 -07:00
Robin Sommer
f4cbcb9b03 Converting log writers and input readers to plugins. 2014-07-20 19:17:58 +02:00
Robin Sommer
aeb8e71e8c Merge remote-tracking branch 'origin/master' into topic/robin/dynamic-plugins-2.3
Conflicts:
	aux/bro-aux
	aux/broccoli
2014-07-10 20:11:52 -07:00
Jon Siwek
3cea6ab1eb Include yield of vectors in Broxygen's type descriptions.
BIT-1217 #close
2014-07-10 19:23:49 -05:00
Jon Siwek
bfaa082aee Fix a reference counting bug in ListVal ctor. 2014-06-25 10:44:57 -05:00
Robin Sommer
d88b333353 A number of smaller API extensions to provide plugins with access to
information.
2014-05-29 18:15:14 -07:00
Robin Sommer
bbd409d274 Merge remote-tracking branch 'origin/master' into topic/robin/dynamic-plugins-2.3
(Never good to name a branch after version anticipated to include it ...)
2014-05-14 16:23:04 -07:00
Jon Siwek
8b7d5a68b2 Fix reference counting for lookup_ID() usages.
That function refs the ID before returning it, but callers were never
assuming responsibility for that reference.
2014-05-01 15:00:03 -05:00
Jon Siwek
70131b5c84 Refactor SerializationFormat::EndWrite and ChunkedIO::Chunk mem mgmt.
SerializationFormat::EndWrite now transfers ownership of the buffer
to the caller instead of doing a memcpy.

ChunkedIO::Chunk is no longer a POD type, hopefully the ctor/dtor
make it easier to manage its associated memory.  It also now
tracks how to deallocate its buffer (i.e. delete vs. free).
2014-03-18 14:42:38 -05:00
Robin Sommer
7774af7518 Merge remote-tracking branch 'origin/topic/bernhard/ticket-1144'
* origin/topic/bernhard/ticket-1144:
  Allow iterating over bif functions with result type vector of any.

BIT-1144 #merged
2014-03-03 16:35:00 -08:00
Bernhard Amann
b3bd509b3f Allow iterating over bif functions with result type vector of any.
This changes the internal type that is used to signal that a vector
is unspecified from any to void.

I tried to verify that the behavior of Bro is still the same. After
a lot of playing around, I think everything still should worl as before.

However, it might be good for someone to take a look at this.

addresses BIT-1144
2014-02-25 15:30:29 -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
dedc39d784 Minor Broxygen improvements, addresses BIT-1098.
- Internals: move type alias table to private static BroType member.

- Sphinx extension: now uses absolute path to bro binary.

- reST ouput formatting: remove "param" from function desriptions
  and change package overview docs so script link+summaries render
  consistently.
2013-12-06 09:35:35 -06: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
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
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
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
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
e58865af22 Internal Broxygen organization/documentation/polish. 2013-11-25 14:36:05 -06: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
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
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
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
Jon Siwek
68227f112d Merge branch 'master' into topic/jsiwek/broxygen 2013-10-03 13:06:23 -05:00
Jon Siwek
5a857a6dfc Initial skeleton of new Broxygen infrastructure.
Doesn't generate any docs, but it's hooked in to all places needed to
gather the necessary stuff w/ significantly less coupling than before.

The gathering now always occurs unconditionally to make documentation
available at runtime and a command line switch (-X) only toggles whether
to output docs to disk (reST format).

Should also improve the treatment of type name aliasing which wasn't a
big problem in practice before, but I think it's more correct now:
there's now a distinct BroType for each alias, but extensible types
(record/enum) will automatically update the types for aliases on redef.

Other misc refactoring of note:

    - Removed a redundant/unused way of declaring event types.

    - Changed type serialization format/process to preserve type name
      information and remove compatibility code (since broccoli will
      have be updated anyway).
2013-10-03 10:42:04 -05:00
Jon Siwek
775ec6795e Fix uninitialized (or unused) fields. 2013-09-27 10:13:52 -05:00
Jon Siwek
daf5d0d098 Improve return value checking and error handling. 2013-09-24 17:38:22 -05:00
Jon Siwek
19b15217f0 Minor refactor to broxygen enum comments.
Coverity claimed a mismatched iterator here.  Don't think it was, but
this might make it either go away or make its insane template output
understandable.  Else at least it makes the code more readable.
2013-09-16 15:40:44 -05:00
Jon Siwek
f823b92e5e Fix mem leak when merging incompatible types.
Though this would typically be caused by a scripting error that should
be fixed and Bro would exit anyway if encountered at parse time.
2013-09-05 15:47:57 -05:00
Robin Sommer
474107fe40 Broifying the code.
Also extending API documentation a bit more and fixing a memory leak.
2013-07-23 20:10:32 -07:00
Matthias Vallentin
69a7dd03bc Merge remote-tracking branch 'origin/master' into topic/matthias/bloom-filter 2013-07-22 22:26:15 +02:00
Matthias Vallentin
5f70452a9a Small fixes and style tweaks. 2013-06-18 10:40:00 -07:00
Jon Siwek
e56a17102e Teach broxygen to generate protocol analyzer plugin reference. 2013-06-07 13:21:18 -05:00
Jon Siwek
e2a1d4a233 Allow default function/hook/event parameters. Addresses #972.
And changed the endianness parameter of bytestring_to_count() BIF to
default to false (big endian), mostly just to prove that the BIF parser
doesn't choke on default parameters.
2013-05-07 14:32:22 -05:00
Jon Siwek
2293443ea0 Fix function type-equivalence requiring same param names, addresses #957 2013-03-07 13:02:33 -06:00
Jon Siwek
d158c7ffdf Fix memory leaks resulting from 'when' and 'return when' statements.
Addresses #946.
2013-02-19 16:19:16 -06:00