Skip to content

Commit 28ee296

Browse files
authored
fix(e2e): clean up temp files in sandbox-runner on exit (#1647)
1 parent e98ea3e commit 28ee296

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

e2e/policy-advisor/sandbox-runner.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
set -euo pipefail
77

8+
_td="$(mktemp -d)"
9+
trap 'rm -rf "$_td"' EXIT
10+
811
cmd="$1"
912
shift
1013

@@ -23,7 +26,7 @@ case "$cmd" in
2326
;;
2427

2528
current-policy)
26-
body="$(mktemp)"
29+
body="$_td/body"
2730
status="$(curl -sS -o "$body" -w "%{http_code}" http://policy.local/v1/policy/current)"
2831
json_status_response "$status" "$body"
2932
;;
@@ -34,8 +37,8 @@ case "$cmd" in
3437
branch="$3"
3538
file_path="$4"
3639
run_id="$5"
37-
body="$(mktemp)"
38-
payload="$(mktemp)"
40+
body="$_td/body"
41+
payload="$_td/payload"
3942

4043
python3 - "$branch" "$run_id" > "$payload" <<'PY'
4144
import base64
@@ -76,8 +79,8 @@ PY
7679
owner="$1"
7780
repo="$2"
7881
file_path="$3"
79-
body="$(mktemp)"
80-
payload="$(mktemp)"
82+
body="$_td/body"
83+
payload="$_td/payload"
8184

8285
python3 - "$owner" "$repo" "$file_path" > "$payload" <<'PY'
8386
import json
@@ -140,8 +143,8 @@ PY
140143
# — we never make outbound calls, the gateway just persists the
141144
# chunk and the reviewer decides on it.
142145
rule_id="$1"
143-
body="$(mktemp)"
144-
payload="$(mktemp)"
146+
body="$_td/body"
147+
payload="$_td/payload"
145148

146149
python3 - "$rule_id" > "$payload" <<'PY'
147150
import json
@@ -184,7 +187,7 @@ PY
184187

185188
proposal-status)
186189
chunk_id="$1"
187-
body="$(mktemp)"
190+
body="$_td/body"
188191
status="$(curl -sS \
189192
-o "$body" \
190193
-w "%{http_code}" \
@@ -195,7 +198,7 @@ PY
195198
proposal-wait)
196199
chunk_id="$1"
197200
timeout="${2:-60}"
198-
body="$(mktemp)"
201+
body="$_td/body"
199202
# No --max-time on curl: the server bounds the wait at `timeout`,
200203
# which is already clamped to [1, 300] by policy.local. Let the
201204
# request return naturally.

0 commit comments

Comments
 (0)