Commit graph

308 commits

Author SHA1 Message Date
Robin Sommer
d9f90fcac0 Merge remote-tracking branch 'origin/topic/jsiwek/table-attribute-fixes'
* origin/topic/jsiwek/table-attribute-fixes:
  Fix various bugs with table/set attributes.

Closes #866.
2012-12-03 14:11:44 -08:00
Robin Sommer
d4792dc7fe Merge remote-tracking branch 'origin/topic/jsiwek/table-init-container-ctors'
* origin/topic/jsiwek/table-init-container-ctors:
  Add test of record() constructor to table initializer unit test.
  Fix table(), set(), vector() constructors in table initializer lists.

Closes #5.
2012-12-03 14:10:17 -08:00
Robin Sommer
1298f2e974 Merge remote-tracking branch 'origin/topic/jsiwek/hook'
* origin/topic/jsiwek/hook:
  Change hook calls to only be allowed when preceded by "hook" keyword.
  Clarification in hook documentation.
  Hook functions now directly callable instead of w/ "hook" statements.

Closes #918.
2012-12-03 14:07:22 -08:00
Jon Siwek
95ffb1cf27 Quick pass over unit tests, adding -b flag to bro so they run faster.
Doing this made bifs/ ~3x faster and language/ ~2x faster.
2012-11-30 17:44:36 -06:00
Jon Siwek
4e85fe0454 Change hook calls to only be allowed when preceded by "hook" keyword. 2012-11-30 15:39:00 -06:00
Jon Siwek
f7e07f5f09 Fix various bugs with table/set attributes.
- Identifiers that are initialized with set()/table() constructor
  expressions now inherit attributes from the expression.  Before,
  statements like

     const i: set[string] = set() &redef;

  associated the attribute with the set() constructor, but not the
  "i" identifier, preventing redefinition.  Addresses #866.

- Allow &default attribute to apply to tables initialized as empty
  (via either "{ }" or "table()") or if the expression supplied to it
  can evaluate to a type that's promotable to the same yield type as
  the table.
2012-11-29 15:44:03 -06:00
Jon Siwek
00f7bbda96 Add test of record() constructor to table initializer unit test. 2012-11-28 14:53:36 -06:00
Jon Siwek
a0590b2140 Fix table(), set(), vector() constructors in table initializer lists.
Also adds type checking of yield values to table() constructor and
fixes the type checking of yield values in vector() constructor.

Addresses #5.
2012-11-28 14:19:48 -06:00
Jon Siwek
378ee699ff Hook functions now directly callable instead of w/ "hook" statements.
The return value of the call is an implicit boolean value of T if all
hook handlers ran, or F if one hook handler exited as a result of a
break statement and potentially prevented other handlers from running.

Scripts don't need to declare hooks with an explicit return type of bool
(internally, that's assumed), and any values given to (optional) return
statements in handler definitions are just ignored.

Addresses #918.
2012-11-26 17:09:29 -06:00
Robin Sommer
d9bb9e0eb1 Merge remote-tracking branch 'origin/topic/jsiwek/hook'
* origin/topic/jsiwek/hook:
  Add memory leak unit test for "hook" function flavor.
  Add new function flavor called a "hook".
2012-11-23 18:39:51 -08:00
Jon Siwek
56e359ca9d Fix ambiguity between composite table index and record ctor expressions.
For tables of a composite index type with the first type being a
record, membership checks with an inline index key could be
misinterpreted as a record constructor instead of an expression list.
E.g, if the table type is "global t = table[conn_id, bool] of count",
then checking membership like "[c$id, is_orig] in t" now works.

Addresses #80.
2012-11-16 12:43:39 -06:00
Jon Siwek
e0fb9eb2b2 Add new function flavor called a "hook".
This new flavor of function behaves like a "synchronous event".
See documentation for more details on usage.
2012-11-15 13:45:13 -06:00
Jon Siwek
46d225cc5b Add parsing rules for IPv4/IPv6 subnet literal constants, addresses #888
This fixes specifying IPv4 subnets in IPv4-mapped-IPv6 format with a
mask length relative to the 128 bits of the mapped IPv6 address.
2012-10-22 15:57:21 -05:00
Daniel Thayer
f7e55509a4 Uncomment some previously-broken tests
Uncommented some tests that previously would cause Bro to exit
with an error.
2012-09-25 16:05:23 -05:00
Jon Siwek
1044762dfa Serialize language.when unit test with the "comm" group.
Since it now loads the listen script.
2012-09-25 14:53:51 -05:00
Daniel Thayer
101ba67203 Fix race condition in language/when.bro test 2012-09-24 18:20:42 -05:00
Daniel Thayer
84ec139fd9 Update language tests for recent bug fixes 2012-09-07 10:48:13 -05:00
Daniel Thayer
d5bf5eb38c Add more language tests 2012-09-04 17:39:00 -05:00
Daniel Thayer
76420e4b61 Add more language tests 2012-09-02 12:55:31 -05:00
Daniel Thayer
05ad3f95af Add more language tests
Added more tests and fixed a broken test.
2012-08-31 14:05:02 -05:00
Daniel Thayer
44c6ed5e8c Update language tests
Updated the int and count max/min constant value tests based on latest fixes
in master.
2012-08-29 17:53:37 -05:00
Daniel Thayer
621a90d248 Add more language tests
Added tests for the conditional operator, operator precedence,
modules ("module" and "export" keywords, and the "::" operator), and
for the "copy" keyword.

Also improved tests of max/min values of int, count, and double constants.
2012-08-29 17:14:03 -05:00
Daniel Thayer
90281a2423 Add tests of the Bro scripting language
Added tests of all built-in Bro data types (including different
representations of constant values, and max./min. values), keywords, and
operators (including special properties of certain operators, such as
short-circuit evaluation and associativity).
2012-08-24 11:32:49 -05:00
Jon Siwek
353393f9bd Fix segfault when incrementing whole vector values.
Also removed RefExpr::Eval(Val*) method since it was never called
(Clang emitted warning about this hiding overloaded virtual function
UnaryExpr::Eval(Frame*)) and doesn't appear to be necessary even if it
was called to avoid the default vector handling of UnaryExpr::Eval
(as the comment suggests as the intention).
2012-07-13 14:32:50 -05:00
Jon Siwek
fcd8f9b77e Fix table expiry for values assigned in bro_init() when reading live.
Value assigned in bro_init() to a table with &create_expire
weren't expiring when reading traffic from an interface.  It worked
when reading a pcap file, but I added a test case to show it still
working.
2012-04-06 13:24:27 -05:00
Jon Siwek
667487cec9 Adapt FreeBSD's inet_ntop implementation for internal use.
So we get consistent text representations of IPv6 addresses across
platforms.
2012-03-19 11:26:31 -05: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
Jon Siwek
2e2f8f5d06 Merge branch 'master' into topic/v6-addr
Conflicts:
	src/bro.bif
2012-02-06 11:06:55 -06:00
Jon Siwek
b3f1f45082 Remove --enable-brov6 flag, IPv6 now supported by default.
Internally, all BROv6 preprocessor switches were removed and
addr/subnet representations wrapped in the new IPAddr/IPPrefix classes.

Some script-layer changes of note:

- dns_AAAA_reply event signature changed: the string representation
  of an IPv6 addr is easily derived from the addr value, it doesn't
  need to be another parameter.  This event also now generated directly
  by the DNS analyzer instead of being "faked" into a dns_A_reply event.

- removed addr_to_count BIF.  It used to return the host-order
  count representation of IPv4 addresses only.  To make it more
  generic, we might later add a BIF to return a vector of counts
  in order to support IPv6.

- changed the result of enclosing addr variables in vertical pipes
  (e.g. |my_addr|) to return the bit-width of the address type which
  is 128 for IPv6 and 32 for IPv4.  It used to function the same
  way as addr_to_count mentioned above.

- remove bro_has_ipv6 BIF
2012-02-03 16:46:58 -06:00
Robin Sommer
7a8c9b1c69 Merge remote-tracking branch 'origin/topic/jsiwek/local-table-init'
* origin/topic/jsiwek/local-table-init:
  Allow local table variables to be initialized with {} list expressions.

Closes #739.
2012-01-25 13:47:42 -08:00
Jon Siwek
1e4c3d8ea2 Teach CompHash to allow indexing by records with vector/table/set fields.
Addresses #464.
2012-01-20 16:54:48 -06:00
Jon Siwek
aae60a6d76 Allow local table variables to be initialized with {} list expressions. 2012-01-04 16:44:25 -06:00
Jon Siwek
f302f2f3f2 Fix &default fields in records not being initialized in coerced assignments.
Addresses #722
2011-12-15 12:16:42 -06:00
Jon Siwek
eb3c5ee1a4 Fix indexing for record types with optional fields
Addresses #378
2011-09-09 13:06:45 -05:00
Robin Sommer
29e9183f5b Merge remote branch 'origin/topic/jsiwek/nested-record-coerce-fix'
* origin/topic/jsiwek/nested-record-coerce-fix:
  Fix for a case where nested records weren't coerced even though possible.

Closes #571.
2011-09-04 09:00:45 -07:00
Jon Siwek
2e853a3892 Change presentation of enum val to include namespace.
Enum vals now add their full identifier string, including module
namespace to ODescs.
2011-08-31 10:57:19 -05:00
Jon Siwek
f08ef8350a Fix for a case where nested records weren't coerced even though possible. 2011-08-26 13:59:51 -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
6f060a58d6 Fix vector initialization for lists of records with optional types.
If possible the list elements now get promoted to the yield type of the
vector.  There was also a problem with the value returned by the record
constructor expression's eval being completely unref'd since the vector
element assignment function doesn't ref the element -- so I changed it
to ref values if they just constructed before assigning them to the
vector.

Addresses #485.
2011-08-12 23:25:01 -07:00
Jon Siwek
560685f1c6 Fix redef'ing records with &default empty set fields.
Attributes have state to track whether they're in a record and should
apply to a record field, but this state wasn't being set for TypeDecls
that are part of a redef'd record.

Closes #460
2011-08-12 23:24:49 -07:00
Seth Hall
597a4d6704 Hopefully the last major script reorganization.
- policy/ renamed to scripts/

- By default BROPATH now contains:
	- scripts/
	- scripts/policy
	- scripts/site

- *Nearly* all tests pass.

- All of scripts/base/ is loaded by main.cc
	- Can be disabled by setting $BRO_NO_BASE_SCRIPTS
	- Scripts in scripts/base/ don't use relative path loading to ease use of BRO_NO_BASE_SCRIPTS (to copy and paste that script).

- The scripts in scripts/base/protocols/ only (or soon will only) do logging and state building.

- The scripts in scripts/base/frameworks/ add functionality without causing any additional overhead.

- All "detection" activity happens through scripts in scripts/policy/.

- Communications framework modified temporarily to need an environment variable to actually enable (ENABLE_COMMUNICATION=1)
	- This is so the communications framework can be loaded as part
	  of the base without causing trouble when it's not needed.
	- This will be removed once a resolution to ticket #540 is reached.
2011-08-05 23:09:53 -04:00
Robin Sommer
d8aece07d7 Merge remote-tracking branch 'origin/topic/jsiwek/raw_output'
* origin/topic/jsiwek/raw_output:
  Fix &raw_output and enable_raw_output interpretation of NUL characters
2011-08-03 16:27:52 -07:00
Jon Siwek
648e1bda26 Fix &raw_output and enable_raw_output interpretation of NUL characters
When using a `print` statement to write to a file that has raw output
enabled, NUL characters in string are no longer interpreted into "\0",
no newline is appended afterwards, and each argument to `print` is
written to the file without any additional separation.

(Re)Assigning to identifiers with the &raw_output attribute should also
now correctly apply the attribute to the file value being assigned.

Note that the write_file BiF should already be capable of raw string
data to a file, expect it bypasses the print_hook event.

Addresses #474
2011-08-03 10:51:40 -05:00
Robin Sommer
a7ced3228b Removing language.rare-events test which is no longer meaningful.
It relied on the now removed netstats_update event.
2011-06-25 18:10:40 -07:00
Jon Siwek
cb89440593 Fix language.wrong-delete-field test by running through abs path canonifier 2011-06-10 14:56:49 -05:00
Robin Sommer
63f7359e1e Bugfix: vectors in records were not initalized.
Closes #421.
2011-05-10 18:19:27 -07:00
Robin Sommer
03cd7a47ac Moving the test-scripts from the old test-suite over to btest. 2011-05-10 17:28:09 -07:00
Robin Sommer
c41da9ca99 Fixing bug with deleting still unset record fields of table type. 2011-04-23 10:40:07 -07:00