[Bro-Dev] Proposing a new type: opaque

Matthias Vallentin vallentin at icir.org
Sun Nov 18 19:26:59 PST 2012


Bro currently misuses the any type to describe "handle" or "descriptor"
types. Consider for example the MD5 function family, which take a state
object as first argument. At the scripting layer, it has no other
purpose than mapping to the corresponding MD5 state at the core. Users
don't use it otherwise. There exists no dedicated handle type in Bro,
although it wouldn't be complicated to add one.

I am encountering this during the review of Soumya's cardinality counter
code. Before continuing with the merge, I propose to add a dedicated
opaque type that has the form:

    opaque of T

where T is an identifier from the parsers perspective. For example, this
would entail a signature change from

    md5_hash_init(idx: any): bool

to
    md5_hash_init(idx: opaque of MD5): bool

At script load time, Bro can ensure type safety by performing string
comparisons that come with the identifier. Such a type would finally add
structure to the process of adding new BiFs and related extensions. 

   Matthias


More information about the bro-dev mailing list