From: Jacob Bachmeyer Date: Wed, 28 Jun 2023 01:39:57 +0000 (-0500) Subject: Clean up scaffolding X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9fe680a56170ba574ca4ef0cce1c871a6df3affa;p=gatekeeper.git Clean up scaffolding --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 3c54a7c..dd197a9 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -3259,22 +3259,11 @@ my @packets; foreach my $packet (@packets) { # each list element is an array reference # variables preserved for the report if an exception is thrown - my $directive_text; my $directive; my $oplist; + my $directive_text; my $oplist; my $dsig_info; # directive signature information my $fsig_info; # file signature information my $complete = 0; # direct flag to indicate successful processing - # scaffolding to be cleaned up as the internal API is improved - my $directive_only = not $packet->has_uploaded_file; - my $directive_file = $packet->directive_file_name; - my $upload_file = ''; my $sig_file = ''; - - unless ($directive_only) { - foreach ($packet->files) { - if (m/[.]sig$/) { $sig_file =$_ } else { $upload_file = $_ } - } - } - eval { # trap exceptions encountered while processing a packet local $Phase = 'PS'; @@ -3282,7 +3271,6 @@ foreach my $packet (@packets) { # each list element is an array reference # scaffolding to be cleaned up later $directive_text = $packet->{directive_text}; - $directive = $packet->{directive}; $oplist = $packet->{oplist}; $Phase = 'AA'; @@ -3298,7 +3286,7 @@ foreach my $packet (@packets) { # each list element is an array reference # If the upload carries a file, check it for known Automake CVE issues. check_automake_vulnerabilities (File::Spec->catfile(CONF_DIR_Scratch, $packet->target_filename)) - if find_directive_elements($directive, 'filename'); + if $packet->has_uploaded_file; my @directory = File::Spec::Unix->splitdir($packet->target_directory); @@ -3329,7 +3317,7 @@ foreach my $packet (@packets) { # each list element is an array reference $Phase = 'EX'; # If the upload carries a file, transfer (with signature) to staging area. - if (find_directive_elements($directive, 'filename')) { + if ($packet->has_uploaded_file) { # Do we need a subdirectory on CONF_DIR_Staging as well? Can't quite # picture when we'd have a collision, so skip that for now. move_filepair @@ -3376,11 +3364,12 @@ foreach my $packet (@packets) { # each list element is an array reference if $fsig_info; # report success - if ($directive_only) { - mail "processing of $directive_file complete", + if (not $packet->has_uploaded_file) { + mail 'processing of '.$packet->directive_file_name.' complete', to => \@email_addresses, subject => $packet->target_package; } else { - my @messages = ("upload of $upload_file and $sig_file complete"); + my @messages = + ('upload of '.join(' and ', $packet->target_filepair).' complete'); # add notices stored in the packet object... unshift @messages, $packet->notices, ''; # ...and remove any leading blank lines... @@ -3391,8 +3380,8 @@ foreach my $packet (@packets) { # each list element is an array reference } # unlink the directive file - unlink File::Spec->catfile(CONF_DIR_Scratch, $directive_file) - or warn "unlink($directive_file) failed: $!"; + unlink File::Spec->catfile(CONF_DIR_Scratch, $packet->directive_file_name) + or warn 'unlink('.$packet->directive_file_name.') failed: '.$!; } else { local $Phase = 'RP'; @@ -3498,7 +3487,7 @@ foreach my $packet (@packets) { # each list element is an array reference } # clean up files if we abort while processing a triplet - cleanup ($sig_file, $upload_file, $directive_file) + cleanup ($packet->files) } }