Use a form for Block Deletion

quicksketch - May 19, 2008 - 00:00
Project:MultiBlock
Version:5.x-1.0
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

Right now the delete block instance form is simply a menu callback. This means that there isn't any warning at all to prevent a user from accidentally deleting a block instance. It also makes the block instances vulnerable to Cross-site Request Forgery attacks (aka CSRF attacks). Meaning that a malicious site that an administrator visits while logged into the Drupal site could delete block instances simply by requesting the delete block URLs.

Adding a confirmation form prevents this problem by adding the security of form_tokens.

This patch adds such a form, and provides a central API function for getting all the blocks defined by multiblock (multiblock_get_block).

AttachmentSize
multiblock-delete.patch5.68 KB

#1

quicksketch - May 21, 2008 - 05:21

This updated patch adds the $reset flag to the multiblock_get_block_list() function and call it from the hook_block() implementation. This makes it so that if _block_rehash() is called a second time in one page load, a new list of blocks is returned instead of the cached version.

AttachmentSize
multiblock-delete.patch 5.83 KB

#2

andrewlevine - May 28, 2008 - 21:22

quicksketch,

These are good changes. I made a couple modifications, let me know if this is acceptable to you and I'll commit it.

1. I removed multiblock_get_block_list() because it is only a few lines and I'm not sure it would be used anywhere else
2. I set $reset of multiblock_get_block() to FALSE in hook_block because this is where we would gain any performance from saving in a static variable
3. I set $reset of multiblock_get_block() to TRUE in multiblock_general because we need the most up to date information for the admin to see and the admin for will rarely be used

I think that's all I changed in the patch, let me know.

AttachmentSize
multiblock-delete.patch 5.61 KB

#3

quicksketch - May 28, 2008 - 22:24
Status:needs review» reviewed & tested by the community

This all looks great to me. That's fine that the reset flag has been switched around from my original patch, I'm probably in a bit of a strange situation where I'm manually calling _block_rehash() in my module that depends on Multiblock. I can easily call multiblock_get_block(NULL, TRUE) to reset the list manually before calling my own _block_rehash. Tested this all out and it looks just fine.

#4

andrewlevine - May 29, 2008 - 05:03
Status:reviewed & tested by the community» fixed

committed, thanks so much for the patch.

#5

Anonymous (not verified) - June 12, 2008 - 05:14
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.