Files
Ken 5ba367af2f fix: code review fixes — auth gap, path traversal, dead code, health-check timeout
- backend/app.py: add Depends(_require_auth) to /api/copilotkit endpoint (critical
  security fix — endpoint was fully unprotected; now requires valid session cookie)
- backend/app.py: move 'from ag_ui.core import RunStartedEvent' from inline function
  body to top-level imports (style consistency)
- backend/auth.py: remove dead AUTH_PASS_HASH module-level constant (verify_password
  already reads from os.environ at call time; the cached binding was unused dead code)
- backend/artifacts.py: add path traversal guards to list_artifacts, get_artifact,
  and save_artifact — resolve paths and verify they stay within ARTIFACTS_DIR
- entrypoint.sh: health-check loop now sets READY flag and exits 1 if amplifierd
  fails to start within 30s (previously fell through silently, causing 502s)
- tests/test_app.py: add TestCopilotKitAuth — verifies unauthenticated requests to
  /api/copilotkit return 401; includes note explaining why streaming is not tested here
- tests/test_structure.sh: update to reflect that Dockerfile and entrypoint.sh now
  exist (created in Tasks 7+8); convert absent-checks to presence-checks

Co-authored-by: Amplifier <amplifier@anthropic.com>
2026-05-26 18:52:12 +00:00

101 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# test_structure.sh - Verify expected repo state after task-1-clean-old-files
# RED: Run before changes (should fail)
# GREEN: Run after changes (should pass)
REPO=/home/ken/workspace/research-workbench
PASS=0
FAIL=0
check_absent() {
if [ ! -e "$REPO/$1" ]; then
echo "PASS: '$1' is absent"
((PASS++))
else
echo "FAIL: '$1' should be absent but exists"
((FAIL++))
fi
}
check_dir() {
if [ -d "$REPO/$1" ]; then
echo "PASS: directory '$1' exists"
((PASS++))
else
echo "FAIL: directory '$1' should exist but is missing"
((FAIL++))
fi
}
check_gitignore_line() {
if grep -qF "$1" "$REPO/.gitignore"; then
echo "PASS: .gitignore contains '$1'"
((PASS++))
else
echo "FAIL: .gitignore is missing '$1'"
((FAIL++))
fi
}
echo "=== Checking old car-help files are removed ==="
check_absent "search.py"
check_absent "guide.py"
check_absent "sites.yaml"
check_absent "app.py"
check_absent "static"
check_absent "results"
check_absent "pyproject.toml"
check_absent "uv.lock"
echo ""
echo "=== Checking new root-level files exist ==="
if [ -f "$REPO/Dockerfile" ]; then
echo "PASS: 'Dockerfile' exists (Task 7)"
((PASS++))
else
echo "FAIL: 'Dockerfile' should exist (Task 7) but is missing"
((FAIL++))
fi
if [ -f "$REPO/entrypoint.sh" ]; then
echo "PASS: 'entrypoint.sh' exists (Task 8)"
((PASS++))
else
echo "FAIL: 'entrypoint.sh' should exist (Task 8) but is missing"
((FAIL++))
fi
echo ""
echo "=== Checking new directories exist ==="
check_dir "backend"
check_dir "tests"
check_dir "bundle/behaviors"
check_dir "bundle/agents"
check_dir "bundle/context"
check_dir "frontend/src"
check_dir "artifacts"
check_dir "docs/plans"
echo ""
echo "=== Checking .gitignore contents ==="
# Python
check_gitignore_line ".venv/"
check_gitignore_line "__pycache__/"
check_gitignore_line "*.pyc"
check_gitignore_line "*.egg-info/"
# Node/Frontend
check_gitignore_line "frontend/node_modules/"
check_gitignore_line "frontend/dist/"
# Runtime
check_gitignore_line "artifacts/"
# IDE
check_gitignore_line ".idea/"
check_gitignore_line ".vscode/"
check_gitignore_line "*.swp"
echo ""
echo "=============================="
echo "Results: $PASS passed, $FAIL failed"
echo "=============================="
[ $FAIL -eq 0 ] && exit 0 || exit 1