Report unknown files as soon as they are detected. This means they no longer need an extra week to live. Also the WineTest reports of deleted VMs no longer get reported as 'suspicious'.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/Janitor.pl | 54 ++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 34 deletions(-)
diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl index 4eda071fa..579a43275 100755 --- a/testbot/bin/Janitor.pl +++ b/testbot/bin/Janitor.pl @@ -265,34 +265,24 @@ if (opendir(my $dh, "$DataDir/staging")) foreach my $Entry (@Entries) { next if ($Entry eq "." or $Entry eq ".."); + $Entry =~ m%^([^/]+)$%; # untaint my $FileName = "$DataDir/staging/$1"; my $Age = int((-M $FileName) + 0.5); + my $TTL = $JobPurgeDays ? $JobPurgeDays - $Age : undef;
- if ($Entry !~ /^[0-9a-f]{32}-websubmit_/) + if ($Entry =~ /^[0-9a-f]{32}-websubmit_/) { - if ($Entry !~ /^[0-9a-f]{32}_(?:patch|patch.diff|wine-patches|winetest(?:64)?-latest.exe|work)$/) - { - Trace "Found a suspicious staging file: $Entry\n"; - } - - if ($JobPurgeDays != 0) - { - if ($Age >= $JobPurgeDays + 7) - { - DeletePath($FileName); - } - elsif ($Age > $JobPurgeDays) - { - Error "'$FileName' is $Age days old and should have been deleted already. It will be deleted in ", $JobPurgeDays + 7 - $Age, " day(s).\n"; - } - } + # These files always expire after one day + $TTL = 1 - $Age; } - elsif ($Age >= 1) + elsif ($Entry !~ /^[0-9a-f]{32}_(?:patch|patch.diff|wine-patches|winetest(?:64)?-latest.exe|work)$/) { - # The user abandoned the submit procedure half-way through - DeletePath($FileName); + my $Deletion = defined $TTL ? " (deletion in $TTL days)" : ""; + Error "Found a suspicious file$Deletion: staging/$Entry\n"; } + + DeletePath($FileName) if (defined $TTL and $TTL <= 0); } } else @@ -319,6 +309,11 @@ if (opendir(my $dh, "$DataDir/latest")) next if ($Entry =~ /^TestLauncher[0-9]*.exe$/); next if ($Entry =~ /^winetest[0-9]*-latest.exe$/);
+ $Entry =~ m%^([^/]+)$%; # untaint + my $FileName = "$DataDir/latest/$1"; + my $Age = int((-M $FileName) + 0.5); + my $TTL = $JobPurgeDays ? $JobPurgeDays - $Age : undef; + if ($Entry =~ /^([a-zA-Z0-9_]+)_(?:exe|win|wow)(?:32|64)[a-zA-Z0-9_]*.report(?:.err)?$/) { # Keep the reference WineTest reports for all VMs even if they are @@ -326,22 +321,13 @@ if (opendir(my $dh, "$DataDir/latest")) my $VMName = $1; next if ($AllVMs->GetItem($VMName)); } - - Trace "Found a suspicious latest file: $Entry\n"; - if ($JobPurgeDays != 0) + else { - $Entry =~ m%^([^/]+)$%; # untaint - my $FileName = "$DataDir/latest/$1"; - my $Age = int((-M $FileName) + 0.5); - if ($Age >= $JobPurgeDays + 7) - { - DeletePath($FileName); - } - elsif ($Age > $JobPurgeDays) - { - Trace "'$FileName' will be deleted in ", $JobPurgeDays + 7 - $Age, " day(s).\n"; - } + my $Deletion = defined $TTL ? " (deletion in $TTL days)" : ""; + Error "Found a suspicious file$Deletion: latest/$Entry\n"; } + + DeletePath($FileName) if (defined $TTL and $TTL <= 0); } } else