Testing/external scripts no longer compute MD5 checksums for SMTP

entities.

Before, whether they did depended on libmagic. To do that,
smpt/entities.bro gets a new option `never_calc_md5`.

Also restructuring the tests a bit so that load a common
testing-setup.bro scripts that can set a global configuration.
This commit is contained in:
Robin Sommer 2011-09-15 15:35:58 -07:00
parent 4bc18bd3f2
commit 9ee8a9f806
4 changed files with 19 additions and 4 deletions

View file

@ -69,6 +69,11 @@ export {
## The on-disk prefix for files to be extracted from MIME entity bodies. ## The on-disk prefix for files to be extracted from MIME entity bodies.
const extraction_prefix = "smtp-entity" &redef; const extraction_prefix = "smtp-entity" &redef;
## If set, never generate MD5s. This is mainly for testing purposes to create
## reproducable output in the case that the decision whether to create
## checksums depends on environment specifics.
const never_calc_md5 = F &redef;
global log_mime: event(rec: EntityInfo); global log_mime: event(rec: EntityInfo);
} }
@ -121,7 +126,7 @@ event mime_segment_data(c: connection, length: count, data: string) &priority=-5
if ( c$smtp$current_entity$content_len == 0 ) if ( c$smtp$current_entity$content_len == 0 )
{ {
if ( generate_md5 in c$smtp$current_entity$mime_type ) if ( generate_md5 in c$smtp$current_entity$mime_type && ! never_calc_md5 )
c$smtp$current_entity$calc_md5 = T; c$smtp$current_entity$calc_md5 = T;
if ( c$smtp$current_entity$calc_md5 ) if ( c$smtp$current_entity$calc_md5 )

View file

@ -1,2 +1,6 @@
@TEST-EXEC: zcat $TRACES/test.trace.gz | bro -r - test-all-policy # @TEST-EXEC: zcat $TRACES/trace.gz | bro -r - %INPUT
@TEST-EXEC: $SCRIPTS/diff-all *.log # @TEST-EXEC: $SCRIPTS/diff-all *.log
@load testing-setup
@load test-all-policy

View file

@ -0,0 +1,6 @@
# Sets some testing specific options.
@ifdef ( SMTP::never_calc_md5 )
# MDD5s can depend on libmagic output.
redef SMTP::never_calc_md5 = T;
@endif

View file

@ -6,7 +6,7 @@ IgnoreDirs = .svn CVS .tmp
IgnoreFiles = *.tmp *.swp #* *.trace .gitignore *.skeleton IgnoreFiles = *.tmp *.swp #* *.trace .gitignore *.skeleton
[environment] [environment]
BROPATH=`bash -c %(testbase)s/../../../build/bro-path-dev` BROPATH=`bash -c %(testbase)s/../../../build/bro-path-dev`:%(testbase)s/../scripts
BRO_SEED_FILE=%(testbase)s/../random.seed BRO_SEED_FILE=%(testbase)s/../random.seed
TZ=UTC TZ=UTC
LC_ALL=C LC_ALL=C