Add a domain match filter (~d regex)

This commit is contained in:
Aldo Cortesi 2012-07-06 22:21:44 +12:00
parent c4426952ad
commit d02bcade3a
3 changed files with 16 additions and 2 deletions

View File

@ -992,6 +992,6 @@ class ConsoleMaster(flow.FlowMaster):
f = flow.FlowMaster.handle_response(self, r)
if f:
self.process_flow(f, r)
if self.stream:
self.stream.add(f)
if self.stream:
self.stream.add(f)
return f

View File

@ -182,6 +182,13 @@ class FMethod(_Rex):
return bool(re.search(self.expr, f.request.method, re.IGNORECASE))
class FDomain(_Rex):
code = "d"
help = "Domain"
def __call__(self, f):
return bool(re.search(self.expr, f.request.host, re.IGNORECASE))
class FUrl(_Rex):
code = "u"
help = "URL"
@ -260,6 +267,7 @@ filt_rex = [
FBodResponse,
FBod,
FMethod,
FDomain,
FUrl,
FRequestContentType,
FResponseContentType,

View File

@ -195,6 +195,12 @@ class TestMatching:
q.request.method = "oink"
assert not self.q("~m get", q)
def test_domain(self):
q = self.req()
s = self.resp()
assert self.q("~d host", q)
assert not self.q("~d none", q)
def test_url(self):
q = self.req()
s = self.resp()