From: Ian Jackson Subject: [OSSTEST PATCH 11/14] Reporting: Break out report_blessingscond Date: Tue, 30 Jun 2015 10:57:48 +0100 Message-ID: <1435658271-31823-12-git-send-email-ian.jackson@eu.citrix.com> References: <1435658271-31823-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z9sIn-0007RF-Sf for xen-devel@lists.xenproject.org; Tue, 30 Jun 2015 09:58:05 +0000 In-Reply-To: <1435658271-31823-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 Acked-by: Ian Campbell --- 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 eb01fd1..b757618 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 ebb9281..3c360e5 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(<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