<div dir="ltr"><br><div>Sounds good and I like it. To be honest I&#39;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 &amp;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 &lt;<a href="mailto:vern@corelight.com">vern@corelight.com</a>&gt; 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>
                &amp;default = 10<br>
                &amp;default = 9<br>
                &amp;optional<br>
                &amp;log<br>
                &amp;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&#39;m planning to add basic consistency checking, which will look for<br>
(1) attributes that are repeated (which doesn&#39;t appear to be meaningful for<br>
any of them) and (2) attributes that don&#39;t make sense in a given context,<br>
like the ones listed above.<br>
<br>
I&#39;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      (&amp;redef)<br>
                to global type          (&amp;redef)<br>
                to event handler        (&amp;priority)<br>
                to record field         (&amp;log)<br>
                to indexed type         (&amp;default)<br>
                to global indexed type  (&amp;add_func)<br>
                to type with expirable entries  (&amp;expire_func)<br>
                to a file               (&amp;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>