]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
wirefuzz: add -N option to count complete passes
authorVictor Julien <victor@inliniac.net>
Thu, 26 Nov 2015 16:32:25 +0000 (17:32 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 13 Feb 2016 08:45:49 +0000 (09:45 +0100)
qa/wirefuzz.pl

index 059e5e671947e876f9e03ae92259a53b20a4731c..c24ec6a0e8fde4a47f6f3061b2391cc723fda5de 100755 (executable)
@@ -64,6 +64,7 @@ my @tmpfiles;
 my @files;
 my $suricatabin;
 my $loopnum;
+my $loopnum_per_file = 0;
 my $rules;
 my $rules_exclusive = 0;
 my $logdir;
@@ -81,7 +82,7 @@ my $keeplogs;
 my $file_was_fuzzed = 0;
 
 Getopt::Long::Configure("prefix_pattern=(-|--)");
-GetOptions( \%config, qw(n=s r=s c=s e=s v=s p=s l=s s=s S=s x=s k y z=s h help) );
+GetOptions( \%config, qw(n=s N=s r=s c=s e=s v=s p=s l=s s=s S=s x=s k y z=s h help) );
 
 &parseopts();
 
@@ -151,16 +152,33 @@ sub parseopts {
         &printhelp();
     }
 
+    if ( $config{n} && $config{N} ) {
+        print "ERROR: can't mix -n and -N\n";
+        exit(1);
+    }
+
     #number of times to loop
     if ( $config{n} ) {
         $loopnum = $config{n};
+        $loopnum_per_file = 1;
+        print "parseopts: looping through the pcaps " . $loopnum . " times or until we have an error\n";
+    }
+    else {
+        $loopnum = "infinity";
+    }
+
+    if ( $config{N} ) {
+        $loopnum = $config{N};
         print "parseopts: looping through the pcaps " . $loopnum . " times or until we have an error\n";
     }
     else {
-        print "parseopts: looping through the pcaps forever or until we have an error\n";
         $loopnum = "infinity";
     }
 
+    if ( $loopnum == "infinity") {
+        print "parseopts: looping through the pcaps forever or until we have an error\n";
+    }
+
     #rules file do we have a path and does it exist
     if ( $config{s} && -e $config{s} ) {
         $rules = $config{s};
@@ -286,6 +304,7 @@ sub printhelp {
         -h or help <this output>
         -r=<filemask for pcaps to read>
         -n=<(optional) number of iterations or if not specified will run until error>
+        -N=<(optional) number of iterations of all files in the test set>
         -s=<(optional) path to ids rules file will be passed as -s to suricata>
         -S=<(optional) path to ids rules file will be passed as -S to suricata>
         -e=<(optional) editcap error ratio to introduce if not specified will not fuzz. Valid range for this is 0.00 - 1.0>
@@ -473,7 +492,9 @@ while ( $successcnt < $loopnum ) {
                 $knownerr = 1;
             }
             if ( $knownerr eq 1 ) {
-                $successcnt++;
+                if ($loopnum_per_file == 1) {
+                    $successcnt++;
+                }
                 print "suricata: we have run with success " . $successcnt . " times\n";
                 if( $keeplogs eq "yes" ) {
                     &keep_logs($fuzzedfilename);
@@ -521,7 +542,10 @@ while ( $successcnt < $loopnum ) {
                 print "Stream mem counter could not be found in output\n";
             }
 
-            $successcnt++;
+            if ($loopnum_per_file == 1) {
+                $successcnt++;
+            }
+
             print "suricata: we have run with success " . $successcnt . " times\n";
             print "******************Suricata Complete**********************\n";
             if( $keeplogs eq "yes" ) {
@@ -537,6 +561,9 @@ while ( $successcnt < $loopnum ) {
             last;
         }
     }
+    if ($loopnum_per_file == 0) {
+        $successcnt++;
+    }
     if ($successcnt >= $loopnum) {
         last;
     }