-
Notifications
You must be signed in to change notification settings - Fork 0
fix(#235): add fallback path resolution for companion scripts in post-scripts #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -301,8 +301,17 @@ fi | |
| export GH_TOKEN="${PUSH_TOKEN}" | ||
|
|
||
| # Locate process-fix-result.py relative to this script. | ||
| # When this script runs from a content-addressed cache path | ||
| # (sha256/<hash>/content), companion files are not co-located. | ||
| # Fall back to ${FULLSEND_DIR}/scripts if the companion is missing. | ||
| # FULLSEND_DIR is required (fail-closed) to avoid silently resolving to cwd. | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROCESS_SCRIPT="${SCRIPT_DIR}/process-fix-result.py" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] integrity The fallback from the content-addressed cache path to ${FULLSEND_DIR}/scripts loses the integrity guarantee provided by the SHA-256 hash in the cache path. Consider logging when the fallback activates to aid debugging. Suggested fix: Add a log line when the fallback path is taken: echo "::notice::Companion not found at cache path, using fallback: ${SCRIPT_DIR}" |
||
| if [ ! -f "${PROCESS_SCRIPT}" ] && [ -d "${FULLSEND_DIR:?FULLSEND_DIR must be set}/scripts" ]; then | ||
| SCRIPT_DIR="${FULLSEND_DIR}/scripts" | ||
| PROCESS_SCRIPT="${SCRIPT_DIR}/process-fix-result.py" | ||
| echo "Using fallback companion path: ${SCRIPT_DIR}" | ||
| fi | ||
|
|
||
| # Find fix-result.json in the output directory. | ||
| # RUN_DIR is the original cwd (runDir = <outputBase>/<sandboxName>), saved | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,14 @@ | |
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # When this script runs from a content-addressed cache path | ||
| # (sha256/<hash>/content), companion files are not co-located. | ||
| # Fall back to ${FULLSEND_DIR}/scripts if the companion is missing. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] fail-open Same ${FULLSEND_DIR:-.} pattern as post-fix.sh. The source command at line 17 executes code from the resolved path — a fail-closed default is preferable for defense-in-depth. Suggested fix: Replace ${FULLSEND_DIR:-.} with ${FULLSEND_DIR:?FULLSEND_DIR must be set}. |
||
| # FULLSEND_DIR is required (fail-closed) to avoid silently resolving to cwd. | ||
| if [ ! -f "${SCRIPT_DIR}/lib/github-api-csma.sh" ] && [ -d "${FULLSEND_DIR:?FULLSEND_DIR must be set}/scripts/lib" ]; then | ||
| SCRIPT_DIR="${FULLSEND_DIR}/scripts" | ||
| echo "Using fallback companion path: ${SCRIPT_DIR}" | ||
| fi | ||
| # shellcheck source=lib/github-api-csma.sh | ||
| source "${SCRIPT_DIR}/lib/github-api-csma.sh" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] fail-open
${FULLSEND_DIR:-.} falls back to '.' (the post-script's working directory, which is the agent output directory) when FULLSEND_DIR is unset. While FULLSEND_DIR is always set in CI and the sandboxed agent cannot write to the host runDir, the fail-open default is unnecessary. Using ${FULLSEND_DIR:?FULLSEND_DIR must be set} would make this fail-closed at no functional cost.
Suggested fix: Replace ${FULLSEND_DIR:-.} with ${FULLSEND_DIR:?FULLSEND_DIR must be set} in both scripts.