Skip to content

Commit 84ae30d

Browse files
committed
Only allow traffic via the proxy in global-proxy test
1 parent 909828c commit 84ae30d

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/__global-proxy.yml

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

pr-checks/checks/global-proxy.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ versions:
55
- nightly-latest
66
container:
77
image: ubuntu:22.04
8+
options: --cap-add=NET_ADMIN
89
services:
910
squid-proxy:
1011
image: ubuntu/squid:latest
@@ -14,6 +15,24 @@ env:
1415
https_proxy: http://squid-proxy:3128
1516
CODEQL_ACTION_TOLERATE_MISSING_GIT_VERSION: true
1617
steps:
18+
- name: Block direct internet access to force proxy usage
19+
run: |
20+
apt-get update -qq && apt-get install -y -qq iptables >/dev/null 2>&1
21+
PROXY_IP=$(getent hosts squid-proxy | awk '{ print $1 }')
22+
echo "Squid proxy IP: $PROXY_IP"
23+
# Allow all traffic to the proxy container
24+
iptables -A OUTPUT -d "$PROXY_IP" -j ACCEPT
25+
# Allow DNS resolution
26+
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
27+
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
28+
# Allow loopback
29+
iptables -A OUTPUT -o lo -j ACCEPT
30+
# Allow already-established connections (from checkout/prepare-test)
31+
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
32+
# Block all other outbound HTTP and HTTPS, ensuring direct access fails
33+
iptables -A OUTPUT -p tcp --dport 80 -j REJECT --reject-with tcp-reset
34+
iptables -A OUTPUT -p tcp --dport 443 -j REJECT --reject-with tcp-reset
35+
echo "Direct HTTP/HTTPS access is now blocked - all traffic must go through the proxy"
1736
- uses: ./../action/init
1837
with:
1938
languages: javascript

0 commit comments

Comments
 (0)