mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 22:18:20 +00:00

If a test doesn't rely on libmagic, mime type related columns of baselined logs are filtered out. If a test does rely on libmagic, it needs to use the TEST-REQUIRES btest macro to check that the bro build supports it, and then mime type related columns of logs can be normalized via a logging filter to reduce sensitivity to varying version of libmagic.
24 lines
739 B
Text
24 lines
739 B
Text
# This tests md5 calculation for a specified mime type. The http.log
|
|
# will normalize mime types other than the target type to prevent sensitivity
|
|
# to varying versions of libmagic.
|
|
|
|
# @TEST-REQUIRES: grep -q '#define HAVE_LIBMAGIC' $BUILD/config.h
|
|
# @TEST-EXEC: bro -r $TRACES/http-pipelined-requests.trace %INPUT > output
|
|
# @TEST-EXEC: btest-diff http.log
|
|
|
|
@load protocols/http
|
|
|
|
redef HTTP::generate_md5 += /image\/png/;
|
|
|
|
event bro_init()
|
|
{
|
|
Log::remove_default_filter(HTTP::HTTP);
|
|
Log::add_filter(HTTP::HTTP, [$name="normalized-mime-types",
|
|
$pred=function(rec: HTTP::Info): bool
|
|
{
|
|
if ( rec?$mime_type && HTTP::generate_md5 != rec$mime_type )
|
|
rec$mime_type = "FAKE_MIME";
|
|
return T;
|
|
}
|
|
]);
|
|
}
|