Add report of number of files with bogus names discarded
authorJacob Bachmeyer <jcb@gnu.org>
Sun, 16 Oct 2022 00:53:35 +0000 (19:53 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Sun, 16 Oct 2022 00:53:35 +0000 (19:53 -0500)
gatekeeper.pl
testsuite/lib/gatekeeper.exp

index d94dc8d4b3d443f1c5d7c62dd52d0abf6391eef7..16ccac99e64795d0b7525d9fafcc9682981cd7d9 100755 (executable)
@@ -869,7 +869,7 @@ sub scan_incoming {
   local *_;
 
   my $time_bar = time - 120;
-  my @trash;
+  my @trash; my $badname_count = 0;
   my %possible;
   # Get list of all possible files from incoming dir.
   #
@@ -880,7 +880,7 @@ sub scan_incoming {
     # require acceptable filenames
     unless (length($_) <= MAX_FILE_NAME_LEN && /^($RE_filename_here)$/) {
       m/^(.*)$/;       # untaint the value
-      push @trash, File::Spec->catfile($directory, $1);
+      push @trash, File::Spec->catfile($directory, $1); $badname_count++;
       # This is safe for unlink (which is all we will do with @trash)
       # because the filename came from a directory entry, so it must be a
       # valid filename and cannot indicate directory traversal.
@@ -925,6 +925,8 @@ sub scan_incoming {
     or ftp_die("FATAL: closedir($directory) failed: $!");
 
   # dispose of any garbage files
+  ftp_syslog('info', "$badname_count files with bogus names were trashcanned")
+    if $badname_count;
   ftp_syslog('info', "Trashcanned files removed")
     if unlink @trash;
   @trash = (); # and empty the array to be safe, since it contained
index 683b6e61a4213afee4f354bb0c9ec29cfa4414b2..e84d263472aaee7c3879e0aed930e854c9009290 100644 (file)
@@ -538,6 +538,11 @@ proc analyze_log { base_dir name assess } {
                     set A(scan,$expect_out(1,string)) 1
                     exp_continue
                 }
+       -re {^gatekeeper\[[0-9]+\]: \(Test\)\
+                [0-9]+ files with bogus names were trashcanned} {
+                    # from scan_incoming, reporting count of bad file names
+                    exp_continue
+                }
        -re {^gatekeeper\[[0-9]+\]: \(Test\)\
                 Trashcanned files removed} {
                     # from scan_incoming, when garbage files are purged