zeek / zeek

Zeek is a powerful network analysis framework that is much different from the typical IDS you may know.
https://www.zeek.org
Other
6.49k stars 1.22k forks source link

Zeek doesn't complain about completely redefining a record #2686

Open vpax opened 1 year ago

vpax commented 1 year ago

Surprisingly, this script compiles fine:

type r: record {
        a: count &default=3;
        b: string &default="missing";
};

global x1: r;

type r: record {
        d: count &default=4;
        e: string &default="present";
        f: double &default=3.14;
};

global x2: r;

print x1, x2;

and when run prints:

[a=3, b=missing], [d=4, e=present, f=3.14]
timwoj commented 1 year ago

Just at a quick glance, it looks like we only avoid creating duplicate IDs if we're not in the global scope. It'll happily do this otherwise.

awelzel commented 4 days ago

It's the same for enums, actually, and we might be relying on this working due to enum's being repeated for .bif files and in .zeek files:

https://github.com/zeek/zeek/pull/4063#discussion_r1858864804