From 4a2eb93ecf6ba3545dabe45d88282e82457af7a0 Mon Sep 17 00:00:00 2001 From: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:50:49 +0530 Subject: [PATCH] Log raw bytes for invalid request line (#1313) * Log raw bytes for invalid request line * Upgrade isort to fix https://results.pre-commit.ci/run/github/12228178/1677045066.rNmdqVF5RLehPuIVg48STQ * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * `.. spelling:word-list::` * Ignore `PT027` * Keep using `.. spelling::` * Pin to `sphinxcontrib-spelling == 7.7.2` as v8 causes deprecation warning issues * Pin to 7.2.0 * 7.2.1 * `7.7.0` had last success --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .flake8 | 1 + .pre-commit-config.yaml | 2 +- proxy/http/parser/parser.py | 4 +++- tox.ini | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 7752ff415b..3a2dd7e150 100644 --- a/.flake8 +++ b/.flake8 @@ -187,6 +187,7 @@ extend-ignore = WPS612 # FIXME: useless `__init__()` override WPS613 # FIXME: unmatching super method access WPS615 # FIXME: unpythonic setter/getter + PT027 # FIXME: use pytest.raises() instead of unittest-style 'assertRaises' # https://wemake-python-stylegui.de/en/latest/pages/usage/formatter.html format = wemake diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c5050d667..14c0a97036 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - --py36-plus - repo: https://github.com/timothycrosley/isort.git - rev: 5.10.0 + rev: 5.12.0 hooks: - id: isort args: diff --git a/proxy/http/parser/parser.py b/proxy/http/parser/parser.py index 91a0cbbc9e..6b882f8fd9 100644 --- a/proxy/http/parser/parser.py +++ b/proxy/http/parser/parser.py @@ -417,7 +417,9 @@ def _process_line( break # To avoid a possible attack vector, we raise exception # if parser receives an invalid request line. - raise HttpProtocolException('Invalid request line %r' % raw) + raise HttpProtocolException( + 'Invalid request line %r' % raw.tobytes(), + ) parts = line.split(WHITESPACE, 2) self.version = parts[0] self.code = parts[1] diff --git a/tox.ini b/tox.ini index 9f59afc2bb..c5b7598c4d 100644 --- a/tox.ini +++ b/tox.ini @@ -143,7 +143,7 @@ commands = . "{toxworkdir}/docs_out" changedir = {[testenv:build-docs]changedir} deps = - sphinxcontrib-spelling >= 7.2.0 + sphinxcontrib-spelling == 7.7.0 -r{toxinidir}/docs/requirements.in description = Spellcheck The Docs isolated_build = {[testenv:build-docs]isolated_build}