Login

Tag "whitelist"

Snippet List

Whitelisted overwriting FileSystemStorage

**Description** A filestorage system that + is whitlisted, + changes the file name and targeting directory to put the file in - with respect to (runtime) instance information. + replaces files if they exists with the same name. Kudos to [jedie](http://djangosnippets.org/users/jedie/) - http://djangosnippets.org/snippets/977/

  • forms
  • filefield
  • whitelist
  • filestorage
  • overwrite
  • file-extension
Read More

Sanitize HTML filter with tag/attribute whitelist and XSS protection

Reworked version of [this snippet](http://www.djangosnippets.org/snippets/205/) that now accepts an argument so the user can specify which tags to allow, and which attributes should be allowed for each tag. Argument should be in form `tag2:attr1:attr2 tag2:attr1 tag3`, where tags are allowed HTML tags, and attrs are the allowed attributes for that tag. It also uses code from [this post on stack overflow](http://stackoverflow.com/questions/16861/sanitising-user-input-using-python) to add XSS protection.

  • html
  • security
  • sanitize
  • whitelist
Read More

Test IP against IP address+Subnet whitelist

Simple function that tests whether a given IP address is in a list of IP addresses or subnets. Requires `ipaddr`. Comes with Python 2.7 or 3.1, [downloadable here](http://code.google.com/p/ipaddr-py/) for earlier versions. More info on `ipaddr` [in Python 3.1 docs](http://docs.python.org/dev/py3k/library/ipaddr.html).

  • ip-address
  • whitelist
  • ipaddr
  • subnet
Read More

Restrict Middleware

This is a _very basic_, _easily foolable_, restriction method implemented in a Django middleware. However, for low security sites that need a cursory barrier to entry (without the ability to assign/administer user accounts), this does very well. All of the features are fairly well-documented in the code.

  • whitelist
  • restrict
  • reject
Read More

4 snippets posted so far.