diff --git a/CHANGELOG.rst b/CHANGELOG.rst index eafce272d..5e6f80455 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,8 @@ Unreleased: mitmproxy next * Fix query parameters in asgiapp addon (@jpstotz) * Fix command history failing on file IO errors (@Kriechi) * Deprecation of pathod and pathoc tools and modules. Future releases might not contain them! (@Kriechi) +* Addon to suppress unwanted error messages sent by mitmproxy. (@anneborcherding) +* Updated imports and styles for web scanner helper addons. (@anneborcherding) * --- TODO: add new PRs above this line --- diff --git a/examples/contrib/webscanner_helper/mapping.py b/examples/contrib/webscanner_helper/mapping.py index 8c83bf779..bd5260729 100644 --- a/examples/contrib/webscanner_helper/mapping.py +++ b/examples/contrib/webscanner_helper/mapping.py @@ -6,7 +6,7 @@ from typing import Dict from bs4 import BeautifulSoup from mitmproxy.http import HTTPFlow -from examples.complex.webscanner_helper.urldict import URLDict +from examples.contrib.webscanner_helper.urldict import URLDict NO_CONTENT = object() @@ -141,4 +141,4 @@ class MappingAddon: return store with open(self.filename, "w") as f: - self.mapping_templates.dump(f, value_dumper) \ No newline at end of file + self.mapping_templates.dump(f, value_dumper) diff --git a/examples/contrib/webscanner_helper/proxyauth_selenium.py b/examples/contrib/webscanner_helper/proxyauth_selenium.py index d2a712da6..4a00a8d06 100644 --- a/examples/contrib/webscanner_helper/proxyauth_selenium.py +++ b/examples/contrib/webscanner_helper/proxyauth_selenium.py @@ -30,6 +30,7 @@ def randomString(string_length=10): class AuthorizationOracle(abc.ABC): """Abstract class for an authorization oracle which decides if a given request or response is authenticated.""" + @abc.abstractmethod def is_unauthorized_request(self, flow: mitmproxy.http.HTTPFlow) -> bool: pass @@ -48,6 +49,7 @@ class SeleniumAddon: created. This class needs to include the concrete selenium actions necessary to authenticate against the web application. In addition, an authentication oracle which inherits from AuthorizationOracle should be created. """ + def __init__(self, fltr: str, domain: str, auth_oracle: AuthorizationOracle): self.filter = flowfilter.parse(fltr) diff --git a/examples/contrib/webscanner_helper/test_mapping.py b/examples/contrib/webscanner_helper/test_mapping.py index e4d519fcf..c0639bfb3 100644 --- a/examples/contrib/webscanner_helper/test_mapping.py +++ b/examples/contrib/webscanner_helper/test_mapping.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock from mitmproxy.test import tflow from mitmproxy.test import tutils -from examples.complex.webscanner_helper.mapping import MappingAddon, MappingAddonConfig +from examples.contrib.webscanner_helper.mapping import MappingAddon, MappingAddonConfig class TestConfig: diff --git a/examples/contrib/webscanner_helper/test_proxyauth_selenium.py b/examples/contrib/webscanner_helper/test_proxyauth_selenium.py index c552355c4..58e035068 100644 --- a/examples/contrib/webscanner_helper/test_proxyauth_selenium.py +++ b/examples/contrib/webscanner_helper/test_proxyauth_selenium.py @@ -7,7 +7,8 @@ from mitmproxy.test import tflow from mitmproxy.test import tutils from mitmproxy.http import HTTPFlow -from examples.complex.webscanner_helper.proxyauth_selenium import logger, randomString, AuthorizationOracle, SeleniumAddon +from examples.contrib.webscanner_helper.proxyauth_selenium import logger, randomString, AuthorizationOracle, \ + SeleniumAddon class TestRandomString: @@ -104,7 +105,8 @@ class TestSeleniumAddon: f = tflow.tflow(resp=tutils.tresp()) f.request.url = "http://example.com/login.php" selenium_addon.set_cookies = False - with mock.patch('examples.complex.webscanner_helper.proxyauth_selenium.SeleniumAddon.login', return_value=[]) as mock_login: + with mock.patch('examples.complex.webscanner_helper.proxyauth_selenium.SeleniumAddon.login', + return_value=[]) as mock_login: selenium_addon.response(f) mock_login.assert_called() diff --git a/examples/contrib/webscanner_helper/test_urldict.py b/examples/contrib/webscanner_helper/test_urldict.py index 7bd4fb017..4eadfe630 100644 --- a/examples/contrib/webscanner_helper/test_urldict.py +++ b/examples/contrib/webscanner_helper/test_urldict.py @@ -1,5 +1,5 @@ from mitmproxy.test import tflow, tutils -from examples.complex.webscanner_helper.urldict import URLDict +from examples.contrib.webscanner_helper.urldict import URLDict url = "http://10.10.10.10" new_content_body = "New Body" diff --git a/examples/contrib/webscanner_helper/test_urlindex.py b/examples/contrib/webscanner_helper/test_urlindex.py index 0edd6cc06..ac6079e90 100644 --- a/examples/contrib/webscanner_helper/test_urlindex.py +++ b/examples/contrib/webscanner_helper/test_urlindex.py @@ -8,7 +8,8 @@ from unittest.mock import patch from mitmproxy.test import tflow from mitmproxy.test import tutils -from examples.complex.webscanner_helper.urlindex import UrlIndexWriter, SetEncoder, JSONUrlIndexWriter, TextUrlIndexWriter, WRITER, \ +from examples.contrib.webscanner_helper.urlindex import UrlIndexWriter, SetEncoder, JSONUrlIndexWriter, \ + TextUrlIndexWriter, WRITER, \ filter_404, \ UrlIndexAddon diff --git a/examples/contrib/webscanner_helper/test_urlinjection.py b/examples/contrib/webscanner_helper/test_urlinjection.py index 4b87296d6..b1c412d21 100644 --- a/examples/contrib/webscanner_helper/test_urlinjection.py +++ b/examples/contrib/webscanner_helper/test_urlinjection.py @@ -5,7 +5,8 @@ from mitmproxy import flowfilter from mitmproxy.test import tflow from mitmproxy.test import tutils -from examples.complex.webscanner_helper.urlinjection import InjectionGenerator, HTMLInjection, RobotsInjection, SitemapInjection, \ +from examples.contrib.webscanner_helper.urlinjection import InjectionGenerator, HTMLInjection, RobotsInjection, \ + SitemapInjection, \ UrlInjectionAddon, logger index = json.loads( diff --git a/examples/contrib/webscanner_helper/test_watchdog.py b/examples/contrib/webscanner_helper/test_watchdog.py index 43e59310d..f6a34a61b 100644 --- a/examples/contrib/webscanner_helper/test_watchdog.py +++ b/examples/contrib/webscanner_helper/test_watchdog.py @@ -8,7 +8,7 @@ from mitmproxy.test import tflow from mitmproxy.test import tutils import multiprocessing -from examples.complex.webscanner_helper.watchdog import WatchdogAddon, logger +from examples.contrib.webscanner_helper.watchdog import WatchdogAddon, logger class TestWatchdog: diff --git a/examples/contrib/webscanner_helper/urldict.py b/examples/contrib/webscanner_helper/urldict.py index 28e6b5e6a..daceb47fe 100644 --- a/examples/contrib/webscanner_helper/urldict.py +++ b/examples/contrib/webscanner_helper/urldict.py @@ -14,6 +14,7 @@ def f_id(x): class URLDict(MutableMapping): """Data structure to store information using filters as keys.""" + def __init__(self): self.store: Dict[flowfilter.TFilter, Any] = {}