mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
Merge pull request #2833 from mitmproxy/issue-2824
Improve error message for missing scripts, fix #2824
This commit is contained in:
commit
6d8731e144
2 changed files with 16 additions and 2 deletions
|
|
@ -44,13 +44,15 @@ class Script:
|
|||
def __init__(self, path):
|
||||
self.name = "scriptmanager:" + path
|
||||
self.path = path
|
||||
self.fullpath = os.path.expanduser(path)
|
||||
self.fullpath = os.path.expanduser(
|
||||
path.strip("'\" ")
|
||||
)
|
||||
self.ns = None
|
||||
|
||||
self.last_load = 0
|
||||
self.last_mtime = 0
|
||||
if not os.path.isfile(self.fullpath):
|
||||
raise exceptions.OptionsError("No such script: %s" % path)
|
||||
raise exceptions.OptionsError('No such script: "%s"' % self.fullpath)
|
||||
|
||||
@property
|
||||
def addons(self):
|
||||
|
|
|
|||
|
|
@ -68,6 +68,18 @@ class TestScript:
|
|||
with pytest.raises(exceptions.OptionsError):
|
||||
script.Script("nonexistent")
|
||||
|
||||
def test_quotes_around_filename(self):
|
||||
"""
|
||||
Test that a script specified as '"foo.py"' works to support the calling convention of
|
||||
mitmproxy 2.0, as e.g. used by Cuckoo Sandbox.
|
||||
"""
|
||||
path = tutils.test_data.path("mitmproxy/data/addonscripts/recorder/recorder.py")
|
||||
|
||||
s = script.Script(
|
||||
'"{}"'.format(path)
|
||||
)
|
||||
assert '"' not in s.fullpath
|
||||
|
||||
def test_simple(self):
|
||||
with taddons.context() as tctx:
|
||||
sc = script.Script(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue