fix(bootstrap): stub Linux apt in the PATH-stripped parser test
After Kali detection stopped using grep, Ubuntu CI reached python install and called apt-get, which the macOS-oriented fixture never stubbed. Detect Kali with builtins only, and accept brew or apt-get as the python sink.
This commit is contained in:
@@ -143,14 +143,13 @@ sudo_cmd() {
|
|||||||
|
|
||||||
is_kali() {
|
is_kali() {
|
||||||
[[ -f /etc/os-release ]] || return 1
|
[[ -f /etc/os-release ]] || return 1
|
||||||
local line lowered
|
local line
|
||||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||||
lowered="$(printf '%s\n' "$line" | tr '[:upper:]' '[:lower:]')"
|
case "$line" in
|
||||||
case "$lowered" in
|
ID_LIKE=*|id_like=*) continue ;;
|
||||||
id_like=*) continue ;;
|
ID=*|id=*)
|
||||||
id=*)
|
case "$line" in
|
||||||
case "$lowered" in
|
*[Kk][Aa][Ll][Ii]*) return 0 ;;
|
||||||
*kali*) return 0 ;;
|
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ cat > "$STUB_BIN/command-stub" <<'STUB'
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
name="$(basename "$0")"
|
name="$(basename "$0")"
|
||||||
{ printf '%s' "$name"; for arg in "$@"; do printf '|%s' "$arg"; done; printf '\n'; } >> "$CALL_LOG"
|
{ printf '%s' "$name"; for arg in "$@"; do printf '|%s' "$arg"; done; printf '\n'; } >> "$CALL_LOG"
|
||||||
|
if [[ "$name" == sudo ]]; then
|
||||||
|
next="${1:-}"; shift || true
|
||||||
|
exec "$(dirname "$0")/$next" "$@"
|
||||||
|
fi
|
||||||
case "$name:${1:-}" in
|
case "$name:${1:-}" in
|
||||||
pipx:--version) printf '%s\n' "${STUB_PIPX_VERSION:-0}" ;;
|
pipx:--version) printf '%s\n' "${STUB_PIPX_VERSION:-0}" ;;
|
||||||
pnpm:--version) printf '%s\n' "${STUB_PNPM_VERSION:-0}" ;;
|
pnpm:--version) printf '%s\n' "${STUB_PNPM_VERSION:-0}" ;;
|
||||||
@@ -24,6 +28,12 @@ case "$name:${1:-}" in
|
|||||||
ln -sf "$STUB_PYTHON_SOURCE" "$STUB_ACTIVE_BIN/python3"
|
ln -sf "$STUB_PYTHON_SOURCE" "$STUB_ACTIVE_BIN/python3"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
apt-get:install)
|
||||||
|
pkg="${3:-${2:-}}"
|
||||||
|
if [[ "$pkg" == python3 ]]; then
|
||||||
|
ln -sf "$STUB_PYTHON_SOURCE" "$STUB_ACTIVE_BIN/python3"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
git:init)
|
git:init)
|
||||||
target="${!#}"; mkdir -p "$target/.git"; printf '%s\n' unpinned-head > "$target/.stub-head"
|
target="${!#}"; mkdir -p "$target/.git"; printf '%s\n' unpinned-head > "$target/.stub-head"
|
||||||
;;
|
;;
|
||||||
@@ -47,7 +57,7 @@ esac
|
|||||||
[[ "${STUB_FAIL_COMMAND:-}" != "$name" ]]
|
[[ "${STUB_FAIL_COMMAND:-}" != "$name" ]]
|
||||||
STUB
|
STUB
|
||||||
chmod +x "$STUB_BIN/command-stub"
|
chmod +x "$STUB_BIN/command-stub"
|
||||||
for name in git node npm npx pipx pnpm sleep nc; do ln -s command-stub "$STUB_BIN/$name"; done
|
for name in git node npm npx pipx pnpm sleep nc apt-get sudo; do ln -s command-stub "$STUB_BIN/$name"; done
|
||||||
ln -s command-stub "$STUB_BIN/brew"
|
ln -s command-stub "$STUB_BIN/brew"
|
||||||
|
|
||||||
cat > "$STUB_BIN/python3" <<STUB
|
cat > "$STUB_BIN/python3" <<STUB
|
||||||
@@ -102,17 +112,26 @@ anything_pin=$(json_value anything-analyzer pinnedCommit)
|
|||||||
NO_PYTHON_BIN="$SCRATCH/no-python-bin"
|
NO_PYTHON_BIN="$SCRATCH/no-python-bin"
|
||||||
PARSER_FIXTURE="$SCRATCH/parser-bootstrap"
|
PARSER_FIXTURE="$SCRATCH/parser-bootstrap"
|
||||||
mkdir -p "$NO_PYTHON_BIN"
|
mkdir -p "$NO_PYTHON_BIN"
|
||||||
for name in git node npm npx pipx pnpm sleep nc brew; do ln -s "$STUB_BIN/command-stub" "$NO_PYTHON_BIN/$name"; done
|
for name in git node npm npx pipx pnpm sleep nc brew apt-get sudo; do ln -s "$STUB_BIN/command-stub" "$NO_PYTHON_BIN/$name"; done
|
||||||
for tool in bash uname dirname mktemp rm head tr basename mkdir cat ln; do ln -s "$(command -v "$tool")" "$NO_PYTHON_BIN/$tool"; done
|
for tool in bash uname dirname mktemp rm head tr basename mkdir cat ln; do ln -s "$(command -v "$tool")" "$NO_PYTHON_BIN/$tool"; done
|
||||||
mkdir -p "$PARSER_FIXTURE"
|
mkdir -p "$PARSER_FIXTURE"
|
||||||
cp "$BOOTSTRAP" "$PARSER_FIXTURE/bootstrap-reverse.sh"
|
cp "$BOOTSTRAP" "$PARSER_FIXTURE/bootstrap-reverse.sh"
|
||||||
cp "$MANIFEST" "$PARSER_FIXTURE/bootstrap-manifest.json"
|
cp "$MANIFEST" "$PARSER_FIXTURE/bootstrap-manifest.json"
|
||||||
: > "$CALL_LOG"
|
: > "$CALL_LOG"
|
||||||
env PATH="$NO_PYTHON_BIN" HOME="$SCRATCH/home" CALL_LOG="$CALL_LOG" \
|
if ! env PATH="$NO_PYTHON_BIN" HOME="$SCRATCH/home" CALL_LOG="$CALL_LOG" \
|
||||||
STUB_ACTIVE_BIN="$NO_PYTHON_BIN" STUB_PYTHON_SOURCE="$STUB_BIN/python3" \
|
STUB_ACTIVE_BIN="$NO_PYTHON_BIN" STUB_PYTHON_SOURCE="$STUB_BIN/python3" \
|
||||||
REVERSE_SKILL_TOOLS_DIR="$SCRATCH/tools" CLAUDE_MCP_CONFIG="$SCRATCH/home/mcp.json" \
|
REVERSE_SKILL_TOOLS_DIR="$SCRATCH/tools" CLAUDE_MCP_CONFIG="$SCRATCH/home/mcp.json" \
|
||||||
bash "$PARSER_FIXTURE/bootstrap-reverse.sh" agent-browser --skip-refresh >/dev/null
|
bash "$PARSER_FIXTURE/bootstrap-reverse.sh" agent-browser --skip-refresh \
|
||||||
expect_line 'brew|install|python'
|
>"$SCRATCH/parser-out.log" 2>&1; then
|
||||||
|
echo "parser-bootstrap failed:" >&2
|
||||||
|
cat "$SCRATCH/parser-out.log" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$(uname -s)" == Darwin ]]; then
|
||||||
|
expect_line 'brew|install|python'
|
||||||
|
else
|
||||||
|
expect_line 'apt-get|install|-y|python3'
|
||||||
|
fi
|
||||||
expect_line "npm|install|-g|$(json_value agent-browser npmPackage)"
|
expect_line "npm|install|-g|$(json_value agent-browser npmPackage)"
|
||||||
! grep -Fq '|pip|install|' "$CALL_LOG"
|
! grep -Fq '|pip|install|' "$CALL_LOG"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user