forked from cherokee/webserver
/
207-RuleExists4.py
47 lines (38 loc) · 1.17 KB
/
207-RuleExists4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from base import *
DIR = 'foo/bar'
FILE = 'file.cgi'
MAGIC = 'Alvaro: http://www.alobbs.com/'
DOMAIN = 'domain_207'
CONF = """
vserver!207!nick = %(DOMAIN)s
vserver!207!document_root = %(droot)s
vserver!207!rule!2!match = exists
vserver!207!rule!2!match!exists = %(FILE)s
vserver!207!rule!2!match!final = 1
vserver!207!rule!2!handler = cgi
vserver!207!rule!1!match = default
vserver!207!rule!1!handler = file
"""
CGI_BASE = """#!/bin/sh
echo "Content-type: text/html"
echo ""
cat << EOF
%s
EOF
"""
class Test (TestBase):
def __init__ (self):
TestBase.__init__ (self, __file__)
self.name = "Rule Exists: match in directory"
self.request = "GET /%s/%s HTTP/1.0\r\n" % (DIR, FILE) + \
"Host: %s\r\n" % (DOMAIN)
self.forbidden_content = ['/bin/sh', 'echo']
self.expected_error = 200
self.expected_content = MAGIC
def Prepare (self, www):
droot = self.Mkdir (www, '207')
e = self.Mkdir (droot, DIR)
self.WriteFile (e, FILE, 0555, CGI_BASE % (MAGIC))
vars = globals()
vars['droot'] = droot
self.conf = CONF % (vars)