Skip to content

Commit a3e6685

Browse files
committed
Prevent any user from updating public bundles
Currently, the web UI allows any logged in user to remove patches from public bundles. However the correct behaviour is that only the owner of the bundle should be allowed to update a bundle. Fix that by adding checks in set_bundle() before adding or removing patches from bundles. Signed-off-by: Abdun Nihaal <[email protected]> Closes: getpatchwork#599
1 parent 1c3e4d4 commit a3e6685

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

patchwork/views/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ def set_bundle(request, project, action, data, patches):
135135
if not data['bundle_id']:
136136
return ['No bundle was selected']
137137
bundle = get_object_or_404(Bundle, id=data['bundle_id'])
138+
if request.user != bundle.owner:
139+
return ["You don't have permissions to add patches to bundle"]
138140
add_bundle_patches(request, patches, bundle)
139141
elif action == 'remove':
140142
bundle = get_object_or_404(Bundle, id=data['removed_bundle_id'])
143+
if request.user != bundle.owner:
144+
return ["You don't have permissions to remove patches from bundle"]
141145
for patch in patches:
142146
try:
143147
bp = BundlePatch.objects.get(bundle=bundle, patch=patch)

0 commit comments

Comments
 (0)