py-euvd 0.2.1__tar.gz → 0.2.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.
- py_euvd-0.2.2/CHANGELOG.md +18 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/PKG-INFO +1 -1
- py_euvd-0.2.2/pyeuvd/_version.py +1 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/response.py +5 -4
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/transports/urllib_transport.py +55 -14
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/utils.py +6 -1
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_response.py +8 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_urllib_transport.py +71 -2
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_utils.py +1 -0
- py_euvd-0.2.1/CHANGELOG.md +0 -10
- py_euvd-0.2.1/pyeuvd/_version.py +0 -1
- {py_euvd-0.2.1 → py_euvd-0.2.2}/.gitignore +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/LICENSE +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/NOTICE +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/README.md +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/__init__.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/async_client.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/base_client.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/client.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/constants.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/errors.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/filters.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/__init__.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/advisory.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/advisory_detail.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/kev_entry.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/model.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/page.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/product.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/record.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/source_record.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/vulnerability.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/models/vulnerability_detail.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/parsing.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/py.typed +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/transports/__init__.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/transports/async_transport.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/transports/threaded_transport.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyeuvd/transports/transport.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/pyproject.toml +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/__init__.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/conftest.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fakes.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/advisory.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/cve_mapping.csv +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/exploited.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/kev.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/latest.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/search.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/fixtures/vulnerability.json +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/server.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_async_client.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_client.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_live.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_models.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_parsing.py +0 -0
- {py_euvd-0.2.1 → py_euvd-0.2.2}/tests/test_transports.py +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.2 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
- Security: the built-in transport no longer follows a redirect to an `ftp://` address. The request fails with an `APIError` instead.
|
|
6
|
+
- Security: `UrllibTransport` now raises `ValueError` for any address that is not `http://` or `https://`, such as `file:` or `data:`.
|
|
7
|
+
- Security: `UrllibTransport` refuses a response larger than 50 MB and raises `EUVDError`. The new `max_bytes` option changes the limit. For `cve_mapping()` the limit applies to each line.
|
|
8
|
+
- Security: control characters in text from the server are replaced with spaces in error messages.
|
|
9
|
+
- JSON that is nested too deeply now raises `EUVDError` instead of `RecursionError`.
|
|
10
|
+
|
|
11
|
+
## 0.2.1 (2026-11-27)
|
|
12
|
+
|
|
13
|
+
- Security: headers set with `UrllibTransport(headers=...)` are no longer sent along when the server redirects a request. A replaced `User-Agent` or `Accept` still follows redirects.
|
|
14
|
+
- `UrllibTransport.headers` now holds only the headers you passed in, without the defaults.
|
|
15
|
+
|
|
16
|
+
## 0.2.0 (2026-11-27)
|
|
17
|
+
|
|
18
|
+
First public release. Version 0.1.0 was never published.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: py-euvd
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Dependency-free Python client for the EU Vulnerability Database (EUVD) API
|
|
5
5
|
Project-URL: Documentation, https://py-euvd.spoons.fyi
|
|
6
6
|
Project-URL: Repository, https://github.com/dmuhs/py-euvd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -6,6 +6,7 @@ from http import HTTPStatus
|
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
8
|
from .errors import APIError, EUVDError, NotFoundError
|
|
9
|
+
from .utils import printable
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@dataclass(frozen=True, slots=True)
|
|
@@ -23,7 +24,7 @@ class Response:
|
|
|
23
24
|
"""Decode the body as JSON. Raises ``EUVDError`` if it is not JSON."""
|
|
24
25
|
try:
|
|
25
26
|
return json.loads(self.body)
|
|
26
|
-
except ValueError as exc:
|
|
27
|
+
except (ValueError, RecursionError) as exc:
|
|
27
28
|
raise EUVDError("the API did not return JSON") from exc
|
|
28
29
|
|
|
29
30
|
def raise_for_status(self) -> None:
|
|
@@ -35,10 +36,10 @@ class Response:
|
|
|
35
36
|
|
|
36
37
|
def _error_message(self) -> str:
|
|
37
38
|
try:
|
|
38
|
-
return str(json.loads(self.body)["error"])
|
|
39
|
-
except (ValueError, KeyError, TypeError):
|
|
39
|
+
return printable(str(json.loads(self.body)["error"]))
|
|
40
|
+
except (ValueError, KeyError, TypeError, RecursionError):
|
|
40
41
|
pass
|
|
41
|
-
text = self.body.decode("utf-8", "replace").strip()[:200]
|
|
42
|
+
text = printable(self.body.decode("utf-8", "replace").strip()[:200])
|
|
42
43
|
if text:
|
|
43
44
|
return text
|
|
44
45
|
try:
|
|
@@ -3,13 +3,14 @@ from __future__ import annotations
|
|
|
3
3
|
import logging
|
|
4
4
|
import time
|
|
5
5
|
import urllib.error
|
|
6
|
+
import urllib.parse
|
|
6
7
|
import urllib.request
|
|
7
8
|
from collections.abc import Generator, Mapping
|
|
8
|
-
from http.client import HTTPException
|
|
9
|
-
from typing import Any
|
|
9
|
+
from http.client import HTTPException, HTTPMessage
|
|
10
|
+
from typing import IO, Any
|
|
10
11
|
|
|
11
12
|
from ..constants import DEFAULT_TIMEOUT, USER_AGENT
|
|
12
|
-
from ..errors import APIError, TransportError
|
|
13
|
+
from ..errors import APIError, EUVDError, TransportError
|
|
13
14
|
from ..response import Response
|
|
14
15
|
from ..utils import describe_error, is_certificate_error
|
|
15
16
|
from .transport import Transport
|
|
@@ -21,6 +22,25 @@ RETRY_STATUSES = frozenset({429, 502, 503, 504})
|
|
|
21
22
|
|
|
22
23
|
DEFAULT_HEADERS = {"User-Agent": USER_AGENT, "Accept": "application/json, text/csv"}
|
|
23
24
|
|
|
25
|
+
SCHEMES = ("http", "https")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _RedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
29
|
+
"""Leaves a redirect to anything but http or https unfollowed. urllib allows ftp."""
|
|
30
|
+
|
|
31
|
+
def redirect_request(
|
|
32
|
+
self,
|
|
33
|
+
req: urllib.request.Request,
|
|
34
|
+
fp: IO[bytes],
|
|
35
|
+
code: int,
|
|
36
|
+
msg: str,
|
|
37
|
+
headers: HTTPMessage,
|
|
38
|
+
newurl: str,
|
|
39
|
+
) -> urllib.request.Request | None:
|
|
40
|
+
if urllib.parse.urlsplit(newurl).scheme not in SCHEMES:
|
|
41
|
+
return None
|
|
42
|
+
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
43
|
+
|
|
24
44
|
|
|
25
45
|
class UrllibTransport(Transport):
|
|
26
46
|
"""The default transport. Uses only the Python standard library.
|
|
@@ -35,6 +55,15 @@ class UrllibTransport(Transport):
|
|
|
35
55
|
and ``headers`` to send extra headers with every request. Extra headers
|
|
36
56
|
are not sent along when the server redirects the request, except a
|
|
37
57
|
replaced ``User-Agent`` or ``Accept``.
|
|
58
|
+
|
|
59
|
+
Only ``http`` and ``https`` addresses are fetched. Any other address
|
|
60
|
+
raises ``ValueError``, and a redirect to one is not followed. Your own
|
|
61
|
+
opener follows redirects by its own rules.
|
|
62
|
+
|
|
63
|
+
A response larger than ``max_bytes`` raises ``EUVDError``. For
|
|
64
|
+
``stream_lines`` the limit applies to each line.
|
|
65
|
+
|
|
66
|
+
``timeout`` limits each wait for data, not the whole request.
|
|
38
67
|
"""
|
|
39
68
|
|
|
40
69
|
def __init__(
|
|
@@ -45,12 +74,14 @@ class UrllibTransport(Transport):
|
|
|
45
74
|
backoff: float = 0.5,
|
|
46
75
|
opener: urllib.request.OpenerDirector | None = None,
|
|
47
76
|
headers: Mapping[str, str] | None = None,
|
|
77
|
+
max_bytes: int = 50_000_000,
|
|
48
78
|
) -> None:
|
|
49
79
|
self.timeout = timeout
|
|
50
80
|
self.retries = retries
|
|
51
81
|
self.backoff = backoff
|
|
52
|
-
self.opener = opener or urllib.request.build_opener()
|
|
82
|
+
self.opener = opener or urllib.request.build_opener(_RedirectHandler)
|
|
53
83
|
self.headers = dict(headers or {})
|
|
84
|
+
self.max_bytes = max_bytes
|
|
54
85
|
|
|
55
86
|
def get(self, url: str) -> Response:
|
|
56
87
|
attempt = 0
|
|
@@ -92,7 +123,9 @@ class UrllibTransport(Transport):
|
|
|
92
123
|
def _get_once(self, url: str) -> Response:
|
|
93
124
|
try:
|
|
94
125
|
with self._open(url) as reply:
|
|
95
|
-
|
|
126
|
+
body = self._limited(reply.read(self.max_bytes + 1))
|
|
127
|
+
self._check_complete(reply, len(body))
|
|
128
|
+
return Response(reply.status, body)
|
|
96
129
|
except urllib.error.HTTPError as exc:
|
|
97
130
|
return self._error_response(exc)
|
|
98
131
|
except (OSError, HTTPException) as exc:
|
|
@@ -101,20 +134,27 @@ class UrllibTransport(Transport):
|
|
|
101
134
|
def _stream_once(self, url: str) -> Generator[str, None, None]:
|
|
102
135
|
try:
|
|
103
136
|
with self._open(url) as reply:
|
|
104
|
-
expected = reply.headers.get("Content-Length")
|
|
105
137
|
received = 0
|
|
106
|
-
|
|
138
|
+
while line := self._limited(reply.readline(self.max_bytes + 1)):
|
|
107
139
|
received += len(line)
|
|
108
140
|
yield line.decode("utf-8", "replace").rstrip("\r\n")
|
|
109
|
-
|
|
110
|
-
raise TransportError(
|
|
111
|
-
f"download ended early: got {received} of {expected} bytes"
|
|
112
|
-
)
|
|
141
|
+
self._check_complete(reply, received)
|
|
113
142
|
except urllib.error.HTTPError as exc:
|
|
114
143
|
self._error_response(exc).raise_for_status()
|
|
115
144
|
except (OSError, HTTPException) as exc:
|
|
116
145
|
raise TransportError(describe_error(exc)) from exc
|
|
117
146
|
|
|
147
|
+
def _limited(self, data: bytes) -> bytes:
|
|
148
|
+
if len(data) > self.max_bytes:
|
|
149
|
+
raise EUVDError(f"the response is larger than {self.max_bytes} bytes")
|
|
150
|
+
return data
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def _check_complete(reply: Any, received: int) -> None:
|
|
154
|
+
expected = reply.headers.get("Content-Length", "")
|
|
155
|
+
if expected.isdecimal() and received < int(expected):
|
|
156
|
+
raise TransportError(f"download ended early: got {received} of {expected} bytes")
|
|
157
|
+
|
|
118
158
|
def _wait(self, attempt: int, url: str, problem: str) -> None:
|
|
119
159
|
delay = self.backoff * 2**attempt
|
|
120
160
|
logger.debug("GET %s failed (%s), retrying in %.1f s", url, problem, delay)
|
|
@@ -122,6 +162,8 @@ class UrllibTransport(Transport):
|
|
|
122
162
|
|
|
123
163
|
def _open(self, url: str) -> Any:
|
|
124
164
|
request = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
|
165
|
+
if request.type not in SCHEMES:
|
|
166
|
+
raise ValueError("url must start with http:// or https://")
|
|
125
167
|
for name, value in self.headers.items():
|
|
126
168
|
if request.has_header(name.capitalize()):
|
|
127
169
|
request.add_header(name, value)
|
|
@@ -129,11 +171,10 @@ class UrllibTransport(Transport):
|
|
|
129
171
|
request.add_unredirected_header(name, value)
|
|
130
172
|
return self.opener.open(request, timeout=self.timeout)
|
|
131
173
|
|
|
132
|
-
|
|
133
|
-
def _error_response(error: urllib.error.HTTPError) -> Response:
|
|
174
|
+
def _error_response(self, error: urllib.error.HTTPError) -> Response:
|
|
134
175
|
"""Turn the exception urllib raises for error statuses into a response."""
|
|
135
176
|
try:
|
|
136
|
-
body = error.read()
|
|
177
|
+
body = error.read(self.max_bytes)
|
|
137
178
|
except (OSError, HTTPException):
|
|
138
179
|
body = b""
|
|
139
180
|
finally:
|
|
@@ -88,4 +88,9 @@ def is_certificate_error(error: BaseException | None) -> bool:
|
|
|
88
88
|
def describe_error(error: BaseException) -> str:
|
|
89
89
|
"""Return a short reason for a network error."""
|
|
90
90
|
reason = getattr(error, "reason", None)
|
|
91
|
-
return str(reason or error) or type(error).__name__
|
|
91
|
+
return printable(str(reason or error)) or type(error).__name__
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def printable(text: str) -> str:
|
|
95
|
+
"""Replace control characters with spaces, so text from a server is safe to log."""
|
|
96
|
+
return "".join(char if char.isprintable() else " " for char in text)
|
|
@@ -22,6 +22,11 @@ def test_json_rejects_other_content():
|
|
|
22
22
|
Response(200, b"<html>maintenance</html>").json()
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
def test_json_rejects_deep_nesting():
|
|
26
|
+
with pytest.raises(EUVDError, match="did not return JSON"):
|
|
27
|
+
Response(200, b"[" * 100_000).json()
|
|
28
|
+
|
|
29
|
+
|
|
25
30
|
def test_raise_for_status_passes_on_success():
|
|
26
31
|
Response(200, b"[]").raise_for_status()
|
|
27
32
|
|
|
@@ -52,6 +57,9 @@ def test_other_errors_are_api_errors():
|
|
|
52
57
|
(500, b"x" * 500, "x" * 200), # long bodies are cut
|
|
53
58
|
(502, b"", "Bad Gateway"), # no body: use the standard status text
|
|
54
59
|
(599, b"", "HTTP error"), # no body and an unknown status
|
|
60
|
+
(500, b"[" * 100_000, "[" * 200), # nested too deeply to parse
|
|
61
|
+
(400, b'{"error": "bad\\n\\u001b[31mid"}', "bad [31mid"), # control characters
|
|
62
|
+
(500, b"down\r\n\x1b[2Jnow", "down [2Jnow"),
|
|
55
63
|
],
|
|
56
64
|
)
|
|
57
65
|
def test_error_message_fallbacks(status, body, message):
|
|
@@ -3,15 +3,25 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
import io
|
|
6
7
|
import socket
|
|
7
8
|
import ssl
|
|
8
9
|
import urllib.request
|
|
10
|
+
from email.message import Message
|
|
9
11
|
from types import SimpleNamespace
|
|
10
|
-
from urllib.error import URLError
|
|
12
|
+
from urllib.error import HTTPError, URLError
|
|
11
13
|
|
|
12
14
|
import pytest
|
|
13
15
|
|
|
14
|
-
from pyeuvd import
|
|
16
|
+
from pyeuvd import (
|
|
17
|
+
EUVD,
|
|
18
|
+
APIError,
|
|
19
|
+
AsyncEUVD,
|
|
20
|
+
EUVDError,
|
|
21
|
+
TransportError,
|
|
22
|
+
UrllibTransport,
|
|
23
|
+
__version__,
|
|
24
|
+
)
|
|
15
25
|
from pyeuvd.transports import urllib_transport
|
|
16
26
|
|
|
17
27
|
from .fakes import load_json, load_text
|
|
@@ -269,6 +279,19 @@ def test_certificate_failures_are_not_retried():
|
|
|
269
279
|
assert opener.calls == 2
|
|
270
280
|
|
|
271
281
|
|
|
282
|
+
def test_get_keeps_the_status_when_the_error_body_cannot_be_read():
|
|
283
|
+
class BrokenBody(io.BytesIO):
|
|
284
|
+
def read(self, *args):
|
|
285
|
+
raise ConnectionResetError
|
|
286
|
+
|
|
287
|
+
error = HTTPError("https://x.test/api/kev/dump", 500, "boom", Message(), BrokenBody())
|
|
288
|
+
transport = UrllibTransport(opener=FailingOpener(error), retries=0)
|
|
289
|
+
|
|
290
|
+
response = transport.get("https://x.test/api/kev/dump")
|
|
291
|
+
|
|
292
|
+
assert (response.status, response.body) == (500, b"")
|
|
293
|
+
|
|
294
|
+
|
|
272
295
|
def test_other_connection_failures_are_retried():
|
|
273
296
|
opener = FailingOpener(URLError(ConnectionRefusedError("refused")))
|
|
274
297
|
transport = UrllibTransport(opener=opener, retries=2, backoff=0)
|
|
@@ -337,3 +360,49 @@ def test_extra_headers_are_not_sent_along_when_a_download_is_redirected(api):
|
|
|
337
360
|
assert lines[0] == "euvd_id,cve_id"
|
|
338
361
|
assert "authorization" in api.headers[0]
|
|
339
362
|
assert not {name.lower() for name in SECRETS} & other.headers[0].keys()
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def test_a_redirect_to_ftp_is_not_followed(transport, api, unused_url):
|
|
366
|
+
api.replies["/kev/dump"] = Reply(status=302, location=unused_url.replace("http", "ftp", 1))
|
|
367
|
+
|
|
368
|
+
assert transport.get(api.url + "/kev/dump").status == 302
|
|
369
|
+
with pytest.raises(APIError, match="302"):
|
|
370
|
+
EUVD(base_url=api.url).kev()
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
@pytest.mark.parametrize("url", ["file:///etc/hostname", "data:,hello", "ftp://x.test/file"])
|
|
374
|
+
def test_only_http_addresses_are_fetched(transport, url):
|
|
375
|
+
with pytest.raises(ValueError, match="http://"):
|
|
376
|
+
transport.get(url)
|
|
377
|
+
with pytest.raises(ValueError, match="http://"):
|
|
378
|
+
list(transport.stream_lines(url))
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def test_a_response_over_the_size_limit_is_refused(api):
|
|
382
|
+
transport = UrllibTransport(retries=2, backoff=0, max_bytes=10)
|
|
383
|
+
api.replies["/kev/dump"] = Reply(body=b"x" * 11)
|
|
384
|
+
api.replies["/advisory"] = Reply(body=b"x" * 10)
|
|
385
|
+
|
|
386
|
+
with pytest.raises(EUVDError, match="larger than 10 bytes"):
|
|
387
|
+
transport.get(api.url + "/kev/dump")
|
|
388
|
+
assert len(api.headers) == 1
|
|
389
|
+
assert transport.get(api.url + "/advisory").body == b"x" * 10
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def test_stream_lines_refuses_a_line_over_the_size_limit(api):
|
|
393
|
+
api.replies["/dump/cve-euvd-mapping"] = Reply(body=b"a,b\n" + b"x" * 11)
|
|
394
|
+
lines = UrllibTransport(retries=2, backoff=0, max_bytes=10).stream_lines(
|
|
395
|
+
api.url + "/dump/cve-euvd-mapping"
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
assert next(lines) == "a,b"
|
|
399
|
+
with pytest.raises(EUVDError, match="larger than 10 bytes"):
|
|
400
|
+
next(lines)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def test_an_error_body_over_the_size_limit_is_cut(api):
|
|
404
|
+
api.replies["/kev/dump"] = Reply(status=500, body=b"x" * 50)
|
|
405
|
+
|
|
406
|
+
response = UrllibTransport(retries=0, max_bytes=10).get(api.url + "/kev/dump")
|
|
407
|
+
|
|
408
|
+
assert (response.status, response.body) == (500, b"x" * 10)
|
|
@@ -111,6 +111,7 @@ def test_describe_error():
|
|
|
111
111
|
assert utils.describe_error(TimeoutError("timed out")) == "timed out"
|
|
112
112
|
assert utils.describe_error(URLError("no route to host")) == "no route to host"
|
|
113
113
|
assert utils.describe_error(ConnectionResetError()) == "ConnectionResetError"
|
|
114
|
+
assert utils.describe_error(URLError("bad\x1b[31m\nline")) == "bad [31m line"
|
|
114
115
|
|
|
115
116
|
|
|
116
117
|
@pytest.mark.parametrize(
|
py_euvd-0.2.1/CHANGELOG.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 0.2.1 (2026-11-27)
|
|
4
|
-
|
|
5
|
-
- Security: headers set with `UrllibTransport(headers=...)` are no longer sent along when the server redirects a request. A replaced `User-Agent` or `Accept` still follows redirects.
|
|
6
|
-
- `UrllibTransport.headers` now holds only the headers you passed in, without the defaults.
|
|
7
|
-
|
|
8
|
-
## 0.2.0 (2026-11-27)
|
|
9
|
-
|
|
10
|
-
First public release. Version 0.1.0 was never published.
|
py_euvd-0.2.1/pyeuvd/_version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
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
|
|
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
|