aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/addons
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-11-18 22:03:51 +0100
committerMaximilian Hils <git@maximilianhils.com>2019-11-18 22:03:51 +0100
commit74f5fa6a7736f116416c242b159e6b0525e6fe5b (patch)
tree0c90e441aea082e91ee9b864f3c98363e1232927 /mitmproxy/addons
parent7bf06f8ae04697305731ec89a43ebea6da4376b8 (diff)
downloadmitmproxy-74f5fa6a7736f116416c242b159e6b0525e6fe5b.tar.gz
mitmproxy-74f5fa6a7736f116416c242b159e6b0525e6fe5b.tar.bz2
mitmproxy-74f5fa6a7736f116416c242b159e6b0525e6fe5b.zip
wip
Diffstat (limited to 'mitmproxy/addons')
-rw-r--r--mitmproxy/addons/core.py17
-rw-r--r--mitmproxy/addons/view.py26
2 files changed, 21 insertions, 22 deletions
diff --git a/mitmproxy/addons/core.py b/mitmproxy/addons/core.py
index 1fbeb1e0..55e2e129 100644
--- a/mitmproxy/addons/core.py
+++ b/mitmproxy/addons/core.py
@@ -83,15 +83,15 @@ class Core:
)
@command.command("set")
- def set(self, *options: str) -> None:
+ def set(self, option: str, *value: str) -> None:
"""
- Set an option of the form "key[=value]". When the value is omitted,
- booleans are set to true, strings and integers are set to None (if
- permitted), and sequences are emptied. Boolean values can be true,
- false or toggle. If multiple specs are passed, they are joined
- into one separated by spaces.
+ Set an option. When the value is omitted, booleans are set to true,
+ strings and integers are set to None (if permitted), and sequences
+ are emptied. Boolean values can be true, false or toggle.
+ Multiple values are concatenated with a single space.
"""
- strspec = " ".join(options)
+ value = " ".join(value)
+ strspec = f"{option}={value}"
try:
ctx.options.set(strspec)
except exceptions.OptionsError as e:
@@ -168,8 +168,7 @@ class Core:
"reason",
]
- @command.command(
- "flow.set")
+ @command.command("flow.set")
@command.argument("attr", type=mitmproxy.types.Choice("flow.set.options"))
def flow_set(
self,
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py
index c57c34c8..1d57d781 100644
--- a/mitmproxy/addons/view.py
+++ b/mitmproxy/addons/view.py
@@ -298,16 +298,16 @@ class View(collections.abc.Sequence):
# Filter
@command.command("view.filter.set")
- def set_filter_cmd(self, filtstr: str) -> None:
+ def set_filter_cmd(self, filter_expr: str) -> None:
"""
Sets the current view filter.
"""
filt = None
- if filtstr:
- filt = flowfilter.parse(filtstr)
+ if filter_expr:
+ filt = flowfilter.parse(filter_expr)
if not filt:
raise exceptions.CommandError(
- "Invalid interception filter: %s" % filtstr
+ "Invalid interception filter: %s" % filter_expr
)
self.set_filter(filt)
@@ -412,26 +412,26 @@ class View(collections.abc.Sequence):
ctx.log.alert("Removed %s flows" % len(flows))
@command.command("view.flows.resolve")
- def resolve(self, flowspec: str) -> typing.Sequence[mitmproxy.flow.Flow]:
+ def resolve(self, flow_spec: str) -> typing.Sequence[mitmproxy.flow.Flow]:
"""
Resolve a flow list specification to an actual list of flows.
"""
- if flowspec == "@all":
+ if flow_spec == "@all":
return [i for i in self._store.values()]
- if flowspec == "@focus":
+ if flow_spec == "@focus":
return [self.focus.flow] if self.focus.flow else []
- elif flowspec == "@shown":
+ elif flow_spec == "@shown":
return [i for i in self]
- elif flowspec == "@hidden":
+ elif flow_spec == "@hidden":
return [i for i in self._store.values() if i not in self._view]
- elif flowspec == "@marked":
+ elif flow_spec == "@marked":
return [i for i in self._store.values() if i.marked]
- elif flowspec == "@unmarked":
+ elif flow_spec == "@unmarked":
return [i for i in self._store.values() if not i.marked]
else:
- filt = flowfilter.parse(flowspec)
+ filt = flowfilter.parse(flow_spec)
if not filt:
- raise exceptions.CommandError("Invalid flow filter: %s" % flowspec)
+ raise exceptions.CommandError("Invalid flow filter: %s" % flow_spec)
return [i for i in self._store.values() if filt(i)]
@command.command("view.flows.create")