Merge lp:~stevenk/launchpad/link-branch-to-private-bug into lp:launchpad

Proposed by Steve Kowalik
Status: Rejected
Rejected by: Steve Kowalik
Proposed branch: lp:~stevenk/launchpad/link-branch-to-private-bug
Merge into: lp:launchpad
Diff against target: 114 lines (+32/-9)
3 files modified
lib/lp/bugs/model/bug.py (+3/-0)
lib/lp/bugs/model/bugbranch.py (+12/-4)
lib/lp/bugs/tests/test_bugbranch.py (+17/-5)
To merge this branch: bzr merge lp:~stevenk/launchpad/link-branch-to-private-bug
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Review via email: mp+71508@code.launchpad.net

Description of the change

When a branch is linked to a private bug, the branch should be made private too.

Clean up a bunch of lint too.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

So, this is problematic because it will grant private branches (a commercial feature) to anything that has security bugs.

It also doesn't require a security policy, which I suspect will make other parts of LP fall over in a heap.

-> I think this needs more consideration, specifically around the cases for how these things should interact.

Revision history for this message
Robert Collins (lifeless) wrote :

Oh, and it will also violate an existing axiom:
 - public branches can never become private

And will be surprising for folk that have toggle a branch public explicitly to have it become private when *anyone* links it to a private bug.

I'm 'upgrading' my review to needs-fixing (and I think it needs design level fixing, not a small matter of code).

review: Needs Fixing

Unmerged revisions

13688. By Steve Kowalik

Make the branch private if the bug is when linking the two together, and lint.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2011-08-01 05:56:43 +0000
+++ lib/lp/bugs/model/bug.py 2011-08-15 06:09:25 +0000
@@ -1275,6 +1275,9 @@
1275 if bug_branch.branch == branch:1275 if bug_branch.branch == branch:
1276 return bug_branch1276 return bug_branch
12771277
1278 # If the bug is private, we should make the branch private too.
1279 if self.private:
1280 removeSecurityProxy(branch).private = True
1278 bug_branch = BugBranch(1281 bug_branch = BugBranch(
1279 branch=branch, bug=self, registrant=registrant)1282 branch=branch, bug=self, registrant=registrant)
1280 branch.date_last_modified = UTC_NOW1283 branch.date_last_modified = UTC_NOW
12811284
=== modified file 'lib/lp/bugs/model/bugbranch.py'
--- lib/lp/bugs/model/bugbranch.py 2011-05-27 21:12:25 +0000
+++ lib/lp/bugs/model/bugbranch.py 2011-08-15 06:09:25 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4# pylint: disable-msg=E0611,W02124# pylint: disable-msg=E0611,W0212
@@ -7,8 +7,10 @@
77
8__metaclass__ = type8__metaclass__ = type
99
10__all__ = ["BugBranch",10__all__ = [
11 "BugBranchSet"]11 "BugBranch",
12 "BugBranchSet"
13 ]
1214
13from sqlobject import (15from sqlobject import (
14 ForeignKey,16 ForeignKey,
@@ -24,6 +26,7 @@
24 )26 )
25from zope.component import getUtility27from zope.component import getUtility
26from zope.interface import implements28from zope.interface import implements
29from zope.security.interfaces import Unauthorized
2730
28from canonical.database.constants import UTC_NOW31from canonical.database.constants import UTC_NOW
29from canonical.database.datetimecol import UtcDateTimeCol32from canonical.database.datetimecol import UtcDateTimeCol
@@ -82,7 +85,12 @@
82 from lp.bugs.model.bug import Bug85 from lp.bugs.model.bug import Bug
83 from lp.bugs.model.bugsubscription import BugSubscription86 from lp.bugs.model.bugsubscription import BugSubscription
8487
85 branch_ids = [branch.id for branch in branches]88 branch_ids = []
89 for branch in branches:
90 try:
91 branch_ids.append(branch.id)
92 except Unauthorized:
93 continue # User has no permission for this branch.
86 if branch_ids == []:94 if branch_ids == []:
87 return []95 return []
8896
8997
=== modified file 'lib/lp/bugs/tests/test_bugbranch.py'
--- lib/lp/bugs/tests/test_bugbranch.py 2011-02-10 14:42:11 +0000
+++ lib/lp/bugs/tests/test_bugbranch.py 2011-08-15 06:09:25 +0000
@@ -20,6 +20,7 @@
20from lp.testing import (20from lp.testing import (
21 anonymous_logged_in,21 anonymous_logged_in,
22 celebrity_logged_in,22 celebrity_logged_in,
23 person_logged_in,
23 TestCaseWithFactory,24 TestCaseWithFactory,
24 )25 )
2526
@@ -46,7 +47,6 @@
46 branch_1 = self.factory.makeBranch()47 branch_1 = self.factory.makeBranch()
47 branch_2 = self.factory.makeBranch()48 branch_2 = self.factory.makeBranch()
48 bug_a = self.factory.makeBug()49 bug_a = self.factory.makeBug()
49 bug_b = self.factory.makeBug()
50 self.factory.loginAsAnyone()50 self.factory.loginAsAnyone()
51 bug_a.linkBranch(branch_1, self.factory.makePerson())51 bug_a.linkBranch(branch_1, self.factory.makePerson())
52 bug_a.linkBranch(branch_2, self.factory.makePerson())52 bug_a.linkBranch(branch_2, self.factory.makePerson())
@@ -120,15 +120,17 @@
120 def test_getBranchesWithVisibleBugs_shows_private_bugs_to_sub(self):120 def test_getBranchesWithVisibleBugs_shows_private_bugs_to_sub(self):
121 # getBranchesWithVisibleBugs will show private bugs to their121 # getBranchesWithVisibleBugs will show private bugs to their
122 # subscribers.122 # subscribers.
123 branch = self.factory.makeBranch()123 user = self.factory.makePerson()
124 branch = self.factory.makeBranch(owner=user)
124 bug = self.factory.makeBug(private=True)125 bug = self.factory.makeBug(private=True)
125 user = self.factory.makePerson()
126 with celebrity_logged_in('admin'):126 with celebrity_logged_in('admin'):
127 bug.subscribe(user, self.factory.makePerson())127 bug.subscribe(user, self.factory.makePerson())
128 bug.linkBranch(branch, self.factory.makePerson())128 bug.linkBranch(branch, self.factory.makePerson())
129 utility = getUtility(IBugBranchSet)129 utility = getUtility(IBugBranchSet)
130 self.assertContentEqual(130 with person_logged_in(user):
131 [branch.id], utility.getBranchesWithVisibleBugs([branch], user))131 self.assertContentEqual(
132 [branch.id],
133 utility.getBranchesWithVisibleBugs([branch], user))
132134
133 def test_getBugBranchesForBugTasks(self):135 def test_getBugBranchesForBugTasks(self):
134 # IBugBranchSet.getBugBranchesForBugTasks returns all of the BugBranch136 # IBugBranchSet.getBugBranchesForBugTasks returns all of the BugBranch
@@ -264,3 +266,13 @@
264 self.factory.loginAsAnyone()266 self.factory.loginAsAnyone()
265 bug.linkBranch(branch, self.factory.makePerson())267 bug.linkBranch(branch, self.factory.makePerson())
266 self.assertTrue(bug.date_last_updated > last_updated)268 self.assertTrue(bug.date_last_updated > last_updated)
269
270 def test_linking_branch_to_private_bug_makes_branch_private(self):
271 # Linking a branch to a private bug forces the branch to be private.
272 reporter = self.factory.makePerson()
273 bug = self.factory.makeBug(private=True, owner=reporter)
274 product = self.factory.makeProduct()
275 branch = self.factory.makeBranch(owner=reporter, product=product)
276 with person_logged_in(reporter):
277 bug.linkBranch(branch, reporter)
278 self.assertTrue(branch.private)