Skip to content

Commit 8260697

Browse files
build: Update WASM Rego test generation setup (#6707)
This change updates the WASM Rego test generation docker command to address CVE-2022-24765 in Git which could cause it to execute arbitrary commands. The error was seen when running the `make wasm-rego-test` target on darwin/arm64. Fixes: #6703 Signed-off-by: Ashutosh Narkar <[email protected]>
1 parent 091286b commit 8260697

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ endif
222222
.PHONY: wasm-rego-test
223223
wasm-rego-test: generate
224224
ifeq ($(DOCKER_RUNNING), 1)
225-
GOVERSION=$(GOVERSION) ./build/run-wasm-rego-tests.sh
225+
GOVERSION=$(GOVERSION) DOCKER_UID=$(DOCKER_UID) DOCKER_GID=$(DOCKER_GID) ./build/run-wasm-rego-tests.sh
226226
else
227227
@echo "Docker not installed or not running. Skipping Rego-WASM test."
228228
endif

build/run-wasm-rego-tests.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#!/usr/bin/env bash
22

33
# This script executes the Wasm Rego test cases. The script uses Docker to run
4-
# the test generation progam and then again to run the test cases inside of a
5-
# Node JS container. The script cachces the test generation program build
4+
# the test generation program and then again to run the test cases inside of a
5+
# Node JS container. The script caches the test generation program build
66
# results in the $PWD/.go directory so that it can be re-used across runs. The
77
# volumes from the test generation container are shared with the Node JS
88
# container to avoid copying the generated test cases more than necessary.
99

1010
set -ex
1111

1212
GOVERSION=${GOVERSION:?"You must set the GOVERSION environment variable."}
13+
DOCKER_UID=${DOCKER_UID:-$(id -u)}
14+
DOCKER_GID=${DOCKER_GID:-$(id -g)}
1315
ASSETS=${ASSETS:-"$PWD/test/wasm/assets"}
1416
VERBOSE=${VERBOSE:-"0"}
1517
TESTGEN_CONTAINER_NAME="opa-wasm-testgen-container"
@@ -44,14 +46,14 @@ function generate_testcases {
4446
purge_testgen_container
4547
docker run \
4648
--name $TESTGEN_CONTAINER_NAME \
47-
-u $(id -u):$(id -g) \
49+
-u $DOCKER_UID:$DOCKER_GID \
4850
-v $PWD/.go/bin:/go/bin:Z \
4951
-v $PWD:/src:z \
5052
-v $ASSETS:/assets:Z \
5153
-e GOCACHE=/src/.go/cache \
5254
-w /src \
5355
golang:$GOVERSION \
54-
sh -c 'make wasm-rego-testgen-install \
56+
sh -c 'git config --global --add safe.directory /src && make wasm-rego-testgen-install \
5557
&& wasm-rego-testgen \
5658
--input-dir=/assets \
5759
--runner=/src/test/wasm/assets/test.js \

0 commit comments

Comments
 (0)