Commit c4c473b9 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 449931: [SECURITY] Unprivileged users can approve/unapprove all the quips…

Bug 449931: [SECURITY] Unprivileged users can approve/unapprove all the quips (including bypassing moderation) - Patch by Robin H. Johnson <robbat2@gentoo.org> r/a=LpSolit
parent bbc78743
...@@ -88,6 +88,11 @@ if ($action eq "add") { ...@@ -88,6 +88,11 @@ if ($action eq "add") {
} }
if ($action eq 'approve') { if ($action eq 'approve') {
$user->in_group('admin')
|| ThrowUserError("auth_failure", {group => "admin",
action => "approve",
object => "quips"});
# Read in the entire quip list # Read in the entire quip list
my $quipsref = $dbh->selectall_arrayref("SELECT quipid, approved FROM quips"); my $quipsref = $dbh->selectall_arrayref("SELECT quipid, approved FROM quips");
...@@ -100,11 +105,18 @@ if ($action eq 'approve') { ...@@ -100,11 +105,18 @@ if ($action eq 'approve') {
my @approved; my @approved;
my @unapproved; my @unapproved;
foreach my $quipid (keys %quips) { foreach my $quipid (keys %quips) {
my $form = $cgi->param('quipid_'.$quipid) ? 1 : 0; # Must check for each quipid being defined for concurrency and
if($quips{$quipid} ne $form) { # automated usage where only one quipid might be defined.
if($form) { push(@approved, $quipid); } my $quip = $cgi->param("quipid_$quipid") ? 1 : 0;
else { push(@unapproved, $quipid); } if(defined($cgi->param("defined_quipid_$quipid"))) {
} if($quips{$quipid} != $quip) {
if($quip) {
push(@approved, $quipid);
} else {
push(@unapproved, $quipid);
}
}
}
} }
$dbh->do("UPDATE quips SET approved = 1 WHERE quipid IN (" . $dbh->do("UPDATE quips SET approved = 1 WHERE quipid IN (" .
join(",", @approved) . ")") if($#approved > -1); join(",", @approved) . ")") if($#approved > -1);
......
...@@ -146,6 +146,8 @@ ...@@ -146,6 +146,8 @@
schedule schedule
[% ELSIF action == "use" %] [% ELSIF action == "use" %]
use use
[% ELSIF action == "approve" %]
approve
[% END %] [% END %]
[% IF object == "administrative_pages" %] [% IF object == "administrative_pages" %]
......
...@@ -124,6 +124,9 @@ ...@@ -124,6 +124,9 @@
</a> </a>
</td> </td>
<td> <td>
<input type="hidden" name="defined_quipid_[% quipid FILTER html %]"
id="defined_quipid_[% quipid FILTER html %]"
value="1">
<input type="checkbox" name="quipid_[% quipid FILTER html %]" <input type="checkbox" name="quipid_[% quipid FILTER html %]"
id="quipid_[% quipid FILTER html %]" id="quipid_[% quipid FILTER html %]"
[%- ' checked="checked"' IF quips.$quipid.approved %]> [%- ' checked="checked"' IF quips.$quipid.approved %]>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment