Adds support to Python scripts on ModSecurity core.

Analog of what we have for Lua, Python support is now added by this commit.
This is very experimental.
This commit is contained in:
Felipe Zimmerle
2014-08-26 07:18:57 -07:00
parent c17bf6ad42
commit 2440a23921
18 changed files with 903 additions and 18 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from modsecurity import ModSecurity
class ModSecurityExtension(ModSecurity):
def process(self):
self.log(8, "Python test message.")
return False
if __name__ == "__main__":
myExtension = ModSecurityExtension()
# Process the content.
ret = myExtension.process()
if ret == True:
print("Matched!")
else:
print("_not_ matched")

View File

@@ -0,0 +1,24 @@
### Test for SecRuleScript
# Python
{
type => "rule",
comment => "SecRuleScript (Python match)",
conf => qq(
SecRuleEngine On
SecDebugLog $ENV{DEBUG_LOG}
SecDebugLogLevel 9
SecRuleScript "script.py" "phase:2,deny"
),
match_log => {
-error => [ qr/Python script matched\./, 1 ],
debug => [ qr/Python test message\./, 1 ],
},
match_response => {
status => qr/^200$/,
},
request => new HTTP::Request(
GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt?foo=bar&foo2=bar2",
),
}

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from modsecurity import ModSecurity
class ModSecurityExtension(ModSecurity):
def process(self):
self.log(8, "Python test message.")
return False
if __name__ == "__main__":
myExtension = ModSecurityExtension()
# Process the content.
ret = myExtension.process()
if ret == True:
print("Matched!")
else:
print("_not_ matched")