diff --git a/extensions/WeeklyReport/component-report.cgi b/extensions/WeeklyReport/component-report.cgi index e51cb48..6a694ea 100755 --- a/extensions/WeeklyReport/component-report.cgi +++ b/extensions/WeeklyReport/component-report.cgi @@ -50,6 +50,7 @@ use Bugzilla; use Bugzilla::Product; use Bugzilla::Constants; use Bugzilla::Error; +use Bugzilla::Util; use vars qw($vars $template); @@ -69,7 +70,7 @@ my $user = Bugzilla->login(LOGIN_OPTIONAL); print $cgi->header(-type => 'text/html', -expires => '+3M'); my $query = <dbh->prepare($query); -my $product = $cgi->param('product'); -if ($product =~ /^([\w.-\s]+)$/) { $product = $1 } +my $product = trim($cgi->param('product')); + +# FIXME: Print a "error" message +ThrowUserError('product_blank_name') if !$product; + +if ($product =~ m/^([\w.-]+)$/) { $product = $1; } +trick_taint($product); $sth->execute($product); my (@bug_counts, %bugs, %total_bugs); @@ -92,6 +98,7 @@ my $disp_component; my $total_bug_count; my $product_obj = new Bugzilla::Product({ 'name' => $product }); +ThrowUserError('invalid_product_name', {product => $product}) if !$product_obj; $vars->{'product'} = $product; $vars->{'all_severities'} = Bugzilla::Field::get_legal_field_values('bug_severity'); @@ -110,4 +117,3 @@ $vars->{'bug_sev_counts'} = \%bugs; $template->process("weeklyreport/component-report.html.tmpl", $vars) || ThrowTemplateError($template->error()); - diff --git a/extensions/WeeklyReport/weekly-bug-summary.cgi b/extensions/WeeklyReport/weekly-bug-summary.cgi index f1649ed..65d4388 100755 --- a/extensions/WeeklyReport/weekly-bug-summary.cgi +++ b/extensions/WeeklyReport/weekly-bug-summary.cgi @@ -13,10 +13,10 @@ use Bugzilla::Util; use Bugzilla::Error; use Bugzilla::Field; -sub total_bugs_in_bugzilla() -{ - my $dbh = Bugzilla->dbh; +Bugzilla->login(LOGIN_OPTIONAL); +sub total_bugs_in_bugzilla() { + my $dbh = Bugzilla->dbh; # figure out total bugs my (@totalbugs) = $dbh->selectrow_array( "SELECT count(bugs.bug_id) FROM bugs WHERE bugs.bug_severity != 'enhancement' AND @@ -34,8 +34,7 @@ sub total_bugs_in_bugzilla() return ($totalbugs[0], $totalwishes[0]); } -sub bugs_opened() -{ +sub bugs_opened() { my($product, $days) = @_; my $sqlproduct = ""; @@ -51,8 +50,7 @@ sub bugs_opened() return $count; } -sub wishes_opened() -{ +sub wishes_opened() { my($product, $days) = @_; my $sqlproduct = ""; @@ -68,8 +66,7 @@ sub wishes_opened() return $count; } -sub bugs_closed() -{ +sub bugs_closed() { my($product, $days) = @_; my $query = ""; my $sqlproduct = ""; @@ -84,7 +81,7 @@ from where bugs.bug_severity != 'enhancement' AND (bugs_activity.added='RESOLVED' or bugs_activity.added='CLOSED' or - bugs_activity.added='NEEDSINFO') + bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED') and bugs_activity.bug_when >= FROM_DAYS(TO_DAYS(NOW())-?) and @@ -95,8 +92,7 @@ and return($count); } -sub wishes_closed() -{ +sub wishes_closed() { my($product, $days) = @_; my $query = ""; my $sqlproduct = ""; @@ -112,7 +108,7 @@ from where bugs.bug_severity = 'enhancement' AND (bugs_activity.added='RESOLVED' or bugs_activity.added='CLOSED' or - bugs_activity.added='NEEDSINFO') + bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED') and bugs_activity.bug_when >= FROM_DAYS(TO_DAYS(NOW())-?) and @@ -123,8 +119,7 @@ and return($count); } -sub open_wishes() -{ +sub open_wishes() { my($product) = @_; my $sqlproduct = ""; @@ -185,7 +180,6 @@ limit $number $product_id{$product} = $p_id; } - foreach my $product (reverse sort {$product_count{$a} <=> $product_count{$b}} keys (%product_count)) { @@ -231,7 +225,7 @@ from bugs, bugs_activity, profiles assign where (bugs_activity.added='RESOLVED' or bugs_activity.added = 'CLOSED' or - bugs_activity.added='NEEDSINFO') + bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED') and bugs_activity.bug_when >= from_days(TO_DAYS(NOW()) - ?) and @@ -239,7 +233,8 @@ and and bugs.bug_id = bugs_activity.bug_id and - (bugs.bug_status = 'RESOLVED' or bugs.bug_status = 'CLOSED') + (bugs.bug_status = 'RESOLVED' or bugs.bug_status = 'CLOSED' or + bugs_activity.added='VERIFIED') group by assign.login_name order by n desc limit ? @@ -291,7 +286,7 @@ AND AND longdescs.who = bugs_activity.who AND - longdescs.thetext like \"%change APPROVED and MERGED%\" + longdescs.thetext like \"%merged by jenkins-bot%" GROUP BY profiles.login_name, bugs.bug_id ORDER BY @@ -321,9 +316,6 @@ LIMIT ?"); return \@results; } - -Bugzilla->login(LOGIN_OPTIONAL); - # For most scripts we don't make $cgi and $template global variables. But # when preparing Bugzilla for mod_perl, this script used these # variables in so many subroutines that it was easier to just @@ -380,9 +372,4 @@ $vars->{'bug_fixers_list'} = &print_bug_fixers_list($current_tops, $current_days $template->process("weeklyreport/weekly-bug-summary.html.tmpl", $vars) || ThrowTemplateError($template->error()); - - - - print "\n"; -