From e06f7f894b32deea4692127bf11758203f66be09 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 15 Oct 2022 19:53:35 -0500 Subject: [PATCH] Add report of number of files with bogus names discarded --- gatekeeper.pl | 6 ++++-- testsuite/lib/gatekeeper.exp | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index d94dc8d..16ccac9 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -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 diff --git a/testsuite/lib/gatekeeper.exp b/testsuite/lib/gatekeeper.exp index 683b6e6..e84d263 100644 --- a/testsuite/lib/gatekeeper.exp +++ b/testsuite/lib/gatekeeper.exp @@ -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 -- 2.25.1