From ad4ac04d2f7e6dbda8ac35053d46f570f04aa90e Mon Sep 17 00:00:00 2001 From: pogzyb Date: Sat, 4 Nov 2023 11:07:01 -0400 Subject: [PATCH 1/3] Update savehar.py Use `.get` when retrieving "path" from the `attrs` cookie dict. This avoids the occasional `KeyError`. --- mitmproxy/addons/savehar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy/addons/savehar.py b/mitmproxy/addons/savehar.py index dcc380c9d..59977e08e 100644 --- a/mitmproxy/addons/savehar.py +++ b/mitmproxy/addons/savehar.py @@ -281,7 +281,7 @@ class SaveHar: cookie = { "name": name, "value": value, - "path": attrs["path"], + "path": attrs.get("path", "/"), "domain": attrs.get("domain", ""), "httpOnly": "httpOnly" in attrs, "secure": "secure" in attrs, From 2a571a8c096b07a9b537b7470a5085e53b4de0b1 Mon Sep 17 00:00:00 2001 From: pogzyb Date: Sat, 4 Nov 2023 11:13:09 -0400 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 956395ba2..fc765a825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Unreleased: mitmproxy next - +* Update savehar addon to handle scenarios where "path" key in cookie + attrs dict is missing. ## 04 November 2023: mitmproxy 10.1.3 From 506c0e1013f8968d529bdf2aefb81ed67dc2dae4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 15:16:32 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc765a825..53efdf85a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Update savehar addon to handle scenarios where "path" key in cookie attrs dict is missing. + ([#6458](https://github.com/mitmproxy/mitmproxy/pull/6458), @pogzyb) ## 04 November 2023: mitmproxy 10.1.3