mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-710: Check that &expire_func is a function and not hook/event
This commit is contained in:
parent
9f802b2a4d
commit
e1a39d27f3
3 changed files with 26 additions and 0 deletions
|
@ -512,10 +512,19 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
const auto& expire_func = a->GetExpr();
|
const auto& expire_func = a->GetExpr();
|
||||||
|
|
||||||
if ( expire_func->GetType()->Tag() != TYPE_FUNC )
|
if ( expire_func->GetType()->Tag() != TYPE_FUNC )
|
||||||
|
{
|
||||||
Error("&expire_func attribute is not a function");
|
Error("&expire_func attribute is not a function");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const FuncType* e_ft = expire_func->GetType()->AsFuncType();
|
const FuncType* e_ft = expire_func->GetType()->AsFuncType();
|
||||||
|
|
||||||
|
if ( e_ft->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||||
|
{
|
||||||
|
Error("&expire_func attribute is not a function");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ( e_ft->Yield()->Tag() != TYPE_INTERVAL )
|
if ( e_ft->Yield()->Tag() != TYPE_INTERVAL )
|
||||||
{
|
{
|
||||||
Error("&expire_func must yield a value of type interval");
|
Error("&expire_func must yield a value of type interval");
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.expire-func-type-check/expire-func-type-check.zeek, line 12: &expire_func attribute is not a function (&expire_func=myev)
|
||||||
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.expire-func-type-check/expire-func-type-check.zeek, line 13: &expire_func attribute is not a function (&expire_func=myhk)
|
||||||
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.expire-func-type-check/expire-func-type-check.zeek, line 14: &expire_func attribute is not a function (&expire_func=foo)
|
14
testing/btest/language/expire-func-type-check.zeek
Normal file
14
testing/btest/language/expire-func-type-check.zeek
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b %INPUT >output 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
|
||||||
|
|
||||||
|
event myev(t: table[string] of count)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
hook myhk(t: table[string] of count)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
global foo = 3;
|
||||||
|
|
||||||
|
global t: table[string] of count &expire_func=myev;
|
||||||
|
global tt: table[string] of count &expire_func=myhk;
|
||||||
|
global ttt: table[string] of count &expire_func=foo;
|
Loading…
Add table
Add a link
Reference in a new issue