diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-07-25 21:55:26 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-07-25 21:55:26 +0200 |
commit | 3262b6e70510e3fd78c512ee79fcb8eb35d371ba (patch) | |
tree | 228267a8881ffafd5194f8360eebaa1771843baa | |
parent | 2868a0808ab272900c71b8d0d79a3ac11ff48fe6 (diff) | |
download | mitmproxy-3262b6e70510e3fd78c512ee79fcb8eb35d371ba.tar.gz mitmproxy-3262b6e70510e3fd78c512ee79fcb8eb35d371ba.tar.bz2 mitmproxy-3262b6e70510e3fd78c512ee79fcb8eb35d371ba.zip |
Squashed commit of the following:
commit edfbd41200a854f0bb7bb99f8bb70af9dbb9b8e0
Author: Matt Weidner <matt.weidner@gmail.com>
Date: Tue Jul 25 01:19:53 2017 -0500
Extended view.load test to check for unhandled IOError exception.
commit a523b534bc59ea97ed1fd5a3e6f78112fee19b6f
Author: requires.io <support@requires.io>
Date: Mon Jul 24 21:25:04 2017 +0200
[requires.io] dependency update
commit c725540c6eb92c003616b649ba43bee1f14e56ac
Author: Thomas Kriechbaumer <thomas@kriechbaumer.name>
Date: Mon Jul 24 21:01:25 2017 +0200
update travis
commit eeb6cfb4c76e60ac1813b839f589cd489c041c6c
Author: Thomas Kriechbaumer <Kriechi@users.noreply.github.com>
Date: Mon Jul 24 21:03:14 2017 +0200
[requires.io] dependency update on master branch (#2435)
commit 51a2672c782ee8ba8c7d5c7116073feccb4d8430
Author: Maximilian Hils <git@maximilianhils.com>
Date: Mon Jul 24 19:03:01 2017 +0200
require latest mypy version (refs #2452)
commit 5685a4850af6edda7100cae900487955c8b7a3ab
Author: Maximilian Hils <git@maximilianhils.com>
Date: Fri Jul 21 11:24:42 2017 +0200
fix addon tracebacks
`.tb_next` discards the first interesting frame,
this shouldn't happen.
commit a2da9b6c02030293f3a412d16df819868c581a29
Author: Matt Weidner <matt.weidner@gmail.com>
Date: Sat Jul 22 12:30:15 2017 -0500
Added os.path.expanduser() before open() calls with user supplied paths
commit 05db6e32c7957f267e97c34aa8f5a3cd6cb7dbb2
Author: Matt Weidner <matt.weidner@gmail.com>
Date: Fri Jul 21 16:25:16 2017 -0500
Added support for the ~ path shortcut when loading flows from disk.
for consistency. Saving flows supports using paths with the ~ shortcut.
commit b7f864b6bbd221093aeb1c384dd16038f490441a
Author: Matt Weidner <matt.weidner@gmail.com>
Date: Fri Jul 21 16:06:38 2017 -0500
Fixed crash when loading flows from a file that does not exist
-rw-r--r-- | mitmproxy/addons/view.py | 18 | ||||
-rw-r--r-- | mitmproxy/optmanager.py | 1 | ||||
-rw-r--r-- | pathod/language/generators.py | 2 | ||||
-rw-r--r-- | pathod/pathoc_cmdline.py | 1 | ||||
-rw-r--r-- | pathod/pathod_cmdline.py | 1 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_view.py | 4 |
6 files changed, 20 insertions, 7 deletions
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index d4319468..b2db0171 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -10,6 +10,7 @@ The View: """ import collections import typing +import os import blinker import sortedcontainers @@ -339,12 +340,17 @@ class View(collections.Sequence): """ Load flows into the view, without processing them with addons. """ - with open(path, "rb") as f: - for i in io.FlowReader(f).stream(): - # Do this to get a new ID, so we can load the same file N times and - # get new flows each time. It would be more efficient to just have a - # .newid() method or something. - self.add([i.copy()]) + path = os.path.expanduser(path) + try: + with open(path, "rb") as f: + for i in io.FlowReader(f).stream(): + # Do this to get a new ID, so we can load the same file N times and + # get new flows each time. It would be more efficient to just have a + # .newid() method or something. + self.add([i.copy()]) + except IOError as e: + ctx.log.error(e.strerror) + return @command.command("view.go") def go(self, dst: int) -> None: diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index e1d74b8e..c28ec685 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -518,6 +518,7 @@ def save(opts, path, defaults=False): Raises OptionsError if the existing data is corrupt. """ + path = os.path.expanduser(path) if os.path.exists(path) and os.path.isfile(path): with open(path, "rt", encoding="utf8") as f: try: diff --git a/pathod/language/generators.py b/pathod/language/generators.py index 1961df74..70c6ad16 100644 --- a/pathod/language/generators.py +++ b/pathod/language/generators.py @@ -75,7 +75,7 @@ class RandomGenerator: class FileGenerator: def __init__(self, path): - self.path = path + self.path = os.path.expanduser(path) def __len__(self): return os.path.getsize(self.path) diff --git a/pathod/pathoc_cmdline.py b/pathod/pathoc_cmdline.py index 3b738d47..0854f6ad 100644 --- a/pathod/pathoc_cmdline.py +++ b/pathod/pathoc_cmdline.py @@ -208,6 +208,7 @@ def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr): reqs = [] for r in args.requests: + r = os.path.expanduser(r) if os.path.isfile(r): with open(r) as f: r = f.read() diff --git a/pathod/pathod_cmdline.py b/pathod/pathod_cmdline.py index dee19f4f..c646aaee 100644 --- a/pathod/pathod_cmdline.py +++ b/pathod/pathod_cmdline.py @@ -215,6 +215,7 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr): anchors = [] for patt, spec in args.anchors: + spec = os.path.expanduser(spec) if os.path.isfile(spec): with open(spec) as f: data = f.read() diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index 40136f1f..e8eeb591 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -170,6 +170,10 @@ def test_load(tmpdir): assert len(v) == 2 v.load_file(path) assert len(v) == 4 + try: + v.load_file("nonexistent_file_path") + except IOError: + assert False def test_resolve(): |