Skip to content
Closed
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
9 changes: 9 additions & 0 deletions internal/scaffold/fullsend-repo/scripts/post-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
Expand Down
8 changes: 8 additions & 0 deletions internal/scaffold/fullsend-repo/scripts/post-prioritize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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"

Expand Down
Loading