Hi Jon,
I’ve attached a minimal script that does what I am describing. However, when I try this minimal script on try.bro.org it works correctly as I expected. However, in my cluster setup, the end_entity event from response body is coming first, then log-filter call, followed by end entity call for request. Since I have other events I am processing for the request, not sure if they are affecting the order. Giving a priority of 10 for the end_entity event did not fix it either. Running the minimalist script I gave here also causes the problem on my system but not try.bro.org website. Really puzzling
fyi, I’ve included the logs I see in my reporter log which indicates the order of the events at the end of this email
Dk.
PS: pcap link https://www.dropbox.com/s/epx2nz60d06uor9/long-user.pcap?dl=0
@load base/protocols/http/main
module HTTP;
export {
redef record Info += {
request_body: string &log &optional;
request_body_complete: bool &log &default=F;
response_body: string &log &optional;
response_body_complete: bool &log &default=F;
log_pred: bool &default=T;
};
}
event bro_init()
{
Log::remove_default_filter(HTTP::LOG);
Log::add_filter(HTTP::LOG, [$name=“new-default”,
$pred(rec: HTTP::Info) = {
Reporter::info(fmt(“request body complete: %s, bsize=%d”
, rec$request_body_complete?“true”:“false”
, |rec$request_body|));
return rec$log_pred;
}
]);
}
event http_entity_data(c: connection, is_orig: bool, length: count, data: string)
{
if (is_orig) {
request body accumulation
if (is_orig && !c$http?$request_body)
c$http$request_body = “”;
c$http$request_body += data;
} else {
response body accumulation.
if (!is_orig && !c$http?$response_body)
c$http$response_body = “”;
c$http$response_body += data;
}
}
event http_end_entity(c: connection, is_orig: bool)
{
Reporter::info(fmt("%s: end_entity called for %s, bsize=%d"
, c$uid, is_orig?“request”:“response”, |c$http$request_body|));
if (is_orig) {
if (|c$http$request_body| > 0) {
c$http$request_body = encode_base64(c$http$request_body);
c$http$request_body_complete = T;
}
} else {
if (|c$http$response_body| > 0) {
c$http$response_body = encode_base64(c$http$response_body);
c$http$response_body_complete = T;
}
}
}
Logs order on my setup: