Author: geissert
Date: 2017-10-18 14:45:39 +0000 (Wed, 18 Oct 2017)
New Revision: 56822

Modified:
   bin/check-new-issues
Log:
move the presenting/editing loop logic into its own function


Modified: bin/check-new-issues
===================================================================
--- bin/check-new-issues        2017-10-18 14:07:19 UTC (rev 56821)
+++ bin/check-new-issues        2017-10-18 14:45:39 UTC (rev 56822)
@@ -269,26 +269,37 @@
 
 $attribs->{attempted_completion_function} = \&initial_completion;
 
-TODO: foreach my $todo (reverse sort @todos) {
-       print ${$data->{$todo}->{CVE}} if $data->{$todo}->{CVE};
-       print ${$data->{$todo}->{entry}};
+foreach my $todo (reverse sort @todos) {
+       last unless present_issue($todo);
+}
 
-       if ($data->{$todo}->{CVE}) {
-               my $nfu_entry = auto_nfu($todo);
+open(my $fh, ">", $datafile);
+print $fh @{$entries};
+close($fh);
+
+sub present_issue {
+       my $name = shift;
+       my $quit = 0;
+
+       print ${$data->{$name}->{CVE}} if $data->{$name}->{CVE};
+       print ${$data->{$name}->{entry}};
+
+       if ($data->{$name}->{CVE}) {
+               my $nfu_entry = auto_nfu($name);
                if ($nfu_entry) {
-                       ${$data->{$todo}->{entry}} =~
+                       ${$data->{$name}->{entry}} =~
                                s/^\s*TODO: check/\tNOT-FOR-US: $nfu_entry/m ;
-                               print "New entry auto set to set 
to:\n${$data->{$todo}->{entry}}";
-                               next TODO;
+                               print "New entry auto set to set 
to:\n${$data->{$name}->{entry}}";
+                               return 1;
                }
        }
 
-       auto_search($todo);
+       auto_search($name);
        
     READ: while (my $r=$term->readline(">") ) {
                chomp $r;
                if ($r =~ /^\s*$/) {
-                       next TODO;
+                       last READ;
                }
                elsif ($r=~ /^\.c(.*)$/ ) {
                        my $s = $1;
@@ -333,18 +344,19 @@
                        next READ;
                }
                elsif ($r=~ /^q\s?$/i ) {
-                       last TODO;
+                       $quit = 1;
+                       last READ;
                }
                elsif ($r=~ /^[ve]\s?$/i ) {
-                       my $newentry=edit_entry(${$data->{$todo}->{entry}});
-                       if ( $newentry eq ${$data->{$todo}->{entry}} ) {
+                       my $newentry=edit_entry(${$data->{$name}->{entry}});
+                       if ( $newentry eq ${$data->{$name}->{entry}} ) {
                                print "Not changed.\n";
                                next READ;
                        }
                        else {
-                               ${$data->{$todo}->{entry}}=$newentry;
+                               ${$data->{$name}->{entry}}=$newentry;
                                print "New entry set to:\n$newentry";
-                               next TODO;
+                               last READ;
                        }
                }
                elsif ($r=~ /^(\-\s+.+)$/ ) {
@@ -353,7 +365,7 @@
                                unless (scalar(@comps)>2);
                        my $inputentry = join(' ', @comps);
 
-                       my $preventry=${$data->{$todo}->{entry}};
+                       my $preventry=${$data->{$name}->{entry}};
                        $preventry =~
                                s/^\s+/\t$inputentry\n$&/m ;
 
@@ -363,31 +375,29 @@
                        }
 
                        my $newentry=edit_entry($preventry);
-                       ${$data->{$todo}->{entry}}=$newentry;
+                       ${$data->{$name}->{entry}}=$newentry;
                        print "New entry set to:\n$newentry";
-                       next TODO;
+                       last READ;
                }
                elsif ($r=~ /^\.r(.*)$/ ) {
                        my $tmp=new File::Temp();
                        my $tmpname=$tmp->filename;
-                       system("$basedir/bin/report-vuln $1 $todo > $tmpname");
+                       system("$basedir/bin/report-vuln $1 $name > $tmpname");
                        system("$editor $tmpname");
                        close($tmp);
                        next READ;
                }
                else {
-                       ${$data->{$todo}->{entry}} =~
+                       ${$data->{$name}->{entry}} =~
                                s/^\s*TODO: check/\tNOT-FOR-US: $r/m ;
-                               print "New entry set 
to:\n${$data->{$todo}->{entry}}";
-                       next TODO;
+                               print "New entry set 
to:\n${$data->{$name}->{entry}}";
+                       last READ;
                }
        }
+
+       return (!$quit);
 }
 
-open(my $fh, ">", $datafile);
-print $fh @{$entries};
-close($fh);
-
 sub description {
        my $name=shift;
 


_______________________________________________
Secure-testing-commits mailing list
Secure-testing-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/secure-testing-commits

Reply via email to