Skip to content

Commit 37b4ccf

Browse files
CopilotPDowney
andauthored
CI: improve path resolution consistency and restrict sudo environment variable exposure
Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/d62f3708-eedf-47cb-848d-974f0adff688 Co-authored-by: PDowney <[email protected]>
1 parent 6bcf5c6 commit 37b4ccf

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Changes are organized by date, with the most recent changes listed first.
66

77
## 2026-04-10
88

9+
### 🔒 CI SCRIPT SECURITY AND CONSISTENCY IMPROVEMENTS
10+
11+
- Updated `ALLOWED_LOG_BASE_DIR` in `scripts/ci/run-install-step.sh` to use `realpath "$(pwd)"` instead of `pwd -P` for consistency with the `ALLOWED_INSTALL_DIR` resolution on line 15.
12+
- Updated `RESOLVED_LOG_PARENT` in `scripts/ci/run-install-step.sh` to use `realpath` instead of `cd ... && pwd -P`, making path resolution more explicit and avoiding an unnecessary directory change.
13+
- Replaced `sudo -E` with explicit `--preserve-env` flags (`CI_ENVIRONMENT`, `DEBIAN_FRONTEND`, `NEEDRESTART_MODE`, `NEEDRESTART_SUSPEND`) in `scripts/ci/run-install-step.sh` to limit environment variable exposure when running install scripts with elevated privileges.
14+
15+
16+
917
### 🐛 VHOST IMPORT LOGGING / EXTRACTION FLOW FIXES
1018

1119
- Removed a duplicate WordPress extraction block in `scripts/functions/vhost/vhost-import.sh` that re-ran archive extraction and wp-config path detection after those steps had already completed.

scripts/ci/run-install-step.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ case "$CANONICAL_INSTALL_SCRIPT_PATH" in
4040
;;
4141
esac
4242

43-
ALLOWED_LOG_BASE_DIR="$(pwd -P)"
43+
ALLOWED_LOG_BASE_DIR="$(realpath "$(pwd)")"
4444
LOG_PARENT_DIR="$(dirname -- "$LOG_PATH")"
4545
LOG_FILENAME="$(basename -- "$LOG_PATH")"
4646

@@ -49,7 +49,7 @@ if [ ! -d "$LOG_PARENT_DIR" ]; then
4949
exit 1
5050
fi
5151

52-
RESOLVED_LOG_PARENT="$(cd "$LOG_PARENT_DIR" 2>/dev/null && pwd -P)"
52+
RESOLVED_LOG_PARENT="$(realpath "$LOG_PARENT_DIR" 2>/dev/null || true)"
5353

5454
if [ -z "${RESOLVED_LOG_PARENT:-}" ]; then
5555
echo "Error: unable to resolve log directory path: $LOG_PARENT_DIR" >&2
@@ -104,7 +104,8 @@ export DEBIAN_FRONTEND=noninteractive
104104
export NEEDRESTART_MODE=a
105105
export NEEDRESTART_SUSPEND=1
106106
timeout "$TIMEOUT_SECONDS" \
107-
sudo -E bash "$CANONICAL_INSTALL_SCRIPT_PATH" 2>&1 | tee -a "$LOG_PATH"
107+
sudo --preserve-env=CI_ENVIRONMENT --preserve-env=DEBIAN_FRONTEND --preserve-env=NEEDRESTART_MODE --preserve-env=NEEDRESTART_SUSPEND \
108+
bash "$CANONICAL_INSTALL_SCRIPT_PATH" 2>&1 | tee -a "$LOG_PATH"
108109
PIPE_EXIT_CODES=("${PIPESTATUS[@]}")
109110
SCRIPT_EXIT_CODE="${PIPE_EXIT_CODES[0]}"
110111
TEE_EXIT_CODE="${PIPE_EXIT_CODES[1]}"

0 commit comments

Comments
 (0)