Commit graph

138 commits

Author SHA1 Message Date
Daniel Thayer
bd2d559fbf Fix race condition causing some tests to fail
Removed loading of the "frameworks/communication/listen" script for
a couple of tests that don't need this functionality.  This was causing
failures of some broccoli-related tests in the "istate" test directory
due to two instances of Bro trying to listen on the same port.
2017-05-24 14:45:11 -05:00
Jon Siwek
c857f5c4dd BIT-1785: fix scripts able to access uninitialized variables. 2017-02-06 23:30:54 -06:00
Johanna Amann
8eddeed78f Allow access to global variables using GLOBAL:: namespace.
Addresses BIT-1758. Patch was contributed by François Pennaneach
<francois.pennaneach@free.fr>.
2016-12-07 15:28:34 -08:00
Robin Sommer
83ff3f8cdc Attempt to make test more stable. 2016-08-12 08:19:51 -07:00
Robin Sommer
9da02ecae4 Merge branch 'topic/jgras/expire-redef' of https://github.com/J-Gras/bro
Extended error handling a bit, and increased serialization
data format version.
2016-06-14 17:22:25 -07:00
Johanna Amann
a72112acca Fix precedence of hook
The precedence is now lower than the precedence of &&/|| so that
expressions like

hook a() && doSomething()

work.

Addresses BIT-1619
2016-06-13 16:02:06 -07:00
Jan Grashoefer
8a87055fcc Fixed table expiration evaluation.
The expiration attribute expression is now evaluated for every use. Thus
later adjustments of the value (e.g. by redefining a const) will now
take effect. Values less than 0 will disable expiration.
2016-06-13 21:01:46 +02:00
Robin Sommer
53c523fa6f Normalizing test baseline. 2016-05-24 22:16:31 -07:00
Robin Sommer
4f9cb6912a Fix for a table refering to a expire function that's not defined.
I was hoping to report this right at startup through a static check
but turns out we don't have the right machinery in place for that.
That would need to be done after the AST has been finalized, but our
AST traversal code can't iterate over types. So instead I've changed
this so that it's still being reported at runtime but at least
doesn't crash Bro anymore.

Closes BIT-1597.
2016-05-23 12:48:34 -07:00
Johanna Amann
8f6cdbb489 Fix test failing when we use &> instead of 2>
On the shell of a few systems, that apparently masks the return code.

(Namely - Debian and FreeBSD)
2016-05-13 07:44:30 -07:00
Johanna Amann
5f50733276 Merge branch 'topic/jgras/event-vars' of https://github.com/J-Gras/bro 2016-05-12 07:40:44 -07:00
Jan Grashoefer
65607239c9 Added interpreter error for local event variables.
Scheduling a local event variable resulted in a global lookup instead of
evaluating the local variable. To prevent misunderstandings, this will
trigger an error now.
2016-05-11 12:26:11 +02:00
Robin Sommer
a9cb90b6f5 Adding canonifier to test. 2016-03-21 21:08:42 -07:00
Johanna Amann
cfffb6e634 Check that there is only one of read, write, create_expire 2016-03-18 12:34:26 -07:00
Jan Grashoefer
a5f4e8aafe Added &read_expire testcase for subnet tables 2016-03-17 19:53:22 +01: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
Johanna Amann
13c4489578 Testcase for crash when a record contains a function referencing a record.
Needs BRO_PROFILER_FILE set to crash
2016-01-21 13:56:21 -08:00
Johanna Amann
990726b514 Fix crash when deleting non existing record member.
Addresses BIT-1519
2016-01-12 15:02:20 -08: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
57501c6069 BIT-1367: improve coercion of anonymous records in set constructor.
Error messages for set constructors that fail the type check may also be
more verbose than before and point out specifically the suspect types.
2015-04-06 12:14:59 -05:00
Jon Siwek
062baefde0 Add 'while' statement to Bro language. 2015-02-13 11:26:54 -06: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
cdbe459f20 Make using local IDs in @if directives an error.
Addresses BIT-1296.
2014-12-02 12:30:46 -06:00
Jon Siwek
f214158cc5 BIT-1288: Improve coercion of &default expressions. 2014-11-18 12:40:16 -06:00
Robin Sommer
78de5c17ef Merge remote-tracking branch 'origin/topic/jsiwek/bit-1176'
* origin/topic/jsiwek/bit-1176:
  Fix segfault if when statement's RHS is unitialized.

BIT-1176 #merged
2014-10-31 16:30:49 -07:00
Robin Sommer
2e7b732c4b Merge remote-tracking branch 'origin/topic/jsiwek/bit-1280'
* origin/topic/jsiwek/bit-1280:
  BIT-1280: Fix checking vector indices via "in".

BIT-1280 #merged.
2014-10-31 16:28:08 -07:00
Jon Siwek
2a181a88c5 Allow arbitrary when statement timeout expressions
BIT-1284 #close
2014-10-31 10:38:23 -05:00
Jon Siwek
1f7facda5b Fix segfault if when statement's RHS is unitialized.
If it is ever assigned a value, the body of the when can be triggered as
usual.

Addresses BIT-1176.
2014-10-30 12:19:25 -05:00
Jon Siwek
e5f75cde93 BIT-1280: Fix checking vector indices via "in".
$ cat test.bro
local vec: vector of string = { "zero" };
vec[2] = "two";
print 0 in vec, 1 in vec, 2 in vec;

$ bro -b test.bro
T, F, T
2014-10-28 14:21:16 -05:00
Jon Siwek
3521a92a00 Detect functions that try to bind variables from an outer scope.
And raise an error saying that's not supported.
Addresses BIT-1233.
2014-08-22 16:49:10 -05:00
Jon Siwek
e616554ab8 Fix use-after-free in some cases of reassigning a table index.
Specifically observed when redef'ing the same index of a table that uses
subnets as indices, though the bug seems like it applies more generally
to anytime TableVal::Assign is provided with just the HashKey parameter
and not the index Val.

Addresses BIT-1202.
2014-06-10 13:38:32 -05:00
Jon Siwek
aee708c703 Change record ctors to only allow record-field-assignment expressions.
Previously, any expression that evaluates to a record may have been used
in a record ctor's expression list.  This didn't work in all cases,
doesn't provide any unique functionality that can't be done otherwise,
and is possibly a path to introducing subtle scripting errors.

BIT-1192 #closed
2014-05-19 15:50:00 -05:00
Jon Siwek
9a8226935d Add unit tests covering vector/set/table ctors/inits. 2014-03-21 09:22:03 -05:00
Jon Siwek
bf3c3887fd Fix parsing of "local" named table constructors. 2014-03-20 16:47:20 -05:00
Jon Siwek
b1fd161274 Improve type checking of records, addresses BIT-1159. 2014-03-20 13:54:26 -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
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
18bd20fe29 Fixing initialization context in anonymous functions.
When an anonymoys function was defined inside an initialization
context, that context transfered over to the function body and could
lead to spurious error messages.
2014-01-23 14:18:30 -08:00
Jon Siwek
58c7fcbbf1 Canonify output of a unit test. 2013-12-20 11:44:06 -06:00
Robin Sommer
ae9e0d4cb6 Fixing segfault with mismatching set &default in record field. 2013-12-18 09:17:05 -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
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
7e95755ce5 Fix record coercion tolerance of optional fields.
There were cases where coercing a record value with an uninitialized
field could cause a null pointer dereference even though the field
can validly be unset since it has &optional.
2013-10-23 11:37:23 -05:00
Jon Siwek
ae5a75bad9 Fix redef of table index from clearing table. Addresses #1013.
`redef foo["x"] = 1` now acts like `redef foo += { ["x"] = 1 }`
instead of `redef foo = { ["x"] = 1 }`.
2013-06-12 15:18:58 -05:00
Jon Siwek
022ce2505f Change @PATH to @DIR for clarity. Add @FILENAME. Addresses #869.
@DIR expands to directory path of the script, @FILENAME expands to just
the script file name without path.
2013-06-05 11:01:11 -05:00
Jon Siwek
7e8b504305 Make @PATH always return absolute path. Addresses #869. 2013-06-04 14:16:56 -05:00
Jon Siwek
307fc187c0 Add @PATH bro script macro. Addresses #869.
The macro expands to a string value containing the file system path
in which the script lives.
2013-06-04 10:53:10 -05:00
Jon Siwek
a66b7380b6 Allow named vector constructors. Addresses #983. 2013-05-30 10:57:28 -05:00
Jon Siwek
bcf5c41786 Allow named table constructors. Addresses #983. 2013-05-30 10:21:15 -05:00