Finish implementation of copy method.

All types (besides EntropyVal) now support a native copy operation,
which uses primitives of the underlying datatypes to perform a quick
copy, without serialization.

EntropyVal is the one exception - since that type is rather complex
(many members) and will probably not be copied a lot, if at all, it
makes sense to just use the serialization function.

This will have to be slightly re-written in the near-term-future to use
the new serialization function for that opaque type.

This change also introduces a new x509_from_der bif, which allows to
parse a der into an opaque of x509.

This change removes the d2i_X509_ wrapper function; this was a remnant
when d2i_X509 took non-const arguments. We directly use d2i_X509 at
several places assuming const-ness, so there does not seem to ba a
reason to keep the wrapper.

This change also exposed a problem in the File cache - cases in which an
object was brought back into the cache, and writing occurred in the
file_open event were never correctly handeled as far as I can tell.
This commit is contained in:
Johanna Amann 2019-05-22 11:36:52 -07:00
parent 2efbe76920
commit 74bb7716f6
22 changed files with 280 additions and 33 deletions

View file

@ -3,7 +3,7 @@
event zeek_init() &priority=5
{
local r1: SumStats::Reducer = [$stream="test.metric",
local r1: SumStats::Reducer = [$stream="test.metric",
$apply=set(SumStats::TOPK)];
# Merge two empty sets
local topk1: opaque of topk = topk_init(4);
@ -18,9 +18,9 @@ event zeek_init() &priority=5
local r = result["test.metric"];
local s: vector of SumStats::Observation;
s = topk_get_top(r$topk, 5);
print fmt("Top entries for key %s", key$str);
for ( element in s )
for ( element in s )
{
print fmt("Num: %d, count: %d, epsilon: %d", s[element]$num, topk_count(r$topk, s[element]), topk_epsilon(r$topk, s[element]));
}
@ -32,16 +32,16 @@ event zeek_init() &priority=5
local a: count;
a = 0;
for ( i in loop_v )
for ( i in loop_v )
{
a = a + 1;
for ( j in loop_v )
{
if ( i < j )
if ( i < j )
SumStats::observe("test.metric", [$str="counter"], [$num=a]);
}
}
SumStats::observe("test.metric", [$str="two"], [$num=1]);
SumStats::observe("test.metric", [$str="two"], [$num=1]);