From fa0198bc816609a79750b325daee8c3e9ebd3337 Mon Sep 17 00:00:00 2001 From: Darren Brumfield Date: Wed, 5 Sep 2018 11:06:03 -0400 Subject: [PATCH] Added -e/error flag to modify exit code if bad rules are found --- dumbpig.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dumbpig.pl b/dumbpig.pl index 1929b9a..75d8c19 100755 --- a/dumbpig.pl +++ b/dumbpig.pl @@ -49,6 +49,7 @@ my @blackArray=(); my $fixnormbug=1; # I found a bug in Parse::Snort with whitespace normalization, # this is a quick fix while waiting for patch upstream +my $chgexitcode=0; sub convert_bl{ # Convert a load of snort rule header format IPs (or CIDR) to the format used by the blacklist patch @@ -119,6 +120,7 @@ sub usage{ print " -v or --verbose Verbose output for debugging\n"; print " -c or --censor Censor rules in the output, in case you dont trust everyone\n"; print " -f or --forcefail Force good rules to FAIL. Allows output of all rules\n"; + print " -e or --error Use nonzero return code if bad rules are found\n"; exit 1; } @@ -132,6 +134,7 @@ sub usage{ 'f|forcefail' => \$forcefail, 'c|censor' => \$censor, 'q|quiet' => \$q, + 'e|error' => \$chgexitcode, ); unless ( $q ) { @@ -619,3 +622,4 @@ sub usage{ print "--------------------------------------\n"; print "Total: $failnum fails over $rulecount rules ($linenum lines) in $rulefile\n"; print "- Contact leon.ward\@sourcefire.com\n"; +exit $failnum if $chgexitcode;