Skip to content

Commit bd41d7c

Browse files
committed
Add codex
1 parent d12e3d5 commit bd41d7c

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ ENV \
2020
ARG \
2121
# renovate: datasource=npm depName=@anthropic-ai/claude-code
2222
CLAUDE_CLI_VERSION=2.1.42 \
23+
# renovate: datasource=npm depName=@openai/codex
24+
CODEX_CLI_VERSION=0.101.0 \
2325
# renovate: datasource=npm depName=@google/gemini-cli
2426
GEMINI_CLI_VERSION=0.28.2 \
2527
# renovate: datasource=npm depName=opencode-ai
2628
OPENCODE_AI_VERSION=1.2.1
2729

2830
RUN npm install -g \
2931
"@anthropic-ai/claude-code@$CLAUDE_CLI_VERSION" \
32+
"@openai/codex@$CODEX_CLI_VERSION" \
3033
"@google/gemini-cli@$GEMINI_CLI_VERSION" \
3134
"opencode-ai@$OPENCODE_AI_VERSION"
3235

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cli-sandbox
22

3-
Run `claude`, `gemini` or `opencode` in a docker container.
3+
Run `claude`, `codex`, `gemini` or `opencode` in a docker container.
44

55
`iptables` is used inside the container to block all outbound traffic except GitHub, Anthropic, and Google Cloud internal IPs.
66

@@ -46,8 +46,8 @@ ccli() {
4646
fi
4747

4848
local cli=$1
49-
if [ "$cli" ] != "opencode" ] && [ "$cli" != "claude" ] && [ "$cli" != "gemini" ]; then
50-
echo "Need to pass opencode, gemini, or claude"
49+
if [ "$cli" != "opencode" ] && [ "$cli" != "codex" ] && [ "$cli" != "claude" ] && [ "$cli" != "gemini" ]; then
50+
echo "Need to pass opencode, codex, gemini, or claude"
5151
return
5252
fi
5353

@@ -84,6 +84,10 @@ claude() {
8484
ccli claude
8585
}
8686

87+
codex() {
88+
ccli codex
89+
}
90+
8791
opencode() {
8892
ccli opencode
8993
}

init-firewall.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ iptables -t nat -F
1212
iptables -t nat -X
1313
iptables -t mangle -F
1414
iptables -t mangle -X
15-
ipset destroy github-anthropic 2>/dev/null || true
15+
ipset destroy general 2>/dev/null || true
1616
ipset destroy google-all-ips 2>/dev/null || true
1717
ipset destroy google-customer-ips 2>/dev/null || true
1818

@@ -32,7 +32,7 @@ iptables -A INPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
3232
iptables -A INPUT -i lo -j ACCEPT
3333
iptables -A OUTPUT -o lo -j ACCEPT
3434

35-
ipset create github-anthropic hash:net
35+
ipset create general hash:net
3636
ipset create google-all-ips hash:net
3737
ipset create google-customer-ips hash:net
3838

@@ -53,11 +53,13 @@ while read -r cidr; do
5353
exit 1
5454
fi
5555
echo "Adding GitHub range $cidr"
56-
ipset add github-anthropic "$cidr"
56+
ipset add general "$cidr"
5757
done < <(echo "$gh_ranges" | jq -r '(.web + .api + .git)[]' | aggregate -q)
5858

5959
for domain in \
6060
"api.anthropic.com" \
61+
"api.openai.com" \
62+
"auth.openai.com" \
6163
"generativelanguage.googleapis.com" \
6264
"googleapis.l.google.com"; do
6365
echo "Resolving $domain..."
@@ -73,7 +75,7 @@ for domain in \
7375
exit 1
7476
fi
7577
echo "Adding $ip for $domain"
76-
ipset add github-anthropic "$ip" || continue
78+
ipset add general "$ip" || continue
7779
done < <(echo "$ips")
7880
done
7981

@@ -127,10 +129,10 @@ iptables -P OUTPUT DROP
127129
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
128130
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
129131

130-
# Allow GitHub and Anthropic
131-
iptables -A OUTPUT -m set --match-set github-anthropic dst -j ACCEPT
132+
# Allow the general set of IPs
133+
iptables -A OUTPUT -m set --match-set general dst -j ACCEPT
132134
# Block all gcloud customer IPs
133-
# since this rule is after github-anthropic ACCEPT it shouldn't block any IPs in both sets
135+
# since this rule is after general ACCEPT it shouldn't block any IPs in both sets
134136
iptables -A OUTPUT -m set --match-set google-customer-ips dst -j REJECT --reject-with icmp-admin-prohibited
135137
# Allow complement set of all gcloud IPs and customer gcloud IPs
136138
# since this rule is after google-customer-ips REJECT

0 commit comments

Comments
 (0)