fix: harden shadow v3 preflight and export guards
This commit is contained in:
@@ -31,8 +31,13 @@ if errorlevel 1 (call :fail "jps is not available on PATH" & exit /b 1)
|
||||
where sqlcmd >nul 2>nul
|
||||
if errorlevel 1 (call :fail "sqlcmd is not available on PATH" & exit /b 1)
|
||||
|
||||
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
|
||||
if errorlevel 1 (call :fail "cannot create OUTPUT_DIR" & exit /b 1)
|
||||
if exist "%OUTPUT_DIR%" (
|
||||
dir /a /b "%OUTPUT_DIR%" >nul 2>nul
|
||||
if not errorlevel 1 (call :fail "OUTPUT_DIR already exists and is not empty" & exit /b 1)
|
||||
) else (
|
||||
mkdir "%OUTPUT_DIR%"
|
||||
if errorlevel 1 (call :fail "cannot create OUTPUT_DIR" & exit /b 1)
|
||||
)
|
||||
|
||||
pushd "%REPO_ROOT%" >nul
|
||||
if errorlevel 1 (call :fail "cannot enter REPO_ROOT" & exit /b 1)
|
||||
@@ -52,11 +57,18 @@ if errorlevel 1 (call :fail "cannot collect JVM process evidence" & exit /b 1)
|
||||
(
|
||||
for /f "tokens=1 delims==" %%E in ('set FORTUCKY_ 2^>nul') do echo %%E
|
||||
) > "%OUTPUT_DIR%\environment-variable-names.txt"
|
||||
if errorlevel 1 (call :fail "cannot collect environment variable evidence" & exit /b 1)
|
||||
call :require_output "environment-variable-names.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
|
||||
sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -w 65535 -y 0 -Y 0 -v WarehouseId="%WAREHOUSE_ID%" StartUtc="%START_UTC%" OutputDir="%OUTPUT_DIR%" -i "%SQL_FILE%"
|
||||
if errorlevel 1 (call :fail "read-only SQL export failed" & exit /b 1)
|
||||
|
||||
set "LOG_CANDIDATE="
|
||||
for /f "delims=" %%L in ('dir /s /b "%LOG_DIR%\*.log" "%LOG_DIR%\*.txt" 2^>nul') do set "LOG_CANDIDATE=%%L"
|
||||
if not defined LOG_CANDIDATE (call :fail "LOG_DIR has no readable .log or .txt candidate" & exit /b 1)
|
||||
findstr /S /I /N /C:"shadow_failure" "%LOG_DIR%\*.log" "%LOG_DIR%\*.txt" > "%OUTPUT_DIR%\shadow-warnings.txt" 2>nul
|
||||
if errorlevel 2 (call :fail "cannot read log sources" & exit /b 1)
|
||||
|
||||
call :require_output "sql-diagnostics.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
|
||||
Reference in New Issue
Block a user