* [OSSTEST PATCH] cs-bisection-step: Cope with graph-out (testids) containing ( ) etc.
@ 2015-09-14 11:17 Ian Jackson
0 siblings, 0 replies; only message in thread
From: Ian Jackson @ 2015-09-14 11:17 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Jackson, Ian Campbell
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-14 11:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14 11:17 [OSSTEST PATCH] cs-bisection-step: Cope with graph-out (testids) containing ( ) etc Ian Jackson
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).