redbot 2.4.0__tar.gz → 2.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. {redbot-2.4.0/redbot.egg-info → redbot-2.4.2}/PKG-INFO +1 -1
  2. {redbot-2.4.0 → redbot-2.4.2}/redbot/__init__.py +1 -1
  3. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/__init__.py +1 -1
  4. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/link_parse.py +6 -0
  5. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/run_test.py +34 -6
  6. {redbot-2.4.0 → redbot-2.4.2/redbot.egg-info}/PKG-INFO +1 -1
  7. {redbot-2.4.0 → redbot-2.4.2}/LICENSE.md +0 -0
  8. {redbot-2.4.0 → redbot-2.4.2}/MANIFEST.in +0 -0
  9. {redbot-2.4.0 → redbot-2.4.2}/README.md +0 -0
  10. {redbot-2.4.0 → redbot-2.4.2}/pyproject.toml +0 -0
  11. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/__init__.py +0 -0
  12. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/__init__.py +0 -0
  13. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/check-circle.svg +0 -0
  14. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/exclamation-circle.svg +0 -0
  15. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/info-circle.svg +0 -0
  16. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/question-circle.svg +0 -0
  17. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/times-circle.svg +0 -0
  18. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/__init__.py +0 -0
  19. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/apple-touch-icon-144x144.png +0 -0
  20. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/apple-touch-icon-152x152.png +0 -0
  21. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon-16x16.png +0 -0
  22. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon-32x32.png +0 -0
  23. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon.ico +0 -0
  24. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/mstile-144x144.png +0 -0
  25. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/redbot-sq.png +0 -0
  26. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/prettify.js +0 -0
  27. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/prettify.js.map +0 -0
  28. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/red_style.css +0 -0
  29. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/red_style.css.map +0 -0
  30. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/script.js +0 -0
  31. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/script.js.map +0 -0
  32. {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/style.css +0 -0
  33. {redbot-2.4.0 → redbot-2.4.2}/redbot/cli.py +0 -0
  34. {redbot-2.4.0 → redbot-2.4.2}/redbot/daemon.py +0 -0
  35. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/__init__.py +0 -0
  36. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/har.py +0 -0
  37. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/html.py +0 -0
  38. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/html_base.py +0 -0
  39. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/null_links.py +0 -0
  40. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/__init__.py +0 -0
  41. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/footer.html +0 -0
  42. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_finish.html +0 -0
  43. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_multi_finish.html +0 -0
  44. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_start.html +0 -0
  45. {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/text.py +0 -0
  46. {redbot-2.4.0 → redbot-2.4.2}/redbot/i18n.py +0 -0
  47. {redbot-2.4.0 → redbot-2.4.2}/redbot/note.py +0 -0
  48. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/__init__.py +0 -0
  49. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/base.py +0 -0
  50. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/conneg.py +0 -0
  51. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/etag_validate.py +0 -0
  52. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/lm_validate.py +0 -0
  53. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/range.py +0 -0
  54. {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/fetch.py +0 -0
  55. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/__init__.py +0 -0
  56. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/es/LC_MESSAGES/messages.mo +0 -0
  57. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/es/LC_MESSAGES/messages.po +0 -0
  58. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/extra_strings.py +0 -0
  59. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/fr/LC_MESSAGES/messages.mo +0 -0
  60. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/fr/LC_MESSAGES/messages.po +0 -0
  61. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/ja/LC_MESSAGES/messages.mo +0 -0
  62. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/ja/LC_MESSAGES/messages.po +0 -0
  63. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/messages.pot +0 -0
  64. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/zh/LC_MESSAGES/messages.mo +0 -0
  65. {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/zh/LC_MESSAGES/messages.po +0 -0
  66. {redbot-2.4.0 → redbot-2.4.2}/redbot/type.py +0 -0
  67. {redbot-2.4.0 → redbot-2.4.2}/redbot/utils.py +0 -0
  68. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/__init__.py +0 -0
  69. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/captcha.py +0 -0
  70. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/__init__.py +0 -0
  71. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/base.py +0 -0
  72. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/client_error.py +0 -0
  73. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/error.py +0 -0
  74. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/save.py +0 -0
  75. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/show.py +0 -0
  76. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/links.py +0 -0
  77. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/ratelimit.py +0 -0
  78. {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/saved_tests.py +0 -0
  79. {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/SOURCES.txt +0 -0
  80. {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/dependency_links.txt +0 -0
  81. {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/entry_points.txt +0 -0
  82. {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/requires.txt +0 -0
  83. {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/top_level.txt +0 -0
  84. {redbot-2.4.0 → redbot-2.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redbot
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: REDbot is lint for HTTP.
5
5
  Author-email: Mark Nottingham <mnot@mnot.net>
6
6
  License-Expression: MIT
@@ -2,7 +2,7 @@
2
2
  This is the Resource Expert Droid.
3
3
  """
4
4
 
5
- __version__ = "2.4.0"
5
+ __version__ = "2.4.2"
6
6
  __author__ = "Mark Nottingham <mnot@mnot.net>"
7
7
  __copyright__ = """\
8
8
  Copyright (c) 2008- Mark Nottingham
@@ -56,7 +56,7 @@ class HttpResource(RedFetcher):
56
56
  self.linked: List[Tuple[HttpResource, str]] = [] # linked HttpResources
57
57
  self._link_parser = link_parse.HTMLLinkParser(self.response, [self.process_link])
58
58
  if self.descend or config.getboolean("content_links", False):
59
- self.response_content_processors.append(self._link_parser.feed_bytes)
59
+ self.response.decoded.processors.append(self._link_parser.feed_bytes)
60
60
 
61
61
  def run_active_checks(self) -> None:
62
62
  """
@@ -13,6 +13,7 @@ from httplint.message import HttpMessageLinter
13
13
  from httplint.syntax import rfc9110
14
14
 
15
15
  DEFAULT_ENCODING = "utf-8"
16
+ MAX_FEED_BYTES = 2 * 1024 * 1024
16
17
 
17
18
 
18
19
  class HTMLLinkParser(HTMLParser):
@@ -57,6 +58,7 @@ class HTMLLinkParser(HTMLParser):
57
58
  self.errors = 0
58
59
  self.last_err_pos: int = 0
59
60
  self.ok = True
61
+ self.bytes_fed = 0
60
62
  HTMLParser.__init__(self)
61
63
 
62
64
  def __getstate__(self) -> Dict[str, Any]:
@@ -65,6 +67,10 @@ class HTMLLinkParser(HTMLParser):
65
67
  def feed_bytes(self, bchunk: bytes) -> None:
66
68
  "Feed a given chunk of bytes to the parser"
67
69
  if self.ok:
70
+ self.bytes_fed += len(bchunk)
71
+ if self.bytes_fed > MAX_FEED_BYTES:
72
+ self.ok = False
73
+ return
68
74
  encoding = self.message.character_encoding or DEFAULT_ENCODING
69
75
  decoded = bchunk.decode(encoding, "ignore")
70
76
  self.feed(decoded)
@@ -10,12 +10,13 @@ from urllib.parse import urlencode, urlsplit
10
10
 
11
11
  import thor
12
12
  import thor.events
13
+ from httplint.util import iri_to_uri
13
14
  from markupsafe import escape
14
15
 
15
16
  from redbot.formatter import find_formatter
16
17
  from redbot.resource import HttpResource
17
18
  from redbot.resource.active_check import active_checks
18
- from redbot.type import RawHeaderListType, RedWebUiProtocol, StrHeaderListType
19
+ from redbot.type import RawHeaderListType, RedWebUiProtocol
19
20
  from redbot.utils import e_url
20
21
  from redbot.webui.captcha import CaptchaHandler
21
22
  from redbot.webui.handlers.base import RequestHandler
@@ -25,6 +26,29 @@ from redbot.webui.saved_tests import init_save_file, save_test
25
26
  if TYPE_CHECKING:
26
27
  from redbot.formatter import Formatter
27
28
 
29
+ _BAD_HEADER_NAME_CHARS = set('()<>@,;:\\"/[]?={} \t\r\n')
30
+
31
+
32
+ def _validate_req_hdrs(raw: List[str]) -> Tuple[List[Tuple[str, str]], Optional[str]]:
33
+ """Parse and validate user-supplied req_hdr entries.
34
+
35
+ Returns (headers, error). When error is not None, headers is meaningless
36
+ and the test should not run.
37
+ """
38
+ headers: List[Tuple[str, str]] = []
39
+ for entry in raw:
40
+ if ":" not in entry:
41
+ return [], f"Request header {entry!r} is missing a colon."
42
+ name, value = entry.split(":", 1)
43
+ if not name:
44
+ return [], "Request header field name is empty."
45
+ if any(c in _BAD_HEADER_NAME_CHARS or ord(c) < 33 or ord(c) > 126 for c in name):
46
+ return [], f"Request header field name {name!r} contains invalid characters."
47
+ if "\r" in value or "\n" in value:
48
+ return [], f"Request header {name!r} value contains CR or LF."
49
+ headers.append((name, value))
50
+ return headers, None
51
+
28
52
 
29
53
  class RunTestHandler(RequestHandler):
30
54
  """
@@ -59,11 +83,15 @@ class RunTestHandler(RequestHandler):
59
83
  """
60
84
  test_id = init_save_file(ui)
61
85
  test_uri = ui.query_string.get("uri", [""])[0]
62
- test_req_hdrs: StrHeaderListType = [
63
- cast(Tuple[str, str], tuple(h.split(":", 1)))
64
- for h in ui.query_string.get("req_hdr", [])
65
- if ":" in h
66
- ]
86
+ try:
87
+ iri_to_uri(test_uri).encode("ascii")
88
+ except (ValueError, UnicodeError):
89
+ ui.error_response(b"400", b"Bad Request", "Request URI is malformed.")
90
+ return
91
+ test_req_hdrs, hdr_error = _validate_req_hdrs(ui.query_string.get("req_hdr", []))
92
+ if hdr_error:
93
+ ui.error_response(b"400", b"Bad Request", hdr_error)
94
+ return
67
95
  descend = "descend" in ui.query_string
68
96
 
69
97
  top_resource = HttpResource(ui.config, descend=descend)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redbot
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: REDbot is lint for HTTP.
5
5
  Author-email: Mark Nottingham <mnot@mnot.net>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes