<div dir="ltr"><br><div>Sounds good and I like it. To be honest I'm not even sure if the behavior is defined right now, i.e. if the later value will overwrite the first one.</div><div><br></div><div>Do you want to error out when two &defaults are found or overwrite the first with the second one?</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 29, 2018 at 11:56 AM Vern Paxson <<a href="mailto:vern@corelight.com">vern@corelight.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Attributes currently receive essentially no consistency checking.<br>
For example, executing this script:<br>
<br>
global a: count<br>
&default = 10<br>
&default = 9<br>
&optional<br>
&log<br>
&add_func = function(d: double, t: time): count { return 3; };<br>
print a;<br>
<br>
simply results in:<br>
<br>
error in /Users/vern/tmp/attr-type-check.bro, line 7: value used but not set (a)<br>
<br>
I'm planning to add basic consistency checking, which will look for<br>
(1) attributes that are repeated (which doesn't appear to be meaningful for<br>
any of them) and (2) attributes that don't make sense in a given context,<br>
like the ones listed above.<br>
<br>
I'm thinking of implementing this as an internal table of meta-attributes,<br>
i.e., each attribute type, like ATTR_OPTIONAL, will have its own attributes<br>
like whether it requires a record context, only makes sense for aggregates,<br>
etc. Here are the ones that come to mind, based on looking at the attributes<br>
at <a href="https://www.bro.org/sphinx/script-reference/attributes.html" rel="noreferrer" target="_blank">https://www.bro.org/sphinx/script-reference/attributes.html</a> with examples<br>
in parens:<br>
<br>
applies to global variable (&redef)<br>
to global type (&redef)<br>
to event handler (&priority)<br>
to record field (&log)<br>
to indexed type (&default)<br>
to global indexed type (&add_func)<br>
to type with expirable entries (&expire_func)<br>
to a file (&rotate_interval)<br>
<br>
Any feedback?<br>
<br>
Vern<br>
_______________________________________________<br>
bro-dev mailing list<br>
<a href="mailto:bro-dev@bro.org" target="_blank">bro-dev@bro.org</a><br>
<a href="http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-dev" rel="noreferrer" target="_blank">http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-dev</a><br>
</blockquote></div>