From 24a00df94eb415ca03e703067bbc729dfd905ce0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:31:27 +0000 Subject: [PATCH 1/3] Initial plan From 32dbd2345a2412da1a3d342ba4afe2c5dfc9d822 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:35:35 +0000 Subject: [PATCH 2/3] Fix malformed aliases by using temp file instead of embedding ALIASES_BLOCK in bash -c string Agent-Logs-Url: https://github.com/microsoft/codespace-features/sessions/5148a449-0bbd-4e16-b7b4-a4629bee57c0 Co-authored-by: markphip <933108+markphip@users.noreply.github.com> --- src/artifacts-helper/devcontainer-feature.json | 2 +- src/artifacts-helper/install.sh | 9 +++++++-- test/artifacts-helper/test_shim_integration.sh | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/artifacts-helper/devcontainer-feature.json b/src/artifacts-helper/devcontainer-feature.json index 3c8cfea..b7af517 100644 --- a/src/artifacts-helper/devcontainer-feature.json +++ b/src/artifacts-helper/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Azure Artifacts Credential Helper", "id": "artifacts-helper", - "version": "3.0.7", + "version": "3.0.8", "description": "Configures Codespace to authenticate with Azure Artifact feeds", "options": { "nugetURIPrefixes": { diff --git a/src/artifacts-helper/install.sh b/src/artifacts-helper/install.sh index 3e362da..2f78cca 100755 --- a/src/artifacts-helper/install.sh +++ b/src/artifacts-helper/install.sh @@ -131,14 +131,19 @@ for ALIAS in "${ALIASES_ARR[@]}"; do ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }"$'\n' done +_TEMP_BLOCK=$(mktemp) +printf '%s' "$ALIASES_BLOCK" > "$_TEMP_BLOCK" + for TARGET_FILE in "${TARGET_FILES_ARR[@]}"; do if [ "${INSTALL_WITH_SUDO}" = "true" ]; then - sudo -u ${_REMOTE_USER} bash -c "printf '%s' \"$ALIASES_BLOCK\" >> $TARGET_FILE" + sudo -u ${_REMOTE_USER} bash -c "cat '$_TEMP_BLOCK' >> $TARGET_FILE" else - printf '%s' "$ALIASES_BLOCK" >> "$TARGET_FILE" || true + cat "$_TEMP_BLOCK" >> "$TARGET_FILE" || true fi done +rm -f "$_TEMP_BLOCK" + if [ "${INSTALL_WITH_SUDO}" = "true" ]; then sudo -u ${_REMOTE_USER} bash -c "/tmp/install-provider.sh ${USENET6}" fi diff --git a/test/artifacts-helper/test_shim_integration.sh b/test/artifacts-helper/test_shim_integration.sh index fff526a..a4500ec 100755 --- a/test/artifacts-helper/test_shim_integration.sh +++ b/test/artifacts-helper/test_shim_integration.sh @@ -29,6 +29,10 @@ check "npm shell function written to bash.bashrc" grep -q "npm()" /etc/bash.bash check "dotnet shell function written to bash.bashrc" grep -q "dotnet()" /etc/bash.bashrc check "npm shell function on its own line in bash.bashrc" grep -q "^npm()" /etc/bash.bashrc +# Verify aliases include proper quoting and argument passing ($@) +check "dotnet alias has quoted path and passes args" grep -q 'dotnet() { ".*/dotnet" "\$@"; }' /etc/bash.bashrc +check "npm alias has quoted path and passes args" grep -q 'npm() { ".*/npm" "\$@"; }' /etc/bash.bashrc + # Verify newlines between shim definitions (each function should be on its own line) check "each shim function is on its own line" bash -c ' # Count function definitions at line starts - with proper newlines each will start at column 0 From c3ece68d04513165d80b670e0e8392ab707a5690 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:36:24 +0000 Subject: [PATCH 3/3] Quote _REMOTE_USER variable to prevent word splitting Agent-Logs-Url: https://github.com/microsoft/codespace-features/sessions/5148a449-0bbd-4e16-b7b4-a4629bee57c0 Co-authored-by: markphip <933108+markphip@users.noreply.github.com> --- src/artifacts-helper/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/artifacts-helper/install.sh b/src/artifacts-helper/install.sh index 2f78cca..d6e0fd4 100755 --- a/src/artifacts-helper/install.sh +++ b/src/artifacts-helper/install.sh @@ -136,7 +136,7 @@ printf '%s' "$ALIASES_BLOCK" > "$_TEMP_BLOCK" for TARGET_FILE in "${TARGET_FILES_ARR[@]}"; do if [ "${INSTALL_WITH_SUDO}" = "true" ]; then - sudo -u ${_REMOTE_USER} bash -c "cat '$_TEMP_BLOCK' >> $TARGET_FILE" + sudo -u "${_REMOTE_USER}" bash -c "cat '$_TEMP_BLOCK' >> $TARGET_FILE" else cat "$_TEMP_BLOCK" >> "$TARGET_FILE" || true fi