xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH] cs-bisection-step: Cope with graph-out (testids) containing ( ) etc.
Date: Mon, 14 Sep 2015 12:17:15 +0100	[thread overview]
Message-ID: <1442229435-27073-1-git-send-email-ian.jackson@eu.citrix.com> (raw)

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@eu.citrix.com>
---
 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

                 reply	other threads:[~2015-09-14 11:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442229435-27073-1-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).