From: Jacob Bachmeyer Date: Sun, 16 Oct 2022 00:53:35 +0000 (-0500) Subject: Add report of number of files with bogus names discarded X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e06f7f894b32deea4692127bf11758203f66be09;p=gatekeeper.git Add report of number of files with bogus names discarded --- 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