Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ async def clone_workflow_at_runtime(
return False, ""

if subpath:
subpath_full = temp_dir / subpath
subpath_full = (temp_dir / subpath).resolve()
if not subpath_full.is_relative_to(temp_dir):
logger.error(f"Subpath '{subpath}' escapes clone directory")
return False, ""
if subpath_full.exists() and subpath_full.is_dir():
if workflow_final.exists():
shutil.rmtree(workflow_final)
Expand All @@ -149,10 +152,12 @@ async def clone_workflow_at_runtime(
logger.warning(f"Subpath '{subpath}' not found, using entire repo")
if workflow_final.exists():
shutil.rmtree(workflow_final)
workflow_final.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(temp_dir), str(workflow_final))
else:
if workflow_final.exists():
shutil.rmtree(workflow_final)
workflow_final.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(temp_dir), str(workflow_final))

logger.info(f"Workflow '{workflow_name}' ready at {workflow_final}")
Expand Down
8 changes: 7 additions & 1 deletion components/runners/state-sync/hydrate.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,13 @@ if [ -n "$ACTIVE_WORKFLOW_GIT_URL" ] && [ "$ACTIVE_WORKFLOW_GIT_URL" != "null" ]
echo " Available paths in repo:"
find "$WORKFLOW_TEMP" -maxdepth 3 -type d | head -10
echo " Using entire repo instead"
mkdir -p "$(dirname "$WORKFLOW_FINAL")"
mv "$WORKFLOW_TEMP" "$WORKFLOW_FINAL"
echo " ✓ Workflow ready at /workspace/workflows/${WORKFLOW_NAME}"
fi
else
# No subpath - use entire repo
mkdir -p "$(dirname "$WORKFLOW_FINAL")"
mv "$WORKFLOW_TEMP" "$WORKFLOW_FINAL"
echo " ✓ Workflow ready at /workspace/workflows/${WORKFLOW_NAME}"
fi
Expand Down Expand Up @@ -467,9 +469,13 @@ else
echo "No git repo state backup found"
fi

# Set permissions on repos after restore (repos may have been cloned or restored)
# Set permissions on repos and workflows after restore
chown -R 1001:0 /workspace/repos 2>/dev/null || true
chmod -R 777 /workspace/repos 2>/dev/null || true
if [ -d /workspace/workflows ]; then
chown -R 1001:0 /workspace/workflows 2>/dev/null || true
chmod -R 777 /workspace/workflows 2>/dev/null || true
fi

echo "========================================="
echo "Workspace initialized successfully"
Expand Down