[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH] cs-bisection-step: Cope with graph-out (testids) containing ( ) etc.



cr-try-bisect launders / in the testid but relies on other characters
being handled appropriately by cs-bisection-step.  So for example it
can pass

  
graph-out=/home/logs/results/bisect/linux-linus/test-armhf-armhf-xl-arndale.leak-check--basis(8)

But cs-bisection step foolishly assumed that the --graph-out argument
did not contain any shell metacharacters.  Fix this.

Specifically:

 * Change invocations of perl's open to use the 3-argument form
 * Change invocations of system to pass individual arguments rather
   than constructing a shell script fragment and relying on the shell
   to split it up.
 * In particular, in the png processing pipeline, use the "sh -ec
   <script> x <arg>..."  technique to pass the input and output
   filenames in a way that does not expose them to the shell's parser.
   To avoid making this code more tangled than it already is, also
   break out the construction of what is now $scriptlet.
 * Escape metacharacters in the URIs we put in the html output.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 cs-bisection-step |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/cs-bisection-step b/cs-bisection-step
index b676044..ebecda4 100755
--- a/cs-bisection-step
+++ b/cs-bisection-step
@@ -32,6 +32,7 @@ use Data::Dumper;
 no warnings qw(recursion);
 use HTML::Entities;
 use Osstest::Executive;
+use URI::Escape;
 
 our @blessings= qw(real real-bisect);
 our @revtuplegenargs= ();
@@ -945,7 +946,7 @@ sub odot ($) { print DOT $_[0] or die $!; }
 sub writegraph () {
     return unless length $graphfile;
 
-    open DOT, "> $graphfile.dot" or die "$graphfile.dot $!";
+    open DOT, ">", "$graphfile.dot" or die "$graphfile.dot $!";
     
     odot(<<END);
 digraph "$job $testid" {
@@ -1005,8 +1006,9 @@ END
 
     my $href= $graphfile;
     $href =~ s,.*/,,;
+    $href = uri_escape($href, '^-._+,=0-9a-zA-Z');
 
-    open HTML, "> $graphfile.html" or die "$graphfile.html $!";
+    open HTML, ">", "$graphfile.html" or die "$graphfile.html $!";
     print HTML <<END
 <html><head><title>bisection $branch $job $testid</title></head>
 <body>
@@ -1021,17 +1023,20 @@ END
 
     if (eval {
         foreach my $fmt (qw(ps png)) {
-            system_checked("dot -T$fmt -o$graphfile.$fmt $graphfile.dot");
+            system_checked("dot", "-T$fmt", "-o$graphfile.$fmt",
+                          "$graphfile.dot");
         }
         1;
     }) {
        my $gsize = $c{BisectionRevisonGraphSize};
-        system_checked("pngtopnm <$graphfile.png".
-                      " | pnmscale -xysize ".
-                      ($gsize =~ m/^(\d+)x(\d+)$/ ? "$1 $2" :
-                       $gsize =~ m/^(\d+)$/ ? "$1 $1" :
-                       die "$gsize ?").
-                      " | pnmtopng >$graphfile.mini.png");
+       my $scriptlet = 'pngtopnm <$1';
+       $scriptlet .= " | pnmscale -xysize ";
+       $scriptlet .= $gsize =~ m/^(\d+)x(\d+)$/ ? "$1 $2" :
+                     $gsize =~ m/^(\d+)$/ ? "$1 $1" :
+                     die "$gsize ?";
+       $scriptlet .= ' | pnmtopng >$2';
+        system_checked(qw(sh -ec), $scriptlet, 'x',
+                      "$graphfile.png", "$graphfile.mini.png");
         print HTML <<END or die $!;
 <h2>Revision graph overview</h2>
 <img src="$href.mini.png">
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.