Skip to content

Commit fa4ef5d

Browse files
test: enforce strict replay sandboxing in e2e fixtures
1 parent 4957ecb commit fa4ef5d

40 files changed

Lines changed: 162 additions & 31 deletions

File tree

drift/instrumentation/aiohttp/e2e-tests/.tusk/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ recording:
2525

2626
replay:
2727
enable_telemetry: false
28+
sandbox:
29+
mode: strict
2830

drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
dockerfile: drift/instrumentation/aiohttp/e2e-tests/Dockerfile
1515
args:
1616
- TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest}
17+
cap_add:
18+
- SYS_ADMIN
19+
security_opt:
20+
- seccomp=unconfined
21+
- apparmor=unconfined
1722
environment:
1823
- PORT=8000
1924
- TUSK_ANALYTICS_DISABLED=1

drift/instrumentation/django/e2e-tests/.tusk/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ recording:
2525

2626
replay:
2727
enable_telemetry: false
28+
sandbox:
29+
mode: strict

drift/instrumentation/django/e2e-tests/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
dockerfile: drift/instrumentation/django/e2e-tests/Dockerfile
1515
args:
1616
- TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest}
17+
cap_add:
18+
- SYS_ADMIN
19+
security_opt:
20+
- seccomp=unconfined
21+
- apparmor=unconfined
1722
environment:
1823
- PORT=8000
1924
- TUSK_ANALYTICS_DISABLED=1

drift/instrumentation/e2e_common/Dockerfile.base

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This base image contains:
44
# - Python 3.9 (minimum supported version)
55
# - Tusk CLI (for running replay tests)
6-
# - System utilities (curl, postgresql-client)
6+
# - System utilities (curl, postgresql-client, socat, bubblewrap)
77
#
88
# Build this image before running e2e tests:
99
# docker build -t python-e2e-base:latest -f drift/instrumentation/e2e-common/Dockerfile.base .
@@ -12,38 +12,40 @@ FROM python:3.9-slim
1212

1313
# Install system dependencies
1414
RUN apt-get update && apt-get install -y --no-install-recommends \
15-
curl \
16-
postgresql-client \
17-
&& rm -rf /var/lib/apt/lists/*
15+
curl \
16+
postgresql-client \
17+
socat \
18+
bubblewrap \
19+
&& rm -rf /var/lib/apt/lists/*
1820

1921
# Install Tusk CLI
2022
# The CLI is downloaded from GitHub releases (tar.gz archives)
2123
ARG TUSK_CLI_VERSION=latest
2224
RUN set -ex && \
23-
if [ "$TUSK_CLI_VERSION" = "latest" ]; then \
24-
# Get the latest version tag
25-
VERSION=$(curl -s https://api.github.com/repos/Use-Tusk/tusk-drift-cli/releases/latest | grep '"tag_name"' | cut -d '"' -f 4); \
26-
else \
27-
VERSION="${TUSK_CLI_VERSION}"; \
28-
fi && \
29-
# Remove 'v' prefix if present for the filename
30-
VERSION_NUM=$(echo "$VERSION" | sed 's/^v//') && \
31-
# Detect architecture (x86_64 or arm64)
32-
ARCH=$(uname -m) && \
33-
case "$ARCH" in \
34-
x86_64) ARCH_NAME="x86_64" ;; \
35-
aarch64|arm64) ARCH_NAME="arm64" ;; \
36-
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
37-
esac && \
38-
# Construct download URL (archives are named like tusk-drift-cli_0.1.35_Linux_x86_64.tar.gz)
39-
DOWNLOAD_URL="https://github.com/Use-Tusk/tusk-drift-cli/releases/download/${VERSION}/tusk-drift-cli_${VERSION_NUM}_Linux_${ARCH_NAME}.tar.gz" && \
40-
echo "Downloading Tusk CLI from: $DOWNLOAD_URL" && \
41-
curl -fsSL "$DOWNLOAD_URL" -o /tmp/tusk.tar.gz && \
42-
tar -xzf /tmp/tusk.tar.gz -C /tmp && \
43-
mv /tmp/tusk /usr/local/bin/tusk && \
44-
chmod +x /usr/local/bin/tusk && \
45-
rm -rf /tmp/tusk.tar.gz /tmp/LICENSE /tmp/README.md && \
46-
tusk --version
25+
if [ "$TUSK_CLI_VERSION" = "latest" ]; then \
26+
# Get the latest version tag
27+
VERSION=$(curl -s https://api.github.com/repos/Use-Tusk/tusk-drift-cli/releases/latest | grep '"tag_name"' | cut -d '"' -f 4); \
28+
else \
29+
VERSION="${TUSK_CLI_VERSION}"; \
30+
fi && \
31+
# Remove 'v' prefix if present for the filename
32+
VERSION_NUM=$(echo "$VERSION" | sed 's/^v//') && \
33+
# Detect architecture (x86_64 or arm64)
34+
ARCH=$(uname -m) && \
35+
case "$ARCH" in \
36+
x86_64) ARCH_NAME="x86_64" ;; \
37+
aarch64|arm64) ARCH_NAME="arm64" ;; \
38+
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
39+
esac && \
40+
# Construct download URL (archives are named like tusk-drift-cli_0.1.35_Linux_x86_64.tar.gz)
41+
DOWNLOAD_URL="https://github.com/Use-Tusk/tusk-drift-cli/releases/download/${VERSION}/tusk-drift-cli_${VERSION_NUM}_Linux_${ARCH_NAME}.tar.gz" && \
42+
echo "Downloading Tusk CLI from: $DOWNLOAD_URL" && \
43+
curl -fsSL "$DOWNLOAD_URL" -o /tmp/tusk.tar.gz && \
44+
tar -xzf /tmp/tusk.tar.gz -C /tmp && \
45+
mv /tmp/tusk /usr/local/bin/tusk && \
46+
chmod +x /usr/local/bin/tusk && \
47+
rm -rf /tmp/tusk.tar.gz /tmp/LICENSE /tmp/README.md && \
48+
tusk --version
4749

4850
# Upgrade pip
4951
RUN pip install --upgrade pip

drift/instrumentation/fastapi/e2e-tests/.tusk/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ recording:
2525

2626
replay:
2727
enable_telemetry: false
28+
sandbox:
29+
mode: strict
2830

drift/instrumentation/fastapi/e2e-tests/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
dockerfile: drift/instrumentation/fastapi/e2e-tests/Dockerfile
1515
args:
1616
- TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest}
17+
cap_add:
18+
- SYS_ADMIN
19+
security_opt:
20+
- seccomp=unconfined
21+
- apparmor=unconfined
1722
environment:
1823
- PORT=8000
1924
- TUSK_ANALYTICS_DISABLED=1

drift/instrumentation/fastapi/e2e-tests/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
fastapi>=0.115.0
33
uvicorn>=0.30.0
44
requests>=2.32.5
5-
httpx>=0.27.0
5+
# Strict replay sandbox routes outbound HTTP through a SOCKS proxy.
6+
httpx[socks]>=0.27.0
67

drift/instrumentation/flask/e2e-tests/.tusk/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ recording:
2525

2626
replay:
2727
enable_telemetry: false
28+
sandbox:
29+
mode: strict
2830

drift/instrumentation/flask/e2e-tests/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
dockerfile: drift/instrumentation/flask/e2e-tests/Dockerfile
1515
args:
1616
- TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest}
17+
cap_add:
18+
- SYS_ADMIN
19+
security_opt:
20+
- seccomp=unconfined
21+
- apparmor=unconfined
1722
environment:
1823
- PORT=8000
1924
- TUSK_ANALYTICS_DISABLED=1

0 commit comments

Comments
 (0)