Skip to content

Commit 844a2a3

Browse files
committed
ci: permit only the exact local emulator
1 parent 7c806be commit 844a2a3

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ jobs:
103103
run: |
104104
cd tests
105105
python tx_fixture_manifest.py --check
106-
sudo iptables -I OUTPUT 1 ! -o lo -m conntrack --ctstate NEW -j REJECT
106+
EMULATOR_IP=$(docker inspect -f \
107+
'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \
108+
"${{ job.services.kkemu.id }}")
109+
test -n "$EMULATOR_IP"
110+
sudo iptables -I OUTPUT 1 -d "$EMULATOR_IP" -j ACCEPT
111+
sudo iptables -I OUTPUT 2 ! -o lo -m conntrack --ctstate NEW -j REJECT
107112
cleanup_network_gate() {
108113
sudo iptables -D OUTPUT ! -o lo -m conntrack --ctstate NEW -j REJECT
114+
sudo iptables -D OUTPUT -d "$EMULATOR_IP" -j ACCEPT
109115
}
110116
trap cleanup_network_gate EXIT
111117
pytest -v --junitxml=junit.xml 2>&1 | tee pytest-output.txt

docs/handoff-python-test-hermeticity.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Affected surfaces:
3535
mode for every KeepKeyTest.
3636
- tests/conftest.py rejects external DNS, socket, and HTTP access per test while
3737
permitting only loopback emulator traffic and Unix-domain sockets.
38-
- .github/workflows/ci.yml checks fixture integrity, adds a kernel outbound-new-
39-
connection deny rule during authoritative pytest, and records the manifest
40-
SHA-256 in every summary.
38+
- .github/workflows/ci.yml checks fixture integrity, permits the exact local
39+
emulator container IP, rejects every other new non-loopback connection during
40+
authoritative pytest, and records the manifest SHA-256 in every summary.
4141
- tests/tx_fixture_manifest.py and tests/test_tx_fixture_integrity.py account
4242
for every fixture, reconstruct canonical transactions, recompute every txid,
4343
test cwd independence and fail-closed misses, and statically reject new

0 commit comments

Comments
 (0)