Git Product home page Git Product logo

django-banish's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-banish's Issues

Internal Server Errors

Occasionally on all sorts of pages I will get this traceback:

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 90, in get_response
    response = middleware_method(request)

  File "/usr/local/lib/python2.7/dist-packages/banish/middleware.py", line 80, in process_request
    if self.is_banned(ip) or self.monitor_abuse(ip) or user_agent in self.BANNED_AGENTS:

  File "/usr/local/lib/python2.7/dist-packages/banish/middleware.py", line 113, in monitor_abuse
    cache.incr(cache_key)

  File "/usr/local/lib/python2.7/dist-packages/django/core/cache/backends/locmem.py", line 81, in incr
    raise ValueError("Key '%s' not found" % key)

ValueError: Key 'DJANGO_BANISH_ABUSE:[ip address here]' not found

Solutions?

django-banish stops working after cache TIMEOUT reached

Steps to reproduce:

  1. Set the default cache timeout to 60s using CACHES argument.
  2. Throw a bunch of abusive traffic at django. (e.g., ab -c 2 -n 1000 http://127.0.0.1:8000/)

Expected results:
After the traffic trips the ABUSE_THRESHOLD, django-banish should respond with 403 for the client

Actual results:
After the traffic trips the ABUSE_THRESHOLD, django-banish responds with 403 for the client until the CACHES TIMEOUT value is reached. Then django-banish forgets that the IP is banished. It allows the requests thru until the same client trips the ABUSE_THRESHOLD again. And repeats this pattern.

BANISH_ABUSE_THRESHOLD for per hour

There is an optional setting BANISH_ABUSE_THRESHOLD for the number of requests per minute. However can I set a per hour threshold and not per minute?

On my django server someone is using a python script to send requests every 5 seconds. This amounts to 12 requests per minute. However setting a threshold to something like ~10 doesn't seem like a very good idea to me.

Another possible solution is can I use this library on requests on specific urls?

Unban without memcached restart?

When I delete banned IP from admin panel I need to restart my memcached server for ativate my changes. Is this normal behavour?
Thanks for your work!

TypeError: __init__() got an unexpected keyword argument 'mimetype'

Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 87, in get_response
response = middleware_method(request)
File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.22.1.20/newrelic/hooks/framework_django.py", line 221, in wrapper
return wrapped(_args, *_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/banish/middleware.py", line 81, in process_request
return HttpResponseForbidden(self.BANISH_MESSAGE, mimetype="text/html")
File "/app/.heroku/python/lib/python2.7/site-packages/django/http/response.py", line 318, in init
super(HttpResponse, self).init(_args, *_kwargs)
TypeError: init() got an unexpected keyword argument 'mimetype'

KeyError: 'HTTP_USER_AGENT'

When no user agent is set it causes unhandled exception:

    self.client.get('/')
  File "/usr/home/mysite/lib/python2.7/site-packages/django/test/client.py", line 453, in get
    response = super(Client, self).get(path, data=data, **extra)
  File "/usr/home/mysite/lib/python2.7/site-packages/django/test/client.py", line 279, in get
    return self.request(**r)
  File "/usr/home/mysite/lib/python2.7/site-packages/django/test/client.py", line 424, in request
    six.reraise(*exc_info)
  File "/usr/home/mysite/lib/python2.7/site-packages/django/core/handlers/base.py", line 92, in get_response
    response = middleware_method(request)
  File "/usr/home/mysite/lib/python2.7/site-packages/banish/middleware.py", line 66, in process_request
    user_agent = request.META['HTTP_USER_AGENT']
KeyError: 'HTTP_USER_AGENT'

Version

Please I need the latest version of django-banish, can you please make that update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.