Skip to content

Commit 7f0367c

Browse files
Pigbibicodex
andauthored
fix: restore lifecycle preflight workspace layout (#235)
* fix: restore lifecycle preflight workspace layout Co-Authored-By: Codex <noreply@openai.com> * fix: isolate lifecycle preflight restore Co-Authored-By: Codex <noreply@openai.com> * fix: validate lifecycle restore destinations Co-Authored-By: Codex <noreply@openai.com> --------- Co-authored-by: Codex <noreply@openai.com>
1 parent fa20754 commit 7f0367c

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

.github/workflows/reusable-drift-check.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,49 @@ jobs:
159159
uses: actions/download-artifact@v4
160160
with:
161161
name: ${{ inputs.lifecycle_preflight_artifact }}
162-
path: ${{ env.LIFECYCLE_LOCAL_ROOT }}
162+
path: ${{ runner.temp }}/lifecycle-preflight
163+
164+
- name: Restore lifecycle preflight inputs
165+
if: inputs.lifecycle_preflight_artifact != ''
166+
env:
167+
PREFLIGHT_BUNDLE_ROOT: ${{ runner.temp }}/lifecycle-preflight
168+
SNAPSHOT_CHECKOUT_PATH: ${{ inputs.snapshot_checkout_path }}
169+
shell: bash
170+
run: |
171+
set -euo pipefail
172+
case "$SNAPSHOT_CHECKOUT_PATH" in
173+
external/*) ;;
174+
*) echo "::error::snapshot_checkout_path must remain under external/"; exit 1 ;;
175+
esac
176+
if [[ "$SNAPSHOT_CHECKOUT_PATH" == *".."* ]]; then
177+
echo "::error::snapshot_checkout_path must not contain traversal segments"
178+
exit 1
179+
fi
180+
if find "$PREFLIGHT_BUNDLE_ROOT" -type l -print -quit | grep -q .; then
181+
echo "::error::lifecycle preflight artifact must not contain symlinks"
182+
exit 1
183+
fi
184+
lifecycle_source="$PREFLIGHT_BUNDLE_ROOT/data/lifecycle_store"
185+
snapshot_source="$PREFLIGHT_BUNDLE_ROOT/$SNAPSHOT_CHECKOUT_PATH/data/output"
186+
if [ ! -d "$lifecycle_source" ] || [ ! -d "$snapshot_source" ]; then
187+
echo "::error::lifecycle preflight artifact is missing required allowlisted directories"
188+
exit 1
189+
fi
190+
snapshot_root="$GITHUB_WORKSPACE/$SNAPSHOT_CHECKOUT_PATH"
191+
resolved_snapshot_root="$(realpath "$snapshot_root")"
192+
case "$resolved_snapshot_root" in
193+
"$GITHUB_WORKSPACE"/external/*) ;;
194+
*) echo "::error::snapshot checkout resolved outside the external workspace"; exit 1 ;;
195+
esac
196+
if find "$snapshot_root" -type l -print -quit | grep -q .; then
197+
echo "::error::snapshot checkout must not contain symlinks"
198+
exit 1
199+
fi
200+
snapshot_target="$snapshot_root/data/output"
201+
rm -rf -- "$LIFECYCLE_LOCAL_ROOT" "$snapshot_target"
202+
mkdir -p "$LIFECYCLE_LOCAL_ROOT" "$GITHUB_WORKSPACE/$SNAPSHOT_CHECKOUT_PATH/data/output"
203+
cp -a "$lifecycle_source/." "$LIFECYCLE_LOCAL_ROOT/"
204+
cp -a "$snapshot_source/." "$snapshot_target/"
163205
164206
- name: Build lifecycle performance snapshots
165207
run: quant-lifecycle monitor --domain ${{ inputs.strategy_domain }}

tests/test_reusable_drift_workflow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def test_reusable_drift_workflow_enforces_lifecycle_preflight() -> None:
4444
assert "Download lifecycle preflight artifact" in workflow
4545
assert "actions/download-artifact@v4" in workflow
4646
assert "name: ${{ inputs.lifecycle_preflight_artifact }}" in workflow
47+
assert "path: ${{ runner.temp }}/lifecycle-preflight" in workflow
48+
assert "Restore lifecycle preflight inputs" in workflow
49+
assert "snapshot_checkout_path must remain under external/" in workflow
50+
assert "lifecycle preflight artifact must not contain symlinks" in workflow
51+
assert "snapshot checkout resolved outside the external workspace" in workflow
52+
assert "snapshot checkout must not contain symlinks" in workflow
53+
assert 'rm -rf -- "$LIFECYCLE_LOCAL_ROOT" "$snapshot_target"' in workflow
54+
assert 'cp -a "$lifecycle_source/." "$LIFECYCLE_LOCAL_ROOT/"' in workflow
4755
assert 'GH_TOKEN: ${{ github.token }}' in workflow
4856
assert 'os.environ["CODEX_AUDIT_ORG"] = owner' in workflow
4957
assert 'os.environ["CODEX_AUDIT_ORCHESTRATOR_REPO"] = repository' in workflow

0 commit comments

Comments
 (0)