mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
fix little sneaky bug in input framework with an edge case.
An assertion would trigger in the case when a predicate refuses a new entry and another entry with the same index elements was already in the table. (I thought that code block was unreachable ... did not think of this case).
This commit is contained in:
parent
18550ab009
commit
a2b5028b58
3 changed files with 60 additions and 3 deletions
|
@ -1044,9 +1044,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
|
||||||
|
|
||||||
if ( ! updated )
|
if ( ! updated )
|
||||||
{
|
{
|
||||||
// throw away. Hence - we quit. And remove the entry from the current dictionary...
|
// just quit and delete everything we created.
|
||||||
// (but why should it be in there? assert this).
|
|
||||||
assert ( stream->currDict->RemoveEntry(idxhash) == 0 );
|
|
||||||
delete idxhash;
|
delete idxhash;
|
||||||
delete h;
|
delete h;
|
||||||
return stream->num_val_fields + stream->num_idx_fields;
|
return stream->num_val_fields + stream->num_idx_fields;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
[1.228.83.33] = [asn=9318 HANARO-AS Hanaro Telecom Inc., severity=medium, confidence=95, detecttime=1342569600.0]
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
# (uses listen.bro just to ensure input sources are more reliably fully-read).
|
||||||
|
# @TEST-SERIALIZE: comm
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-wait -k 5
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
# Ok, this one tests a fun case.
|
||||||
|
# Input file contains two lines mapping to the same index, but with different values,
|
||||||
|
# where the predicate accepts the first one and refuses the second one.
|
||||||
|
# Desired result -> first entry stays.
|
||||||
|
|
||||||
|
@TEST-START-FILE input.log
|
||||||
|
#fields restriction guid severity confidence detecttime address protocol portlist asn prefix rir cc impact description alternativeid_restriction alternativeid
|
||||||
|
need-to-know 8c864306-d21a-37b1-8705-746a786719bf medium 65 1342656000 1.0.17.227 - - 2519 VECTANT VECTANT Ltd. 1.0.16.0/23 apnic JP spam infrastructure spamming public http://reputation.alienvault.com/reputation.generic
|
||||||
|
need-to-know 8c864306-d21a-37b1-8705-746a786719bf medium 95 1342569600 1.228.83.33 6 25 9318 HANARO-AS Hanaro Telecom Inc. 1.224.0.0/13 apnic KR spam infrastructure direct ube sources, spam operations & spam services public http://www.spamhaus.org/query/bl?ip=1.228.83.33
|
||||||
|
need-to-know 8c864306-d21a-37b1-8705-746a786719bf medium 65 1342656000 1.228.83.33 - - 9318 HANARO-AS Hanaro Telecom Inc. 1.224.0.0/13 apnic KR spam infrastructure spamming;malware domain public http://reputation.alienvault.com/reputation.generic
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@load frameworks/communication/listen
|
||||||
|
|
||||||
|
global outfile: file;
|
||||||
|
|
||||||
|
redef InputAscii::empty_field = "EMPTY";
|
||||||
|
|
||||||
|
module A;
|
||||||
|
|
||||||
|
type Idx: record {
|
||||||
|
address: addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Val: record {
|
||||||
|
asn: string;
|
||||||
|
severity: string;
|
||||||
|
confidence: count;
|
||||||
|
detecttime: time;
|
||||||
|
};
|
||||||
|
|
||||||
|
global servers: table[addr] of Val = table();
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
outfile = open("../out");
|
||||||
|
# first read in the old stuff into the table...
|
||||||
|
Input::add_table([$source="../input.log", $name="input", $idx=Idx, $val=Val, $destination=servers,
|
||||||
|
$pred(typ: Input::Event, left: Idx, right: Val) = { if ( right$confidence > 90 ) { return T; } return F; }
|
||||||
|
]);
|
||||||
|
Input::remove("input");
|
||||||
|
}
|
||||||
|
|
||||||
|
event Input::update_finished(name: string, source: string)
|
||||||
|
{
|
||||||
|
print outfile, servers;
|
||||||
|
close(outfile);
|
||||||
|
terminate();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue