fix flowfilter.match args

This commit is contained in:
Thomas Kriechbaumer 2016-10-03 12:04:17 +02:00
parent bb60b76af4
commit 36c04f1631
7 changed files with 24 additions and 24 deletions

View File

@ -220,7 +220,7 @@ class Dumper(object):
return False
if not self.filter:
return True
elif flowfilter.match(f, self.filter):
elif flowfilter.match(self.filter, f):
return True
return False

View File

@ -22,6 +22,6 @@ class StickyAuth:
host = flow.request.host
if "authorization" in flow.request.headers:
self.hosts[host] = flow.request.headers["authorization"]
elif flowfilter.match(flow, self.flt):
elif flowfilter.match(self.flt, flow):
if host in self.hosts:
flow.request.headers["authorization"] = self.hosts[host]

View File

@ -64,7 +64,7 @@ class StickyCookie:
def request(self, flow):
if self.flt:
l = []
if flowfilter.match(flow, self.flt):
if flowfilter.match(self.flt, flow):
for domain, port, path in self.jar.keys():
match = [
domain_match(flow.request.host, domain),

View File

@ -126,7 +126,7 @@ class ConsoleState(flow.State):
self.set_focus(self.focus)
return ret
def get_nearest_matching_flow(self, flow, filt):
def get_nearest_matching_flow(self, flow, flt):
fidx = self.view.index(flow)
dist = 1
@ -135,9 +135,9 @@ class ConsoleState(flow.State):
fprev, _ = self.get_from_pos(fidx - dist)
fnext, _ = self.get_from_pos(fidx + dist)
if fprev and flowfilter.match(fprev, filt):
if fprev and flowfilter.match(flt, fprev):
return fprev
elif fnext and flowfilter.match(fnext, filt):
elif fnext and flowfilter.match(flt, fnext):
return fnext
dist += 1
@ -670,14 +670,14 @@ class ConsoleMaster(flow.FlowMaster):
def process_flow(self, f):
should_intercept = any(
[
self.state.intercept and flowfilter.match(f, self.state.intercept) and not f.request.is_replay,
self.state.intercept and flowfilter.match(self.state.intercept, f) and not f.request.is_replay,
f.intercepted,
]
)
if should_intercept:
f.intercept(self)
signals.flowlist_change.send(self)
signals.flow_change.send(self, flow = f)
signals.flow_change.send(self, flow=f)
def clear_events(self):
self.logbuffer[:] = []

View File

@ -56,14 +56,14 @@ class FlowReader:
class FilteredFlowWriter:
def __init__(self, fo, filt):
def __init__(self, fo, flt):
self.fo = fo
self.filt = filt
self.flt = flt
def add(self, f):
if self.filt and not flowfilter.match(f, self.filt):
def add(self, flow):
if self.flt and not flowfilter.match(self.flt, flow):
return
d = f.get_state()
d = flow.get_state()
tnetstring.dump(d, self.fo)

View File

@ -502,7 +502,7 @@ def parse(s):
return None
def match(flow, flt):
def match(flt, flow):
"""
Matches a flow against a compiled filter expression.
Returns True if matched, False if not.

View File

@ -68,14 +68,14 @@ class TestHTTPFlow(object):
def test_match(self):
f = tutils.tflow(resp=True)
assert not flowfilter.match(f, "~b test")
assert flowfilter.match(f, None)
assert not flowfilter.match(f, "~b test")
assert not flowfilter.match("~b test", f)
assert flowfilter.match(None, f)
assert not flowfilter.match("~b test", f)
f = tutils.tflow(err=True)
assert flowfilter.match(f, "~e")
assert flowfilter.match("~e", f)
tutils.raises(ValueError, flowfilter.match, f, "~")
tutils.raises(ValueError, flowfilter.match, "~", f)
def test_backup(self):
f = tutils.tflow()
@ -195,14 +195,14 @@ class TestTCPFlow:
def test_match(self):
f = tutils.ttcpflow()
assert not flowfilter.match(f, "~b nonexistent")
assert flowfilter.match(f, None)
assert not flowfilter.match(f, "~b nonexistent")
assert not flowfilter.match("~b nonexistent", f)
assert flowfilter.match(None, f)
assert not flowfilter.match("~b nonexistent", f)
f = tutils.ttcpflow(err=True)
assert flowfilter.match(f, "~e")
assert flowfilter.match("~e", f)
tutils.raises(ValueError, flowfilter.match, f, "~")
tutils.raises(ValueError, flowfilter.match, "~", f)
class TestState: