From 42866826867dcd8aca189cb2d67ec24e229fbbfa Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Tue, 14 Jul 2026 22:12:42 -0400 Subject: [PATCH] fix(network-ops): use uv pip install for venvs without pip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The runtime Python is a uv-managed venv that intentionally excludes pip. _ensure_impacket_installed tried sys.executable -m pip which always fails silently. Now tries uv pip install --python first (which works in uv venvs), then falls back to pip. Also removes the impacket readiness check from capability.yaml — it tested system python3 (3.13) not the runtime Python (3.12), so it always passed even when broken. _ensure_impacket_installed handles this at import time instead. Bump to 2.1.5. Co-Authored-By: Claude Opus 4.6 (1M context) --- capabilities/network-ops/capability.yaml | 4 +-- capabilities/network-ops/tools/impacket.py | 37 +++++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/capabilities/network-ops/capability.yaml b/capabilities/network-ops/capability.yaml index c836468..ddb2f4b 100644 --- a/capabilities/network-ops/capability.yaml +++ b/capabilities/network-ops/capability.yaml @@ -1,6 +1,6 @@ schema: 1 name: network-ops -version: "2.1.4" +version: "2.1.5" description: > Network operations and Active Directory exploitation. Multi-agent pipeline for autonomous red teaming with Nmap scanning, Netexec @@ -35,8 +35,6 @@ dependencies: - scripts/install_coercion_tools.sh checks: - - name: impacket - command: "python3 -c 'import impacket' 2>/dev/null" - name: nmap command: "command -v nmap >/dev/null 2>&1" - name: petitpotam diff --git a/capabilities/network-ops/tools/impacket.py b/capabilities/network-ops/tools/impacket.py index 2709e71..823dbbd 100644 --- a/capabilities/network-ops/tools/impacket.py +++ b/capabilities/network-ops/tools/impacket.py @@ -91,20 +91,35 @@ def _ensure_impacket_installed() -> None: pass logger.warning( - f"impacket not importable by {sys.executable} — attempting pip install" + f"impacket not importable by {sys.executable} — attempting install" ) - for extra_args in ([], ["--break-system-packages"]): + + # Build install commands to try in order: + # 1. uv pip install --python (works in uv venvs that lack pip) + # 2. sys.executable -m pip install (works in standard venvs) + # 3. sys.executable -m pip install --break-system-packages (externally managed) + install_cmds: list[list[str]] = [] + + uv = shutil.which("uv") + if uv: + install_cmds.append( + [uv, "pip", "install", "--python", sys.executable, "impacket>=0.12.0"] + ) + + install_cmds.append( + [sys.executable, "-m", "pip", "install", "--quiet", "impacket>=0.12.0"] + ) + install_cmds.append( + [ + sys.executable, "-m", "pip", "install", "--quiet", + "--break-system-packages", "impacket>=0.12.0", + ] + ) + + for cmd in install_cmds: try: subprocess.run( - [ - sys.executable, - "-m", - "pip", - "install", - "--quiet", - "impacket>=0.12.0", - *extra_args, - ], + cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True,