From 700c923bc566c7baa3168b3ea86730cfe773b53b Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:43:50 +1200 Subject: [PATCH 1/8] refactor: move `setup` into `bin` --- setup.sh => bin/setup | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.sh => bin/setup (100%) diff --git a/setup.sh b/bin/setup similarity index 100% rename from setup.sh rename to bin/setup From 84891e6c665bcba0056a226be941206844b15ffa Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:49:06 +1200 Subject: [PATCH 2/8] fix: make sure `bin/setup` runs from root --- bin/setup | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/setup b/bin/setup index b24ed5d8..8652dcbc 100755 --- a/bin/setup +++ b/bin/setup @@ -1,5 +1,12 @@ #!/bin/bash +set -e + +# make sure script runs from project root directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" +cd "${PROJECT_ROOT}" + # This script (attempts) to set up CWAC automatically. # Ensure Python 3.12+ is 'python'. From 0f88a94cfee3da294844f116bd74f23784f3dd33 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:07:16 +1200 Subject: [PATCH 3/8] feat: add scripts for building and running the tool through docker --- bin/build | 10 ++++++++++ bin/run | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 bin/build create mode 100755 bin/run diff --git a/bin/build b/bin/build new file mode 100755 index 00000000..13caeb51 --- /dev/null +++ b/bin/build @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +# make sure script runs from project root directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" +cd "${PROJECT_ROOT}" + +docker build -t cwac . diff --git a/bin/run b/bin/run new file mode 100755 index 00000000..f5a96532 --- /dev/null +++ b/bin/run @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +# make sure script runs from project root directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" +cd "${PROJECT_ROOT}" + +bin/build + +docker run --rm \ + --mount 'type=bind,src=./config,dst=/cwac/config' \ + --mount 'type=bind,src=./base_urls,dst=/cwac/base_urls' \ + --mount 'type=bind,src=./results,dst=/cwac/results' \ + --env CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox \ + cwac .venv/bin/python -u cwac.py "${@}" From 023fe4f0602ea163019aaa2f811324e62561c663 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:09:58 +1200 Subject: [PATCH 4/8] test: use new `bin/run` script --- tests/e2e.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/e2e.sh b/tests/e2e.sh index 1772052d..d68aa113 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -24,15 +24,4 @@ cat config/config_default.json | jq ' # make sure the "results" directory exists mkdir -p results -docker build \ - --iidfile /tmp/cwac_image_id \ - -t cwac-e2e-test-script:latest \ - --build-arg USER_ID=$(id -u) \ - --build-arg GROUP_ID=$(id -g) \ - . -docker run --rm \ - --mount "type=bind,src=./config,dst=/cwac/config" \ - --mount "type=bind,src=./base_urls,dst=/cwac/base_urls" \ - --mount "type=bind,src=./results,dst=/cwac/results" \ - -e CHROME_EXTRA_ARGS='--no-sandbox,--disable-dev-shm-usage' \ - $(cat /tmp/cwac_image_id) .venv/bin/python -u cwac.py config_e2e.json +bin/run config_e2e.json From fffd6059b995629f7c26430d5b065d089815c583 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:14:15 +1200 Subject: [PATCH 5/8] fix: use the user id and group of the current user --- bin/build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/build b/bin/build index 13caeb51..79c2c752 100755 --- a/bin/build +++ b/bin/build @@ -7,4 +7,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" cd "${PROJECT_ROOT}" -docker build -t cwac . +docker build \ + -t cwac \ + --build-arg USER_ID=$(id -u) \ + --build-arg GROUP_ID=$(id -g) \ + . From 99b6af0aad562e7ee06066f3c6c57e82d0fc294d Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:19:15 +1200 Subject: [PATCH 6/8] fix: disable sandbox and dev-shm usage --- bin/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run b/bin/run index f5a96532..68dae8d7 100755 --- a/bin/run +++ b/bin/run @@ -13,5 +13,5 @@ docker run --rm \ --mount 'type=bind,src=./config,dst=/cwac/config' \ --mount 'type=bind,src=./base_urls,dst=/cwac/base_urls' \ --mount 'type=bind,src=./results,dst=/cwac/results' \ - --env CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox \ + --env CHROME_EXTRA_ARGS='--no-sandbox,--disable-dev-shm-usage' \ cwac .venv/bin/python -u cwac.py "${@}" From ba5a5915ab0aa42b16f8a73bf49d4aecccffc3e6 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:28:16 +1200 Subject: [PATCH 7/8] feat: allow externally setting user and group id --- bin/build | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/build b/bin/build index 79c2c752..b40653c8 100755 --- a/bin/build +++ b/bin/build @@ -7,8 +7,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" cd "${PROJECT_ROOT}" +# default to the current user and group +: "${IMAGE_USER_ID:=$(id -u)}" +: "${IMAGE_GROUP_ID:=$(id -g)}" + docker build \ -t cwac \ - --build-arg USER_ID=$(id -u) \ - --build-arg GROUP_ID=$(id -g) \ + --build-arg USER_ID="$IMAGE_USER_ID" \ + --build-arg GROUP_ID="$IMAGE_GROUP_ID" \ . From 293a267a5edd043a81c3bb5485f0041902b813d8 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:59:58 +1200 Subject: [PATCH 8/8] fix: make sure the results directory exists --- bin/run | 3 +++ tests/e2e.sh | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/run b/bin/run index 68dae8d7..d72b668a 100755 --- a/bin/run +++ b/bin/run @@ -9,6 +9,9 @@ cd "${PROJECT_ROOT}" bin/build +# make sure the "results" directory exists +mkdir -p results + docker run --rm \ --mount 'type=bind,src=./config,dst=/cwac/config' \ --mount 'type=bind,src=./base_urls,dst=/cwac/base_urls' \ diff --git a/tests/e2e.sh b/tests/e2e.sh index d68aa113..06506a7e 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -21,7 +21,4 @@ cat config/config_default.json | jq ' .audit_plugins |= map_values(.enabled = true) ' > config/config_e2e.json -# make sure the "results" directory exists -mkdir -p results - bin/run config_e2e.json