mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Base safe-chain setupci implementation
This commit is contained in:
parent
f7589160af
commit
d1c0982942
7 changed files with 195 additions and 4 deletions
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
# Generated wrapper for {{PACKAGE_MANAGER}} by safe-chain
|
||||
# This wrapper intercepts {{PACKAGE_MANAGER}} calls for non-interactive environments
|
||||
|
||||
# Function to remove shim from PATH (POSIX-compliant)
|
||||
remove_shim_from_path() {
|
||||
echo "$PATH" | sed "s|$HOME/.safe-chain/shims:||g"
|
||||
}
|
||||
|
||||
if command -v {{AIKIDO_COMMAND}} >/dev/null 2>&1; then
|
||||
# Remove shim directory from PATH when calling {{AIKIDO_COMMAND}} to prevent infinite loops
|
||||
PATH=$(remove_shim_from_path) exec {{AIKIDO_COMMAND}} "$@"
|
||||
else
|
||||
# Dynamically find original {{PACKAGE_MANAGER}} (excluding this shim directory)
|
||||
original_cmd=$(PATH=$(remove_shim_from_path) command -v {{PACKAGE_MANAGER}})
|
||||
if [ -n "$original_cmd" ]; then
|
||||
exec "$original_cmd" "$@"
|
||||
else
|
||||
echo "Error: Could not find original {{PACKAGE_MANAGER}}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
@echo off
|
||||
REM Generated wrapper for {{PACKAGE_MANAGER}} by safe-chain
|
||||
REM This wrapper intercepts {{PACKAGE_MANAGER}} calls for non-interactive environments
|
||||
|
||||
REM Remove shim directory from PATH to prevent infinite loops
|
||||
set "SHIM_DIR=%USERPROFILE%\.safe-chain\shims"
|
||||
call set "CLEAN_PATH=%%PATH:%SHIM_DIR%;=%%"
|
||||
|
||||
REM Check if aikido command is available with clean PATH
|
||||
set "PATH=%CLEAN_PATH%" & where {{AIKIDO_COMMAND}} >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
REM Call aikido command with clean PATH
|
||||
set "PATH=%CLEAN_PATH%" & {{AIKIDO_COMMAND}} %*
|
||||
) else (
|
||||
REM Find the original command with clean PATH
|
||||
for /f "tokens=*" %%i in ('set "PATH=%CLEAN_PATH%" ^& where {{PACKAGE_MANAGER}} 2^>nul') do (
|
||||
"%%i" %*
|
||||
goto :eof
|
||||
)
|
||||
|
||||
REM If we get here, original command was not found
|
||||
echo Error: Could not find original {{PACKAGE_MANAGER}} >&2
|
||||
exit /b 1
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue