mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Check that there is only one of read, write, create_expire
This commit is contained in:
parent
8de0804712
commit
cfffb6e634
5 changed files with 36 additions and 0 deletions
21
src/Attr.cc
21
src/Attr.cc
|
@ -375,12 +375,33 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
case ATTR_EXPIRE_READ:
|
case ATTR_EXPIRE_READ:
|
||||||
case ATTR_EXPIRE_WRITE:
|
case ATTR_EXPIRE_WRITE:
|
||||||
case ATTR_EXPIRE_CREATE:
|
case ATTR_EXPIRE_CREATE:
|
||||||
|
{
|
||||||
if ( type->Tag() != TYPE_TABLE )
|
if ( type->Tag() != TYPE_TABLE )
|
||||||
{
|
{
|
||||||
Error("expiration only applicable to tables");
|
Error("expiration only applicable to tables");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int num_expires = 0;
|
||||||
|
if ( attrs )
|
||||||
|
{
|
||||||
|
loop_over_list(*attrs, i)
|
||||||
|
{
|
||||||
|
Attr* a = (*attrs)[i];
|
||||||
|
if ( a->Tag() == ATTR_EXPIRE_READ ||
|
||||||
|
a->Tag() == ATTR_EXPIRE_WRITE ||
|
||||||
|
a->Tag() == ATTR_EXPIRE_CREATE )
|
||||||
|
num_expires++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( num_expires > 1 )
|
||||||
|
{
|
||||||
|
Error("set/table can only have one of &read_expire, &write_expire, &create_expire");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//### not easy to test this w/o knowing the ID.
|
//### not easy to test this w/o knowing the ID.
|
||||||
if ( ! IsGlobal() )
|
if ( ! IsGlobal() )
|
||||||
|
|
1
testing/btest/Baseline/language.expire_multiple-2/output
Normal file
1
testing/btest/Baseline/language.expire_multiple-2/output
Normal file
|
@ -0,0 +1 @@
|
||||||
|
error in /Users/johanna/bro/master/testing/btest/.tmp/language.expire_multiple-2/expire_multiple.test, line 2: set/table can only have one of &read_expire, &write_expire, &create_expire (&write_expire=1.0 sec, &create_expire=3.0 secs)
|
1
testing/btest/Baseline/language.expire_multiple-3/output
Normal file
1
testing/btest/Baseline/language.expire_multiple-3/output
Normal file
|
@ -0,0 +1 @@
|
||||||
|
error in /Users/johanna/bro/master/testing/btest/.tmp/language.expire_multiple-3/expire_multiple.test, line 2: set/table can only have one of &read_expire, &write_expire, &create_expire (&write_expire=1.0 sec, &read_expire=3.0 secs)
|
1
testing/btest/Baseline/language.expire_multiple/output
Normal file
1
testing/btest/Baseline/language.expire_multiple/output
Normal file
|
@ -0,0 +1 @@
|
||||||
|
error in /Users/johanna/bro/master/testing/btest/.tmp/language.expire_multiple/expire_multiple.test, line 4: set/table can only have one of &read_expire, &write_expire, &create_expire (&create_expire=1.0 sec, &read_expire=1.0 sec)
|
12
testing/btest/language/expire_multiple.test
Normal file
12
testing/btest/language/expire_multiple.test
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# @TEST-EXEC-FAIL: bro -b %INPUT >output 2>&1
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
global s: set[string] &create_expire=1secs &read_expire=1secs;
|
||||||
|
|
||||||
|
# @TEST-START-NEXT:
|
||||||
|
|
||||||
|
global s: set[string] &write_expire=1secs &create_expire=3secs;
|
||||||
|
|
||||||
|
# @TEST-START-NEXT:
|
||||||
|
|
||||||
|
global s: set[string] &write_expire=1secs &read_expire=3secs;
|
Loading…
Add table
Add a link
Reference in a new issue