mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Improve error for invalid use of types as values (addresses #923).
This scripting error can now generate an error message at parse-time instead of run-time and also includes location information.
This commit is contained in:
parent
ea6b62f586
commit
2f0c698ed5
4 changed files with 21 additions and 2 deletions
|
@ -28,7 +28,7 @@ event signature_match(state: signature_state, msg: string, data: string) &priori
|
||||||
if ( /^webapp-/ !in state$sig_id ) return;
|
if ( /^webapp-/ !in state$sig_id ) return;
|
||||||
|
|
||||||
local c = state$conn;
|
local c = state$conn;
|
||||||
local si = Software::Info;
|
local si: Software::Info;
|
||||||
si = [$name=msg, $unparsed_version=msg, $host=c$id$resp_h, $host_p=c$id$resp_p, $software_type=WEB_APPLICATION];
|
si = [$name=msg, $unparsed_version=msg, $host=c$id$resp_h, $host_p=c$id$resp_p, $software_type=WEB_APPLICATION];
|
||||||
si$url = build_url_http(c$http);
|
si$url = build_url_http(c$http);
|
||||||
if ( c$id$resp_h in Software::tracked &&
|
if ( c$id$resp_h in Software::tracked &&
|
||||||
|
|
|
@ -233,7 +233,11 @@ NameExpr::NameExpr(ID* arg_id, bool const_init) : Expr(EXPR_NAME)
|
||||||
{
|
{
|
||||||
id = arg_id;
|
id = arg_id;
|
||||||
in_const_init = const_init;
|
in_const_init = const_init;
|
||||||
SetType(id->Type()->Ref());
|
|
||||||
|
if ( id->AsType() )
|
||||||
|
SetType(new TypeType(id->AsType()));
|
||||||
|
else
|
||||||
|
SetType(id->Type()->Ref());
|
||||||
|
|
||||||
EventHandler* h = event_registry->Lookup(id->Name());
|
EventHandler* h = event_registry->Lookup(id->Name());
|
||||||
if ( h )
|
if ( h )
|
||||||
|
|
1
testing/btest/Baseline/language.type-type-error/.stderr
Normal file
1
testing/btest/Baseline/language.type-type-error/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
error in /home/jsiwek/bro/testing/btest/.tmp/language.type-type-error/type-type-error.bro, line 13: not a record (r$a)
|
14
testing/btest/language/type-type-error.bro
Normal file
14
testing/btest/language/type-type-error.bro
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# @TEST-EXEC-FAIL: bro -b %INPUT
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||||
|
|
||||||
|
type r: record {
|
||||||
|
a: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
# This should generate a parse error indicating that the type identifier
|
||||||
|
# is incorrectly used in an expression expecting a real value and not
|
||||||
|
# a value of type TypeType.
|
||||||
|
print r$a;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue