Closed
Bug 348057
Opened 20 years ago
Closed 20 years ago
Move the checks for bug visibility out of Bugzilla::Bug->new
Categories
(Bugzilla :: Bugzilla-General, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.0
People
(Reporter: mkanat, Assigned: mkanat)
References
Details
Attachments
(1 file, 2 obsolete files)
|
15.91 KB,
patch
|
LpSolit
:
review+
|
Details | Diff | Splinter Review |
Right now Bugzilla::Bug->new calls $user->can_see_bug inside of its constructor. Instead, this should happen in the calling code.
Comment 1•20 years ago
|
||
Maybe not in the calling code, because it will miss some checks. We should have a my $bug_object = check_bug($bug_id) where check_bug will make sure you can access the bug and return the bug object on success, as we do in Product.pm (new() vs check_product()). This way, the caller simply has to call check_bug() and we have one central place to do the checks.
| Assignee | ||
Comment 2•20 years ago
|
||
Okay, I checked all of these very carefully, and it turns out that checking whether or not the user could see the bug inside of new() was mostly redundant with calls to ValidateBugID.
Attachment #232947 -
Flags: review?(LpSolit)
| Assignee | ||
Updated•20 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 3•20 years ago
|
||
(In reply to comment #1)
> We should have a my $bug_object = check_bug($bug_id) [snip]
Yeah, I totally agree. I'd have to change all the ValidateBugID calls to that though, and I'd rather do that in a separate bug.
Comment 4•20 years ago
|
||
Comment on attachment 232947 [details] [diff] [review]
v1
You missed some places: 3 more places in process_bug.cgi, 1 in showdependencytree.cgi + 1 in votes.cgi (from memory). Doing a |grep "new Bugzilla::Bug"| will tell you if some still use 2 arguments.
Talking about arguments, you should fix Bug::new() to accept one argument:
if ($#_ == 1) {
Or even remove this check completely (we don't care anymore).
Also, you have to fix Bug::initBug and remove $user_id:
sub initBug {
my $self = shift();
my ($bug_id, $user_id) = (@_);
I didn't check if all validations were still present. I will do that on an updated patch.
Attachment #232947 -
Flags: review?(LpSolit) → review-
| Assignee | ||
Comment 5•20 years ago
|
||
Okay, thanks for catching all that! :-) Here's a new version.
Attachment #232947 -
Attachment is obsolete: true
Attachment #233099 -
Flags: review?(LpSolit)
Comment 6•20 years ago
|
||
Comment on attachment 233099 [details] [diff] [review]
v2
>Index: show_bug.cgi
> foreach (@ids) {
>- my $bug = new Bugzilla::Bug($_, Bugzilla->user->id);
>+ my $bug = new Bugzilla::Bug($_);
>+ # This is basically a backwards-compatibility hack from when
>+ # Bugzilla::Bug->new used to set 'NotPermitted' if you couldn't
>+ # see the bug.
>+ if (!$bug->{error} && !$user->can_see_bug($bug->bug_id)) {
>+ $bug->{error} = 'NotPermitted';
>+ }
> push(@bugs, $bug);
> }
This is definitely dangerous. If the user cannot see the bug, we should put an empty bug or exclude it completely. I checked all 3 templates (show.html, show.xml and show-multiple.html) and I found one data leakage, in show-multiple.html.tmpl:
At line 57, the bug alias is displayed even if you are not allowed to view the bug. To fix the problem, write:
- [% IF Param("usebugaliases") AND bug.alias %]
+ [% IF Param("usebugaliases") AND bug.alias AND NOT bug.error %]
I will attach an updated patch with this line fixed. Else your patch works fine, and all other places are correctly validated. So r=LpSolit with this change above.
Attachment #233099 -
Flags: review?(LpSolit) → review+
Comment 7•20 years ago
|
||
r=me on this one.
Attachment #233099 -
Attachment is obsolete: true
Attachment #233180 -
Flags: review+
Updated•20 years ago
|
Flags: approval?
Updated•20 years ago
|
Flags: approval? → approval+
| Assignee | ||
Comment 8•20 years ago
|
||
Okay, I checked in your patch.
The right fix is to fix the AUTOLOAD in Bug.pm, but we can do that in another bug.
Checking in attachment.cgi;
/cvsroot/mozilla/webtools/bugzilla/attachment.cgi,v <-- attachment.cgi
new revision: 1.120; previous revision: 1.119
done
Checking in editcomponents.cgi;
/cvsroot/mozilla/webtools/bugzilla/editcomponents.cgi,v <-- editcomponents.cginew revision: 1.76; previous revision: 1.75
done
Checking in editflagtypes.cgi;
/cvsroot/mozilla/webtools/bugzilla/editflagtypes.cgi,v <-- editflagtypes.cgi
new revision: 1.46; previous revision: 1.45
done
Checking in editproducts.cgi;
/cvsroot/mozilla/webtools/bugzilla/editproducts.cgi,v <-- editproducts.cgi
new revision: 1.129; previous revision: 1.128
done
Checking in enter_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/enter_bug.cgi,v <-- enter_bug.cgi
new revision: 1.145; previous revision: 1.144
done
Checking in importxml.pl;
/cvsroot/mozilla/webtools/bugzilla/importxml.pl,v <-- importxml.pl
new revision: 1.66; previous revision: 1.65
done
Checking in post_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/post_bug.cgi,v <-- post_bug.cgi
new revision: 1.160; previous revision: 1.159
done
Checking in process_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v <-- process_bug.cgi
new revision: 1.336; previous revision: 1.335
done
Checking in show_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/show_bug.cgi,v <-- show_bug.cgi
new revision: 1.47; previous revision: 1.46
done
Checking in showdependencytree.cgi;
/cvsroot/mozilla/webtools/bugzilla/showdependencytree.cgi,v <-- showdependencytree.cgi
new revision: 1.47; previous revision: 1.46
done
Checking in votes.cgi;
/cvsroot/mozilla/webtools/bugzilla/votes.cgi,v <-- votes.cgi
new revision: 1.46; previous revision: 1.45
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v <-- Bug.pm
new revision: 1.132; previous revision: 1.131
done
Checking in template/en/default/bug/show-multiple.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/bug/show-multiple.html.tmpl,v <-- show-multiple.html.tmpl
new revision: 1.31; previous revision: 1.30
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•