improve command detection heuristics

this fixes #3794
This commit is contained in:
Maximilian Hils 2020-01-27 22:44:36 +01:00 committed by GitHub
parent 66fe653063
commit bfcd3ff6ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,9 +149,10 @@ class CommandManager:
if not i.startswith("__"):
o = getattr(addon, i)
try:
is_command = hasattr(o, "command_name")
# hasattr is not enough, see https://github.com/mitmproxy/mitmproxy/issues/3794
is_command = isinstance(getattr(o, "command_name", None), str)
except Exception:
pass # hasattr may raise if o implements __getattr__.
pass # getattr may raise if o implements __getattr__.
else:
if is_command:
try: