Skip to content

Commit 69db9b2

Browse files
authored
update dependecy versions (#8422)
DESCRIPTION: 🚀 Motivation - Upgrade mitmproxy (12.2.1) to address CVEs and enable downstream dependency refreshes tied to security bulletins. - Refresh Python packages used by the regression proxy harness, so they remain compatible with the upgraded mitmproxy API and current patch levels. - Keep the [check-pytest] infrastructure resilient on both SSL-enabled and SSL-less PostgreSQL builds encountered in CI and local development. 🔄 Summary of Changes 1. Mitmproxy Upgrade & Harness Adaptation - Bumped mitmproxy to 12.2.1, which replaces the legacy TCP mode with the new reverse:tcp:// listener and requires explicit connection strategy flags. - Updated pg_regress_multi.pl and the Python proxy scripts to: -- Use the reverse:tcp:// endpoint format. -- Pass [--set connection_strategy=lazy]so new connections are accepted after mitmproxy’s change in default behavior. -- Handle ResetHandler cleanup differences introduced in mitmproxy 12 (guard when the client socket is already closed). - Adjusted columnar tests to accept the new psycopg EOF message variants surfaced once mitmproxy’s forwarding changed, ensuring the failure expectations still match. 2. Python Dependency Refresh - Synchronized requirements.txt/Pipenv lockfiles to versions compatible with mitmproxy 12 and recent security patches. - Ensured pytest plugins referenced in regression tests remain up to date (pytest 9, pytest-xdist 3.8, etc.), matching our supported Python 3.12 toolchain. 3. Pytest Harness Hardening - Added runtime detection in [common.py] to determine whether PostgreSQL was compiled with SSL ([pg_config --configure] - If SSL support is absent (as in our CI images), we now skip writing ssl = on into postgresql.conf and omit hostssl entries in pg_hba.conf. - This prevents pg_ctl from failing with “SSL is not supported by this build” when the tests restart cluster nodes.
1 parent bfefc27 commit 69db9b2

File tree

9 files changed

+2177
-1535
lines changed

9 files changed

+2177
-1535
lines changed

.devcontainer/src/test/regress/Pipfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ url = "https://pypi.python.org/simple"
44
verify_ssl = true
55

66
[packages]
7-
mitmproxy = {editable = true, ref = "main", git = "https://github.com/citusdata/mitmproxy.git"}
7+
mitmproxy = {git = "https://github.com/citusdata/mitmproxy.git", ref = "main"}
8+
"aioquic" = ">=1.2.0,<1.3.0"
9+
"mitmproxy-rs" = ">=0.12.6,<0.13.0"
10+
argon2-cffi = ">=23.1.0"
11+
bcrypt = ">=4.1.2"
12+
brotli = "<=1.2.0"
13+
h11 = "==0.16.0"
14+
h2 = "==4.3.0"
15+
tornado = ">=6.5.1,<6.6.0"
16+
zstandard = ">=0.25.0"
817
construct = "*"
918
docopt = "==0.6.2"
10-
cryptography = ">=41.0.4"
19+
cryptography = "==44.0.3"
1120
pytest = "*"
1221
psycopg = "*"
1322
filelock = "*"
@@ -16,13 +25,15 @@ pytest-timeout = "*"
1625
pytest-xdist = "*"
1726
pytest-repeat = "*"
1827
pyyaml = "*"
19-
werkzeug = "==3.0.6"
28+
werkzeug = "==3.1.0"
29+
"typing-extensions" = ">=4.13.2,<5"
30+
pyperclip = "==1.9.0"
2031

2132
[dev-packages]
22-
black = "*"
33+
black = "==24.10.0"
2334
isort = "*"
2435
flake8 = "*"
2536
flake8-bugbear = "*"
2637

2738
[requires]
28-
python_version = "3.9"
39+
python_version = "3.12"

.devcontainer/src/test/regress/Pipfile.lock

Lines changed: 1049 additions & 749 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
style_checker_image_name: "ghcr.io/citusdata/stylechecker"
3333
style_checker_tools_version: "0.8.33"
3434
sql_snapshot_pg_version: "18.1"
35-
image_suffix: "-v15cd08f"
35+
image_suffix: "-vaa2c190"
3636
pg16_version: '{ "major": "16", "full": "16.11" }'
3737
pg17_version: '{ "major": "17", "full": "17.7" }'
3838
pg18_version: '{ "major": "18", "full": "18.1" }'

src/test/regress/Pipfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ url = "https://pypi.python.org/simple"
44
verify_ssl = true
55

66
[packages]
7-
mitmproxy = {editable = true, ref = "main", git = "https://github.com/citusdata/mitmproxy.git"}
7+
mitmproxy = {git = "https://github.com/citusdata/mitmproxy.git", ref = "main"}
8+
"aioquic" = ">=1.2.0,<1.3.0"
9+
"mitmproxy-rs" = ">=0.12.6,<0.13.0"
10+
argon2-cffi = ">=23.1.0"
11+
bcrypt = ">=4.1.2"
12+
brotli = "<=1.2.0"
13+
h11 = "==0.16.0"
14+
h2 = "==4.3.0"
15+
tornado = ">=6.5.1,<6.6.0"
16+
zstandard = ">=0.25.0"
817
construct = "*"
918
docopt = "==0.6.2"
10-
cryptography = ">=41.0.4"
19+
cryptography = "==44.0.3"
1120
pytest = "*"
1221
psycopg = "*"
1322
filelock = "*"
@@ -16,13 +25,15 @@ pytest-timeout = "*"
1625
pytest-xdist = "*"
1726
pytest-repeat = "*"
1827
pyyaml = "*"
19-
werkzeug = "==3.0.6"
28+
werkzeug = "==3.1.0"
29+
"typing-extensions" = ">=4.13.2,<5"
30+
pyperclip = "==1.9.0"
2031

2132
[dev-packages]
22-
black = "*"
33+
black = "==24.10.0"
2334
isort = "*"
2435
flake8 = "*"
2536
flake8-bugbear = "*"
2637

2738
[requires]
28-
python_version = "3.9"
39+
python_version = "3.12"

src/test/regress/Pipfile.lock

Lines changed: 1049 additions & 749 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/regress/citus_tests/common.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def capture(command, *args, **kwargs):
7474

7575

7676
PG_CONFIG = os.environ.get("PG_CONFIG", "pg_config")
77+
PG_CONFIG_ARGS = capture([PG_CONFIG, "--configure"], shell=False).rstrip()
78+
PG_SUPPORTS_SSL = "--with-ssl" in PG_CONFIG_ARGS or "--with-openssl" in PG_CONFIG_ARGS
79+
7780
PG_BINDIR = capture([PG_CONFIG, "--bindir"], shell=False).rstrip()
7881
os.environ["PATH"] = PG_BINDIR + os.pathsep + os.environ["PATH"]
7982

@@ -850,7 +853,8 @@ def initdb(self):
850853
pgconf.write("restart_after_crash = off\n")
851854

852855
os.truncate(self.hba_path, 0)
853-
self.ssl_access("all", "trust")
856+
if PG_SUPPORTS_SSL:
857+
self.ssl_access("all", "trust")
854858
self.nossl_access("all", "trust")
855859
self.commit_hba()
856860

@@ -859,11 +863,12 @@ def init_with_citus(self):
859863
self.start()
860864
self.sql("CREATE EXTENSION citus")
861865

862-
# Manually turn on ssl, so that we can safely truncate
863-
# postgresql.auto.conf later. We can only do this after creating the
864-
# citus extension because that creates the self signed certificates.
865-
with self.conf_path.open(mode="a") as pgconf:
866-
pgconf.write("ssl = on\n")
866+
if PG_SUPPORTS_SSL:
867+
# Manually turn on ssl, so that we can safely truncate
868+
# postgresql.auto.conf later. We can only do this after creating the
869+
# citus extension because that creates the self signed certificates.
870+
with self.conf_path.open(mode="a") as pgconf:
871+
pgconf.write("ssl = on\n")
867872

868873
def pgctl(self, command, **kwargs):
869874
run(f"pg_ctl -w --pgdata {self.pgdata} {command}", **kwargs)

src/test/regress/citus_tests/test/test_columnar.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ def test_recovery(coord):
7171
# test crashing while having an open transaction
7272
with pytest.raises(
7373
psycopg.OperationalError,
74-
match="server closed the connection unexpectedly|consuming input failed: EOF detected",
74+
match=(
75+
"server closed the connection unexpectedly|"
76+
"consuming input failed: EOF detected|"
77+
"SSL SYSCALL error: EOF detected|"
78+
"SSL error: unexpected eof while reading"
79+
),
7580
):
7681
with coord.transaction() as cur:
7782
cur.execute(
@@ -88,7 +93,12 @@ def test_recovery(coord):
8893
# test crashing while having a prepared transaction
8994
with pytest.raises(
9095
psycopg.OperationalError,
91-
match="server closed the connection unexpectedly|consuming input failed: EOF detected",
96+
match=(
97+
"server closed the connection unexpectedly|"
98+
"consuming input failed: EOF detected|"
99+
"consuming input failed: SSL SYSCALL error: EOF detected|"
100+
"SSL error: unexpected eof while reading"
101+
),
92102
):
93103
with coord.transaction() as cur:
94104
cur.execute(

src/test/regress/mitmscripts/fluent.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,27 @@ def _handle(self, flow, message):
157157
flow.kill() # tell mitmproxy this connection should be closed
158158

159159
# this is a mitmproxy.connections.ClientConnection(mitmproxy.tcp.BaseHandler)
160-
client_conn = flow.client_conn
161-
# this is a regular socket object
162-
conn = client_conn.connection
163-
164-
# cause linux to send a RST
165-
LINGER_ON, LINGER_TIMEOUT = 1, 0
166-
conn.setsockopt(
167-
socket.SOL_SOCKET,
168-
socket.SO_LINGER,
169-
struct.pack("ii", LINGER_ON, LINGER_TIMEOUT),
170-
)
171-
conn.close()
172-
173-
# closing the connection isn't ideal, this thread later crashes when mitmproxy
174-
# tries to call conn.shutdown(), but there's nothing else to clean up so that's
175-
# maybe okay
160+
client_conn = getattr(flow, "client_conn", None)
161+
162+
# this is a regular socket object on mitmproxy versions < 12.2.
163+
# Newer releases no longer expose the raw socket via the "connection"
164+
# attribute, so guard access accordingly.
165+
conn = getattr(client_conn, "connection", None)
166+
167+
if conn is not None:
168+
# mitmproxy < 12 exposed the raw socket so we could force a TCP RST. Keep
169+
# that behaviour for older versions to ensure tests stay reproducible.
170+
LINGER_ON, LINGER_TIMEOUT = 1, 0
171+
conn.setsockopt(
172+
socket.SOL_SOCKET,
173+
socket.SO_LINGER,
174+
struct.pack("ii", LINGER_ON, LINGER_TIMEOUT),
175+
)
176+
conn.close()
177+
else:
178+
# mitmproxy >= 12 hides the socket; flow.kill() already tears the
179+
# connection down, so there's nothing additional we can do here.
180+
pass
176181

177182
return "done"
178183

@@ -460,7 +465,7 @@ def tcp_message(flow: tcp.TCPFlow):
460465
This callback is hit every time mitmproxy receives a packet. It's the main entrypoint
461466
into this script.
462467
"""
463-
global connection_count
468+
global connection_count # noqa: F824
464469

465470
tcp_msg = flow.messages[-1]
466471

src/test/regress/pg_regress_multi.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ ()
914914
if ($mitmPid eq 0) {
915915
print("forked, about to exec mitmdump\n");
916916
setpgrp(0,0); # we're about to spawn both a shell and a mitmdump, kill them as a group
917-
exec("mitmdump --rawtcp -p $mitmPort --mode reverse:localhost:57638 -s $regressdir/mitmscripts/fluent.py --set fifo=$mitmFifoPath --set flow_detail=0 --set termlog_verbosity=warn >proxy.output 2>&1");
917+
exec("mitmdump --rawtcp -p $mitmPort --mode reverse:tcp://localhost:57638 -s $regressdir/mitmscripts/fluent.py --set fifo=$mitmFifoPath --set flow_detail=0 --set termlog_verbosity=warn --set connection_strategy=lazy >proxy.output 2>&1");
918918
die 'could not start mitmdump';
919919
}
920920
}

0 commit comments

Comments
 (0)