Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/ci/brotli-safe-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ floor='brotli-libs>=1.2.1-r0'
# Refuses IMAGE unless its installed brotli-libs meets the floor and every
# Brotli decoder its PHP links belongs to that package.
check() {
docker run --rm --network none --user 0 --entrypoint sh "$1" -c '
local checked_image
checked_image=$1
docker run --rm --network none --user 0 --entrypoint sh "$checked_image" -c '
set -eu
apk info -e "$1" > /dev/null || { echo "Composer image lacks $1" >&2; exit 1; }
for library in $(ldd "$(command -v php)" | awk "/libbrotlidec/ {print \$3}"); do
Expand Down
6 changes: 5 additions & 1 deletion scripts/ci/run-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ here=$(dirname "$0")
options=()
while (($#)) && [[ $1 != -- ]]; do
case "$1" in
*COMPOSER_CAFILE* | *COMPOSER_CAPATH* | --entrypoint* | --env-file*)
*COMPOSER_CAFILE* | *COMPOSER_CAPATH* | --entrypoint* | --env-file* | --volumes-from*)
echo "run-composer.sh sets the CA pair and the entrypoint itself; refusing $1" >&2
exit 2 ;;
*/checked-ca*)
echo "run-composer.sh reserves /checked-ca for its checked CA pair; refusing $1" >&2
exit 2 ;;
*) ;;
esac
options+=("$1")
shift
Expand Down
16 changes: 15 additions & 1 deletion tests/Unit/Support/composer_trust_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,15 @@ def wrapper(self, *arguments: str) -> tuple[subprocess.CompletedProcess[str], bo
def test_the_caller_cannot_replace_the_ca_pair_or_the_entrypoint(self) -> None:
for options in (["-e", "COMPOSER_CAFILE=/etc/ssl/certs/ca-certificates.crt"], ["-eCOMPOSER_CAFILE=/x"],
["--env", "COMPOSER_CAPATH=/etc/ssl/certs"], ["--entrypoint=sh"], ["--entrypoint", "sh"],
["--env-file", "composer.env"]):
["--env-file", "composer.env"], ["-v", "/tmp/root.pem:/checked-ca/ca.pem:ro"],
["--volume=/tmp/trust:/checked-ca:ro"],
["--mount", "type=bind,src=/tmp/empty,dst=/checked-ca/no-ca-directory"],
["--mount=type=bind,src=/tmp/empty,dst=/checked-ca/no-ca-directory"],
["--tmpfs", "/checked-ca"], ["--tmpfs=/checked-ca"],
["--device", "/dev/null:/checked-ca/ca.pem"],
["--device=/dev/null:/checked-ca/ca.pem"],
["--volumes-from", "untrusted-container"],
["--volumes-from=untrusted-container"]):
with self.subTest(options):
result, docker_called = self.wrapper("--rm", *options, "--", "install")

Expand All @@ -355,6 +363,12 @@ def test_composer_arguments_need_the_separator(self) -> None:
self.assertEqual(2, result.returncode)
self.assertFalse(docker_called)

def test_unrelated_docker_options_reach_the_pinned_image_builder(self) -> None:
result, docker_called = self.wrapper("--rm", "-v", "/tmp:/app", "--", "install")

self.assertNotEqual(2, result.returncode, result.stderr)
self.assertTrue(docker_called)

def test_the_ca_pair_and_entrypoint_follow_the_callers_options(self) -> None:
text = WRAPPER_SCRIPT.read_text()
command = text[text.index("docker run --user"):]
Expand Down
Loading