コード例 #1
0
ファイル: api.py プロジェクト: jesk78/blacklist
 def __init__(self):
     self.listing = Listing()
     self.whitelisting = WhiteListing()
     self.rule = Rule()
     self.asnum = ASNum()
     self.subnet = Subnet()
     self.rir = RIR()
     self.country = Country()
     self.peering = Peering()
コード例 #2
0
ファイル: listing.py プロジェクト: jesk78/blacklist
def listings(request):
    errmsg = ""

    if "q" in request.GET.keys() and len(request.GET["q"]) != 0:
        s = Search(model=Listing(),
                   fields={
                       "ip": "ip__ip",
                       "reason": "reason__reason",
                       "sensor": "sensor__name",
                       "sensor_host": "sensor_host__hostname",
                       "timestamp": "timestamp",
                       "duration": "duration__duration",
                       "reporter": "reporter",
                   })
        (result, listing_data) = s.find(request.GET["q"])
        if not result:
            errmsg = listing_data,
            (result, listing_data) = listing.all()
    else:
        (result, listing_data) = listing.all()
        if not result: return HttpResponseRedirect("/")

    try:
        page = int(request.GET.get('page', '1'))
    except:
        page = 1

    listing_table = ListingTable(listing_data,
                                 order_by=request.GET.get('sort', 'title'))

    if request.method == "GET":
        search_form = SearchForm(request.GET)
    else:
        search_form = SearchForm()

    return render_to_response("listing/overview.html", {
        "errmsg": errmsg,
        "search_form": search_form,
        "listing_table": listing_table,
    },
                              context_instance=RequestContext(request))
コード例 #3
0
ファイル: bl-cli.py プロジェクト: jesk78/blacklist
#!/usr/bin/env python

import socket
import sys
import os

sys.path.append("/www/blacklist/app")
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"

from blacklist.middleware.listing		import Listing
from blacklist.middleware.whitelisting	import WhiteListing

listing = Listing()
whitelisting = WhiteListing()

def help():
	print "Usage: %s (listing|whitelisting) (add|del|list) [<value>]" % (os.path.basename(sys.argv[0]))
	print ""
	print "Examples:"
	print "* listing add 192.0.2.1 reason someuser"
	print "* listing add 192.0.2.0/24 reason someuser"
	print "* listing del 192.0.2.1"
	print "* listing list"
	print "* whitelisting add 192.0.2.1 host.example.com someuser"
	print "* whitelisting add 192.0.2.0/24 net.example.com someuser"
	print "* whitelisting del 192.0.2.1"
	print "* whitelisting list"
	sys.exit(1)

if __name__ == "__main__":
	if not len(sys.argv) in range(3,7):