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

[Xen-devel] [OSSTEST PATCH 08/13] Reporting: Break out report_blessingscond



The returned SQL is a self-contained expression, and does not require
additional bind parameters.  To spot SQL quoting problems, we die if
a blessing is not reasonable.

The use sites of the $blessingcond in sg-report-flight are adjusted to
no longer pass @blessings to execute.

No overall functional change with reasonable blessings.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm |   13 +++++++++++++
 sg-report-flight     |   10 +++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 9df4d91..ba668bc 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -47,6 +47,7 @@ BEGIN {
     @EXPORT      = qw(get_harness_rev grabrepolock_reexec
                       findtask @all_lock_tables
                       report_run_getinfo report_altcolour
+                      report_blessingscond
                       tcpconnect_queuedaemon plan_search
                       alloc_resources alloc_resources_rollback_begin_work
                       resource_check_allocated resource_shared_mark_ready
@@ -246,6 +247,18 @@ sub report_altcolour ($) {
     return "bgcolor=\"#".(qw(d0d0d0 ffffff))[$bool]."\"";
 }
 
+sub report_blessingscond ($$) {
+    my ($blessings, $maxflight) = @_;
+    my $blessingscond= '('.join(' OR ', map {
+       die if m/[^-_.0-9a-z]/;
+       "blessing='$_'"
+                               } @$blessings).')';
+    if (defined $maxflight) {
+       $blessingscond= "( flight <= $maxflight AND $blessingscond )";
+    }
+    return $blessingscond;
+}
+
 #---------- host (and other resource) allocation ----------
 
 our $taskid;
diff --git a/sg-report-flight b/sg-report-flight
index 117b609..c1661ec 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -127,11 +127,7 @@ our $cw= 79;
 our $tl= 20;
 our $htmlleaf= "info.html";
 
-our $blessingscond= '('.join(' OR ', map { "blessing=?" } @blessings).')';
-
-if (defined $maxflight) {
-    $blessingscond= "( flight <= $maxflight AND $blessingscond )";
-}
+our $blessingscond= report_blessingscond(\@blessings, $maxflight);
 
 sub displayflightnum ($) {
     my ($flight) = @_;
@@ -202,7 +198,7 @@ END
       ORDER BY blessing ASC, flight DESC
 END
     $flightsq= db_prepare($flightsq);
-    $flightsq->execute(@flightsq_params, @blessings);
+    $flightsq->execute(@flightsq_params);
 
     my $buildflightsq= db_prepare(<<END);
         SELECT val FROM runvars
@@ -691,7 +687,7 @@ END
             next;
         }
 
-        $anypassq->execute($j->{job}, $s->{testid}, @blessings);
+        $anypassq->execute($j->{job}, $s->{testid});
         if (!$anypassq->fetchrow_hashref()) {
             print MRO "never-passed $j->{job} $s->{testid} $st\n";
             print DEBUG " never passed\n";
-- 
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®.