2026-01-28 14:57:30 +00:00
|
|
|
@echo off
|
2026-02-01 00:00:23 +11:00
|
|
|
setlocal enabledelayedexpansion
|
2026-01-28 14:57:30 +00:00
|
|
|
REM Quick setup script for Windows
|
2026-02-01 00:00:23 +11:00
|
|
|
REM Run as Administrator: setup.bat
|
2026-02-01 00:29:32 +11:00
|
|
|
REM
|
|
|
|
|
REM SECURITY: This script validates environment before executing
|
|
|
|
|
REM to prevent path manipulation attacks.
|
2026-01-28 14:57:30 +00:00
|
|
|
|
|
|
|
|
echo === Host UK Developer Workspace Setup ===
|
|
|
|
|
echo.
|
|
|
|
|
|
|
|
|
|
REM Check for admin rights
|
|
|
|
|
net session >nul 2>&1
|
2026-02-01 00:00:23 +11:00
|
|
|
if !errorlevel! neq 0 (
|
2026-01-28 14:57:30 +00:00
|
|
|
echo ERROR: Please run this script as Administrator
|
|
|
|
|
echo Right-click and select "Run as administrator"
|
|
|
|
|
pause
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-01 00:29:32 +11:00
|
|
|
REM === SECURITY: Validate LOCALAPPDATA ===
|
|
|
|
|
REM Ensure LOCALAPPDATA is set and appears to be within user profile
|
|
|
|
|
if "%LOCALAPPDATA%"=="" (
|
|
|
|
|
echo ERROR: LOCALAPPDATA environment variable is not set
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if "%USERPROFILE%"=="" (
|
|
|
|
|
echo ERROR: USERPROFILE environment variable is not set
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM Check that LOCALAPPDATA starts with USERPROFILE (basic validation)
|
|
|
|
|
REM This prevents redirection attacks where LOCALAPPDATA points elsewhere
|
|
|
|
|
echo !LOCALAPPDATA! | findstr /i /b /c:"!USERPROFILE!" >nul
|
|
|
|
|
if !errorlevel! neq 0 (
|
|
|
|
|
echo ERROR: LOCALAPPDATA does not appear to be within user profile
|
|
|
|
|
echo LOCALAPPDATA: !LOCALAPPDATA!
|
|
|
|
|
echo USERPROFILE: !USERPROFILE!
|
|
|
|
|
echo This may indicate a path manipulation attack. Aborting.
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-01 00:40:58 +11:00
|
|
|
REM Validate paths don't contain suspicious characters that could enable injection
|
|
|
|
|
REM Blocks: < > | & ^ ` %% (shell metacharacters)
|
|
|
|
|
echo !LOCALAPPDATA! | findstr /r "[<>|&^`]" >nul
|
2026-02-01 00:29:32 +11:00
|
|
|
if !errorlevel! equ 0 (
|
2026-02-01 00:40:58 +11:00
|
|
|
echo ERROR: LOCALAPPDATA contains invalid shell characters
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
2026-02-01 00:46:46 +11:00
|
|
|
REM Check for percent signs (both single and double)
|
|
|
|
|
set "TEMP_CHECK=!LOCALAPPDATA!"
|
|
|
|
|
set "TEMP_CHECK=!TEMP_CHECK:%%=!"
|
|
|
|
|
if not "!TEMP_CHECK!"=="!LOCALAPPDATA!" (
|
2026-02-01 00:40:58 +11:00
|
|
|
echo ERROR: LOCALAPPDATA contains percent signs
|
2026-02-01 00:29:32 +11:00
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM === Install dependencies ===
|
2026-01-28 14:57:30 +00:00
|
|
|
echo Installing dependencies...
|
2026-02-01 00:00:23 +11:00
|
|
|
call powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-deps.ps1"
|
|
|
|
|
if !errorlevel! neq 0 goto :error
|
2026-01-28 14:57:30 +00:00
|
|
|
|
2026-02-01 00:29:32 +11:00
|
|
|
REM === Install core CLI ===
|
2026-01-28 14:57:30 +00:00
|
|
|
echo.
|
|
|
|
|
echo Installing core CLI...
|
2026-02-01 00:00:23 +11:00
|
|
|
call powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-core.ps1"
|
|
|
|
|
if !errorlevel! neq 0 goto :error
|
2026-01-28 14:57:30 +00:00
|
|
|
|
2026-02-01 00:29:32 +11:00
|
|
|
REM === Validate install path before use ===
|
|
|
|
|
set "CORE_PATH=!LOCALAPPDATA!\Programs\core"
|
2026-01-28 14:57:30 +00:00
|
|
|
|
2026-02-01 00:29:32 +11:00
|
|
|
REM Verify the path exists and is a directory (not a symlink to elsewhere)
|
|
|
|
|
if not exist "!CORE_PATH!\core.exe" (
|
|
|
|
|
echo ERROR: core.exe not found at !CORE_PATH!\core.exe
|
2026-02-01 00:00:23 +11:00
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-01 00:40:58 +11:00
|
|
|
REM Check if it's a symlink/junction using fsutil (more reliable than attributes)
|
|
|
|
|
fsutil reparsepoint query "!CORE_PATH!" >nul 2>&1
|
|
|
|
|
if !errorlevel! equ 0 (
|
|
|
|
|
echo ERROR: Install directory is a reparse point (symlink or junction^)
|
|
|
|
|
echo This may indicate a symlink attack. Aborting.
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM Fallback: also check attributes for symlink indicator
|
2026-02-01 00:29:32 +11:00
|
|
|
for %%F in ("!CORE_PATH!") do (
|
|
|
|
|
set "ATTRS=%%~aF"
|
|
|
|
|
)
|
|
|
|
|
echo !ATTRS! | findstr /c:"l" >nul
|
|
|
|
|
if !errorlevel! equ 0 (
|
|
|
|
|
echo ERROR: Install directory appears to be a symbolic link
|
|
|
|
|
echo This may indicate a symlink attack. Aborting.
|
|
|
|
|
goto :error
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM Refresh PATH for this session
|
|
|
|
|
set "PATH=%PATH%;!CORE_PATH!"
|
|
|
|
|
|
|
|
|
|
REM === Run doctor ===
|
2026-01-28 14:57:30 +00:00
|
|
|
echo.
|
|
|
|
|
echo === Verifying environment ===
|
2026-02-01 00:29:32 +11:00
|
|
|
call "!CORE_PATH!\core.exe" doctor
|
2026-02-01 00:07:45 +11:00
|
|
|
if !errorlevel! neq 0 (
|
|
|
|
|
echo WARNING: core doctor reported issues
|
|
|
|
|
)
|
2026-01-28 14:57:30 +00:00
|
|
|
|
2026-02-01 00:29:32 +11:00
|
|
|
REM === Clone repos ===
|
2026-01-28 14:57:30 +00:00
|
|
|
echo.
|
|
|
|
|
echo === Cloning repositories ===
|
2026-02-01 00:29:32 +11:00
|
|
|
call "!CORE_PATH!\core.exe" setup
|
2026-02-01 00:07:45 +11:00
|
|
|
if !errorlevel! neq 0 goto :error
|
2026-01-28 14:57:30 +00:00
|
|
|
|
|
|
|
|
echo.
|
|
|
|
|
echo === Setup complete! ===
|
|
|
|
|
echo Run 'core health' to check status
|
|
|
|
|
pause
|
2026-02-01 00:00:23 +11:00
|
|
|
endlocal
|
2026-01-28 14:57:30 +00:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
|
|
:error
|
|
|
|
|
echo.
|
|
|
|
|
echo Setup failed! Check the error above.
|
|
|
|
|
pause
|
2026-02-01 00:00:23 +11:00
|
|
|
endlocal
|
2026-01-28 14:57:30 +00:00
|
|
|
exit /b 1
|