mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58: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.
29 lines
950 B
Text
29 lines
950 B
Text
# This tests that the contents of a DCC transfer negotiated with IRC can be
|
|
# correctly extracted. The mime type of the file transferred is normalized
|
|
# to prevent sensitivity to libmagic version being used.
|
|
|
|
# @TEST-REQUIRES: grep -q '#define HAVE_LIBMAGIC' $BUILD/config.h
|
|
# @TEST-EXEC: bro -r $TRACES/irc-dcc-send.trace %INPUT
|
|
# @TEST-EXEC: btest-diff irc.log
|
|
# @TEST-EXEC: btest-diff irc-dcc-item_192.168.1.77:57655-209.197.168.151:1024_1.dat
|
|
# @TEST-EXEC: bro -r $TRACES/irc-dcc-send.trace %INPUT IRC::extraction_prefix="test"
|
|
# @TEST-EXEC: test -e test_192.168.1.77:57655-209.197.168.151:1024_1.dat
|
|
|
|
@load protocols/irc
|
|
|
|
redef IRC::extract_file_types=/.*/;
|
|
|
|
event bro_init()
|
|
{
|
|
Log::remove_default_filter(IRC::IRC);
|
|
Log::add_filter(IRC::IRC, [$name="normalized-mime-types",
|
|
$pred=function(rec: IRC::Info): bool
|
|
{
|
|
if ( rec?$dcc_mime_type )
|
|
{
|
|
rec$dcc_mime_type = "FAKE_MIME";
|
|
}
|
|
return T;
|
|
}
|
|
]);
|
|
}
|